| 赞 | 153 |
| VIP | |
| 好人卡 | |
| 积分 | 93 |
| 经验 | |
| 最后登录 | 2024-5-6 |
| 在线时间 | 2504 小时 |
- 梦石
- 0
- 星屑
- 9292
- 在线时间
- 2504 小时
- 注册时间
- 2011-5-20
- 回帖
- 14521

|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
我把物品菜单做成了2级分类,之后出现了一个问题
如果选择武器的查看,最后3个分类项无法显示在分类菜单,但是物品清单里是已经刷新出来了的
具体情况如图
脚本
- #encoding:utf-8
- #==============================================================================
- # ■ Window_ItemCategory
- #------------------------------------------------------------------------------
- # 物品画面和商店画面中,显示装备、所持物品等项目列表的窗口。
- #==============================================================================
- class Window_ItemCategory < Window_HorzCommand
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_reader :item_window
- #--------------------------------------------------------------------------
- # ● 初始化对象
- #--------------------------------------------------------------------------
- def initialize
- super(0, 0)
- end
- #--------------------------------------------------------------------------
- # ● 获取窗口的宽度
- #--------------------------------------------------------------------------
- def window_width
- Graphics.width
- end
- #--------------------------------------------------------------------------
- # ● 获取列数
- #--------------------------------------------------------------------------
- def col_max
- return 4
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- def update
- super
- @item_window.category = current_symbol if @item_window
- #current_symbol#:items
- end
- #--------------------------------------------------------------------------
- # ● 生成指令列表
- #--------------------------------------------------------------------------
- def make_command_list
- $listid||=0
- $typelist||=[]
- #p typelist
- #p $game_party.items#weapons#armors
-
- #@actor.added_skill_types.sort.each do |stype_id|
- # name = $data_system.skill_types[stype_id]
- # add_command(name, :skill, true, stype_id)
- #end
-
- #p $data_system.weapon_types
- #p $data_system.armor_types
-
- if $listid==0
- add_command(Vocab::item, :item)
- add_command(Vocab::weapon, :weapon)
- add_command(Vocab::armor, :armor)
- add_command(Vocab::key_item, :key_item)
- else
- if $listid==1
- $game_party.items.each{|item|item.types.each{|tid|$typelist.push(tid)}}
- $typelist.uniq!.sort!
- $typelist.each{|i|add_command(Item::TypeList[i], :item, true, i)}
- elsif $listid==2
- $game_party.equip_items.each{|item|item.types.each{|tid|
- if tid.kind_of?(Numeric)
- $typelist.push(tid)
- else
- $typelist+=tid
- end
- }
- }
- $typelist.uniq!.sort!.delete_if{|i|i>0}
- $typelist.reverse!
- $typelist.each{|i|add_command(Vocab::wtype(-i), :equip_items)}
- elsif $listid==3
- $game_party.equip_items.each{|item|item.types.each{|tid|
- if tid.kind_of?(Numeric)
- $typelist.push(tid)
- else
- $typelist+=tid
- end
- }
- }
- $typelist.uniq!.sort!.delete_if{|i|i<0}
- $typelist.each{|i|add_command(Vocab::atype(i), :equip_items)}
- end
- #(4-$typelist.size%4).times.each{|i|add_command("", "", false)} if $typelist.size%4!=0
- end
- end
- #--------------------------------------------------------------------------
- # ● 设置物品窗口
- #--------------------------------------------------------------------------
- def item_window=(item_window)
- @item_window = item_window
- update
- end
- end
复制代码
- #encoding:utf-8
- #==============================================================================
- # ■ Window_ItemList
- #------------------------------------------------------------------------------
- # 物品画面中,显示持有物品的窗口。
- #==============================================================================
- class Window_ItemList < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 初始化对象
- #--------------------------------------------------------------------------
- def initialize(x, y, width, height)
- super
- @category = :none
- @data = []
- end
- #--------------------------------------------------------------------------
- # ● 设置分类
- #--------------------------------------------------------------------------
- def category=(category)
- return if @category == category
- @category = category
- refresh
- self.oy = 0
- end
- #--------------------------------------------------------------------------
- # ● 获取行间距的宽度
- #--------------------------------------------------------------------------
- def spacing
- return 2
- end
- #--------------------------------------------------------------------------
- # ● 获取项目的宽度
- #--------------------------------------------------------------------------
- def item_width
- 24
- end
- #--------------------------------------------------------------------------
- # ● 获取列数
- #--------------------------------------------------------------------------
- def col_max
- return 20
- end
- #--------------------------------------------------------------------------
- # ● 获取项目数
- #--------------------------------------------------------------------------
- def item_max
- @data ? @data.size : 1
- end
- #--------------------------------------------------------------------------
- # ● 获取物品
- #--------------------------------------------------------------------------
- def item
- @data && index >= 0 ? @data[index] : nil
- end
- #--------------------------------------------------------------------------
- # ● 获取选择项目的有效状态
- #--------------------------------------------------------------------------
- def current_item_enabled?
- enable?(@data[index])
- end
- #--------------------------------------------------------------------------
- # ● 查询列表中是否含有此物品
- #--------------------------------------------------------------------------
- def include?(item)
- #item.types
- 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
- #--------------------------------------------------------------------------
- # ● 查询此物品是否可用
- #--------------------------------------------------------------------------
- def enable?(item)
- $game_party.usable?(item)
- end
- #--------------------------------------------------------------------------
- # ● 生成物品列表
- #--------------------------------------------------------------------------
- def make_item_list
- $list2id||=0
- @data = $game_party.all_items.select {|item| include?(item) }
- @data.clear if $listid!=0
- if $listid==1
- $game_party.items.each{|item|
- if item and $typelist.size>0
- #p $typelist[$list2id]
- @data.push(item) if item.types.include?($typelist[$list2id])
- end
- }
- elsif $listid==2
- $game_party.equip_items.each{|item|
- if item
- #p $typelist[$list2id]
- @data.push(item) if item.types.include?($typelist[$list2id])
- end
- }
- elsif $listid==3
- $game_party.equip_items.each{|item|
- if item
- #p $typelist[$list2id]
- @data.push(item) if item.types.include?($typelist[$list2id])
- end
- }
- end
-
- @data.push(nil) if include?(nil)
- end
- #--------------------------------------------------------------------------
- # ● 返回上一个选择的位置
- #--------------------------------------------------------------------------
- def select_last
- select(@data.index($game_party.last_item.object) || 0)
- end
- #--------------------------------------------------------------------------
- # ● 绘制项目
- #--------------------------------------------------------------------------
- def draw_item(index)
- item = @data[index]
- if item
- rect = item_rect(index)
- rect.width -= 4
- draw_item_icon(item, rect.x, rect.y, enable?(item))
- draw_item_number(rect, item)
- end
- end
- #--------------------------------------------------------------------------
- # ● 绘制物品个数
- #--------------------------------------------------------------------------
- def draw_item_number(rect, item)
- contents.font.size=14
- contents.font.bold = true
- change_color(text_color_id(item.namecolor))#待修改显示位置
- i_n=$game_party.item_number(item)
- if i_n>99
- draw_text(rect.x,rect.y+6,rect.width+6,rect.height, sprintf("%2d", i_n), 2)
- elsif i_n>1
- draw_text(rect.x+6,rect.y+6,rect.width,rect.height, sprintf("%2d", i_n), 2)
- end
- reset_font_settings
- end
- #--------------------------------------------------------------------------
- # ● 更新帮助内容
- #--------------------------------------------------------------------------
- def update_help
- @help_window.set_item(item)
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- make_item_list
- create_contents
- draw_all_items
- end
- end
复制代码
|
|