#encoding:utf-8
#==============================================================================
# ■ 带有大图标,推展线索的物品栏
#------------------------------------------------------------------------------
# 适合解密类游戏的菜单,
# 脚本:VIPArcher
# 美工 && 创意:断电
# -- 本脚本来自 [url]https://rpg.blue[/url] 使用或转载请保留以上信息。
#==============================================================================
# 使用说明:
# 物品备注栏备注 <image:文件名> 显示大图
# 物品备注栏备注 <no se> 使用不播放使用道具音效
# 物品备注栏备注 <clue:内容> 显示线索,支持控制符。
#==============================================================================
# ■ 设定部分
#==============================================================================
module VIPArcher
BACKGROUND = "itembackground" #背景图片文件名
module Item_Help #物品栏的帮助窗口
X = 47 # 窗口x坐标
Y = 58 # 窗口y坐标
Width = 282 # 窗口宽度
Height = 83 # 窗口高度
Font_Outline = false # 描边
Font_Bold = false # 粗体
Font_Color = Color.new(255,255,255) # 字体颜色
Font_Size = 20 # 字体大小
Font_Name = "迷你简粗圆" # 字体名称
end
module Item_Name #物品的名称窗口
X = 61 # 窗口x坐标
Y = 12 # 窗口y坐标
Width = 259 # 窗口宽度
Height = 60 # 窗口高度
Font_Outline = false # 描边
Font_Bold = false # 粗体
Font_Color = Color.new(255,255,255) # 字体颜色
Font_Size = 28 # 字体大小
Font_Name = "迷你简粗圆" # 字体名称
end
module Item_List #物品栏的列表窗口
X = 332 # 窗口x坐标
Y = 115 # 窗口y坐标
Width = 259 # 窗口宽度
Height = 346 # 窗口高度
Font_Outline = false # 描边
Font_Bold = false # 粗体
Font_Color = Color.new(255,255,255) # 字体颜色
Font_Size = 28 # 字体大小
Font_Name = "迷你简粗圆" # 字体名称
No_Number = false #是否描绘物品个数
end
module Item_Note #物品的备注信息窗口
X = 47 # 窗口x坐标
Y = 134 # 窗口y坐标
Width = 282 # 窗口宽度
Height = 115 # 窗口高度
Regex = /<Clue:\s*(.*)>/im # 正则匹配式
Font_Outline = false # 描边
Font_Bold = false # 粗体
Font_Color = Color.new(255,255,255) # 字体颜色
Font_Size = 20 # 字体大小
Font_Name = "迷你简粗圆" # 字体名称
end
module Item_Image #物品的大图窗口
X = 10 # 窗口x坐标
Y = 293 # 窗口y坐标
Width = 206 # 窗口宽度
Height = 202 # 窗口高度
Regex = /<Image:\s*(\S*)>/i # 正则匹配式
end
module Item_Category #物品的分类窗口
X = Graphics.width - 200 # 窗口x坐标
Y = 10 # 窗口y坐标
Width = 300 # 窗口宽度
Height = 115 # 窗口高度
#各分类的对应的图标文件名(分别对应着[道具,武器,贵重物品,防具])
#这里有几项就有几个分类
Category_Name = ["道具","收藏","线索"]
end
end
module Cache
#--------------------------------------------------------------------------
# ● 获取物品栏图片
#--------------------------------------------------------------------------
def self.ItemImage(filename)
load_bitmap("Graphics/itemimage/", filename)
end
end
class Window_Base < Window
#----------------------------------------------------------------------
# ● 绘制物品栏图片
#--------------------------------------------------------------------------
def draw_itemimage(x, y, itemimage)
bitmap = Cache.ItemImage(itemimage)
contents.blt(x, y, bitmap, bitmap.rect)
bitmap.dispose
end
end
class Window_Selectable < Window_Base
attr_reader :item_image_window # 图片窗口
attr_reader :item_name_window # 名字窗口
attr_reader :item_note_window # 名字窗口
#--------------------------------------------------------------------------
# ● 设置图片帮助窗口
#--------------------------------------------------------------------------
def item_image_window=(item_image_window)
@item_image_window = item_image_window
end
#--------------------------------------------------------------------------
# ● 设置名称帮助窗口
#--------------------------------------------------------------------------
def item_name_window=(item_name_window)
@item_name_window = item_name_window
end
#--------------------------------------------------------------------------
# ● 设置备注帮助窗口
#--------------------------------------------------------------------------
def item_note_window=(item_note_window)
@item_note_window = item_note_window
end
end
class Window_Help < Window_Base
include VIPArcher::Item_Help
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize(line_number = 2,width = Graphics.width)
super(0, 0,width, fitting_height(line_number))
end
#--------------------------------------------------------------------------
# ● 重置字体设置
#--------------------------------------------------------------------------
alias vip_20140921_rfs reset_font_settings
def reset_font_settings
vip_20140921_rfs
if SceneManager.scene_is?(Scene_Item)
contents.font.name = Font_Name
contents.font.outline = Font_Outline
contents.font.color.set(Font_Color)
contents.font.size = Font_Size
contents.font.bold = Font_Bold
end
end
end
#显示物品备注信息的窗口
class Window_Item_Note < Window_Base
include VIPArcher::Item_Note
#--------------------------------------------------------------------------
# ● 设置内容
#--------------------------------------------------------------------------
def set_text(text)
if text != @text
@text = text
refresh
end
end
#--------------------------------------------------------------------------
# ● 清除
#--------------------------------------------------------------------------
def clear
set_text("")
end
#--------------------------------------------------------------------------
# ● 设置物品
# item : 技能、物品等
#--------------------------------------------------------------------------
def set_item(item)
item.note =~ Regex if item
$1 == nil ? set_text("") : set_text($1)
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_text_ex(0, 0, @text)
end
#--------------------------------------------------------------------------
# ● 重置字体设置
#--------------------------------------------------------------------------
alias vip_20140921_rfs reset_font_settings
def reset_font_settings
vip_20140921_rfs
if SceneManager.scene_is?(Scene_Item)
contents.font.name = Font_Name
contents.font.outline = Font_Outline
contents.font.color.set(Font_Color)
contents.font.size = Font_Size
contents.font.bold = Font_Bold
end
end
end
#显示物品名称的窗口
class Window_Item_Name < Window_Base
include VIPArcher::Item_Name
#--------------------------------------------------------------------------
# ● 设置内容
#--------------------------------------------------------------------------
def set_text(text)
if text != @text
@text = text
refresh
end
end
#--------------------------------------------------------------------------
# ● 清除
#--------------------------------------------------------------------------
def clear
set_text("")
end
#--------------------------------------------------------------------------
# ● 设置物品
# item : 技能、物品等
#--------------------------------------------------------------------------
def set_item(item)
set_text(item ? item.name : "")
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
contents.clear
contents.font.name = Font_Name
contents.font.outline = Font_Outline
contents.font.color.set(Font_Color)
contents.font.size = Font_Size
contents.font.bold = Font_Bold
draw_text(4, 0, 220, line_height, @text, 0)
end
end
#显示物品详细图片的窗口
class Window_Item_Image < Window_Base
include VIPArcher::Item_Image
#--------------------------------------------------------------------------
# ● 设置内容
#--------------------------------------------------------------------------
def set_text(text)
if text != @text
@text = text
refresh
end
end
#--------------------------------------------------------------------------
# ● 清除
#--------------------------------------------------------------------------
def clear
set_text("")
end
#--------------------------------------------------------------------------
# ● 设置物品
# item : 技能、物品等
#--------------------------------------------------------------------------
def set_item(item)
item.note =~ Regex if item
$1 == nil ? set_text("") : set_text($1)
end
#--------------------------------------------------------------------------
# ● 刷新
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_itemimage(0,0,@text) if @text != ""
end
end
#显示分类名字图片的窗口
class Window_Item_Category < Window_Base
include VIPArcher::Item_Category
def initialize(x, y, width, height)
super
@category_name = Category_Name[0]
refresh
end
#--------------------------------------------------------------------------
# ● 设置分类图片
#--------------------------------------------------------------------------
def category_name=(category)
return if @category_name == category
@category_name = category
refresh
end
#--------------------------------------------------------------------------
# ● 刷新窗口
#--------------------------------------------------------------------------
def refresh
contents.clear
draw_itemimage(0,0,@category_name)
end
end
class Window_ItemList < Window_Selectable
include VIPArcher::Item_List
alias vip20140921_update_help update_help
attr_accessor :category_id
#--------------------------------------------------------------------------
# ● 初始化对象
#--------------------------------------------------------------------------
def initialize(x, y, width, height)
super
@category_id = 0
@category = :item #VIP
[url=home.php?mod=space&uid=2653549]@data[/url] = []
end
#--------------------------------------------------------------------------
# ● 获取列数
#--------------------------------------------------------------------------
def col_max
return scene_im? ? 1 : 2
end
#--------------------------------------------------------------------------
# ● 获取行高
#--------------------------------------------------------------------------
def line_height
return scene_im? ? 33 : 24
end
def scene_im?
SceneManager.scene_is?(Scene_Item) ||
SceneManager.scene_is?(Scene_Map)
end
#--------------------------------------------------------------------------
# ● 绘制物品(取消半透明图标的y+4)
#--------------------------------------------------------------------------
def draw_item_name(item, x, y, enabled = true, width = 172)
return unless item
draw_icon(item.icon_index, x, y + 4)
change_color(normal_color)
if SceneManager.scene_is?(Scene_Item) ||
SceneManager.scene_is?(Scene_Map)
contents.font.name = Font_Name
contents.font.outline = Font_Outline
contents.font.color.set(Font_Color)
contents.font.size = Font_Size
contents.font.bold = Font_Bold
end
draw_text(x + 24, y, width, line_height, item.name)
end
#--------------------------------------------------------------------------
# ● 绘制物品个数
#--------------------------------------------------------------------------
def draw_item_number(rect, item);end unless No_Number
#--------------------------------------------------------------------------
# ● 更新帮助内容
#--------------------------------------------------------------------------
def update_help
vip20140921_update_help
@item_image_window.set_item(item) if @item_image_window
@item_name_window.set_item(item) if @item_name_window
@item_note_window.set_item(item) if @item_note_window
end
end
#==============================================================================
# ■ Scene_Item
#------------------------------------------------------------------------------
# 物品画面
#==============================================================================
class Scene_Item < Scene_ItemBase
include VIPArcher
#--------------------------------------------------------------------------
# ● 开始处理
#--------------------------------------------------------------------------
def start
super
create_help_window
create_item_window
create_item_image_window
create_item_name_window
create_category_window
create_item_note_window
on_category_ok
window_opacity
end
#--------------------------------------------------------------------------
# ● 生成物品窗口
#--------------------------------------------------------------------------
def create_item_window
x = Item_List::X
y = Item_List::Y
w = Item_List::Width
h = Item_List::Height
@item_window = Window_ItemList.new(x,y,w,h)
@item_window.viewport = @viewport
@item_window.help_window = @help_window
@item_window.set_handler(:ok, method(:on_item_ok))
@item_window.set_handler(:cancel, method(:return_scene))
@item_window.set_handler(:pagedown, method(:next_category))
@item_window.set_handler(:pageup, method(:prev_category))
end
#分类窗口
def create_category_window
x = Item_Category::X
y = Item_Category::Y
w = Item_Category::Width
h = Item_Category::Height
@category_window = Window_Item_Category.new(x,y,w,h)
@category_window.viewport = @viewport
end
#上一分类
def prev_category
size = Item_Category::Category_Name.size - 1
@item_window.category_id == 0 ? @item_window.category_id = size : @item_window.category_id -= 1
on_category_change
@item_window.activate
@item_window.index = 0
end
#下一分类
def next_category
size = Item_Category::Category_Name.size - 1
@item_window.category_id == size ? @item_window.category_id = 0 : @item_window.category_id += 1
on_category_change
@item_window.activate
@item_window.index = 0
end
#切换分类
def on_category_change
case @item_window.category_id
when 0
@item_window.category = :item
@category_window.category_name = Item_Category::Category_Name[0]
when 1
@item_window.category = :weapon
@category_window.category_name = Item_Category::Category_Name[1]
when 2
@item_window.category = :key_item
@category_window.category_name = Item_Category::Category_Name[2]
when 3
@item_window.category = :armor
@category_window.category_name = Item_Category::Category_Name[3]
end
end
#--------------------------------------------------------------------------
# ● 生成帮助窗口
#--------------------------------------------------------------------------
def create_help_window
@help_window = Window_Help.new(2,Item_Help::Width)
@help_window.viewport = @viewport
@help_window.x = Item_Help::X
@help_window.y = Item_Help::Y
@help_window.height = Item_Help::Height
end
#--------------------------------------------------------------------------
# ● 生成物品图片窗口
#--------------------------------------------------------------------------
def create_item_image_window
x = Item_Image::X
y = Item_Image::Y
w = Item_Image::Width
h = Item_Image::Height
@item_image_window = Window_Item_Image.new(x,y,w,h)
@item_image_window.viewport = @viewport
@item_window.item_image_window = @item_image_window
end
#--------------------------------------------------------------------------
# ● 生成名称窗口
#--------------------------------------------------------------------------
def create_item_name_window
x = Item_Name::X
y = Item_Name::Y
w = Item_Name::Width
h = Item_Name::Height
@item_name_window = Window_Item_Name.new(x,y,w,h)
@item_name_window.viewport = @viewport
@item_window.item_name_window = @item_name_window
end
#--------------------------------------------------------------------------
# ● 备注信息窗口
#--------------------------------------------------------------------------
def create_item_note_window
x = Item_Note::X
y = Item_Note::Y
w = Item_Note::Width
h = Item_Note::Height
@item_note_window = Window_Item_Note.new(x,y,w,h)
@item_note_window.viewport = @viewport
@item_window.item_note_window = @item_note_window
end
#--------------------------------------------------------------------------
# ● 背景透明
#--------------------------------------------------------------------------
def window_opacity
@item_window.opacity = 0
@help_window.opacity = 0
@item_image_window.opacity = 0
@category_window.opacity = 0
@item_name_window.opacity = 0
@item_note_window.opacity = 0
end
#--------------------------------------------------------------------------
# ● 生成背景
#--------------------------------------------------------------------------
def create_background
@background_sprite = Sprite.new
@background_sprite.bitmap = Cache.ItemImage(BACKGROUND)
end
#--------------------------------------------------------------------------
# ● 释放背景
#--------------------------------------------------------------------------
def dispose_background
@background_sprite.dispose
end
#--------------------------------------------------------------------------
# ● 分类“确定”
#--------------------------------------------------------------------------
def on_category_ok
@item_window.activate
@item_window.select_last
@item_window.refresh
@help_window.set_item(item) #VIP
@item_image_window.set_item(item) #VIP
@item_name_window.set_item(item) #VIP
@item_note_window.set_item(item) #VIP
end
#--------------------------------------------------------------------------
# ● 播放使用物品声效 SION
#--------------------------------------------------------------------------
def play_se_for_item
Sound.play_use_item unless item.note.include? "<no se>"
end
end