#==============================================================================
# 功能:[RMVA]增加物品栏类别
# 作者:ScottyFan
# 版本:v1.0 2013.8.8
# 使用说明:
# 在数据库-物品(包括装备)-备注 里写入 @itype[位置编号]
# 新的物品分类编号是从 1 开始。比如 @itype[1]或者@itype[2]
#==============================================================================
module SFS
CATEGORY = [ #格式["显示名称", :标识], 标识随便写,不重复即可
["", :default], #注意,不要更改此行
["药剂", :potion], #此处为编号1
["食物", :food],
["光碟", :disc],
["宝石", :gem],
]
end
class RPG::BaseItem
attr_reader :category_id
def category_id
return if self.is_a?(RPG::Skill)
if @category_id.nil?
/@itype\[(.+?)\]/ =~ @note
@category_id = $1.to_i
end
@category_id
end
end
class Window_ItemList
#--------------------------------------------------------------------------
# ● 查询列表中是否含有此物品
#--------------------------------------------------------------------------
def include?(item)
if item && item.category_id > 0 #如果是特殊类别
return @category == SFS::CATEGORY[item.category_id][1]
end
case @category
when :item
item.is_a?(RPG::Item) && !item.key_item?
when :weapon
item.is_a?(RPG::Weapon)
when :armor
item.is_a?(RPG::Armor)
when :key_item
item.is_a?(RPG::Item) && item.key_item?
else
false
end
end
end
class Window_ItemCategoryNew < Window_Command
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_reader :item_window
#--------------------------------------------------------------------------
# ● 更新画面
#--------------------------------------------------------------------------
def update
super
@item_window.category = current_symbol if @item_window
end
#--------------------------------------------------------------------------
# ● 生成指令列表
#--------------------------------------------------------------------------
def make_command_list
SFS::CATEGORY.each do |itype|
next if itype[1] == :default
add_command(itype[0], itype[1])
end
add_command("普通物品", :item)
add_command(Vocab::weapon, :weapon)
add_command(Vocab::armor, :armor)
add_command(Vocab::key_item, :key_item)
end
#--------------------------------------------------------------------------
# ● 设置物品窗口
#--------------------------------------------------------------------------
def item_window=(item_window)
@item_window = item_window
update
end
end
class Scene_Item < Scene_ItemBase
#--------------------------------------------------------------------------
# ● 生成分类窗口
#--------------------------------------------------------------------------
def create_category_window
@category_window = Window_ItemCategoryNew.new(0, @help_window.height)
@category_window.viewport = @viewport
@category_window.help_window = @help_window
@category_window.height = Graphics.height - @help_window.height
@category_window.set_handler(:ok, method(:on_category_ok))
@category_window.set_handler(:cancel, method(:return_scene))
end
#--------------------------------------------------------------------------
# ● 生成物品窗口
#--------------------------------------------------------------------------
def create_item_window
wx = @category_window.width
wh = Graphics.height - @help_window.height
@item_window = Window_ItemList.new(wx, @help_window.height, Graphics.width - wx, wh)
@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(:on_item_cancel))
@category_window.item_window = @item_window
end
end