赞 | 0 |
VIP | 0 |
好人卡 | 17 |
积分 | 1 |
经验 | 6957 |
最后登录 | 2013-5-13 |
在线时间 | 237 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 237 小时
- 注册时间
- 2011-7-28
- 帖子
- 81
|
- #==============================================================================
- # ■ Harts_Window_ItemCommand
- #==============================================================================
- class Harts_Window_ItemCommand < Window_Selectable
- attr_accessor :commands
- #--------------------------------------------------------------------------
- # ● 初始化,生成commands窗口
- #--------------------------------------------------------------------------
- def initialize
- super(0, 128, 160, 352)
- self.contents = Bitmap.new(width - 32, height - 32)
- @commands = []
- #————————生成commands窗口
- for i in 1...$data_items.size
- if $game_party.item_number(i) > 0
- push = true
- for com in @commands
- if com == $data_items[i].desc
- push = false
- end
- end
- if push == true
- @commands.push($data_items[i].desc)
- end
- end
- end
- for i in 1...$data_weapons.size
- if $game_party.weapon_number(i) > 0
- push = true
- for com in @commands
- if com == $data_weapons[i].desc
- push = false
- end
- end
- if push == true
- @commands.push($data_weapons[i].desc)
- end
- end
- end
- for i in 1...$data_armors.size
- if $game_party.armor_number(i) > 0
- push = true
- for com in @commands
- if com == $data_armors[i].desc
- push = false
- end
- end
- if push == true
- @commands.push($data_armors[i].desc)
- end
- end
- end
- if @commands == []
- @commands.push("无任何物品")
- end
- @item_max = @commands.size
- refresh
- self.index = 0
- end
- #--------------------------------------------------------------------------
- #--------------------------------------------------------------------------
- def update_cursor_rect
- self.cursor_rect.empty
- end
- def refresh
- self.contents.clear
- for i in 0...@item_max
- draw_item(i, normal_color)
- end
- end
- #--------------------------------------------------------------------------
- #--------------------------------------------------------------------------
- def draw_item(index, color)
- self.contents.font.color = color
- y = index * 32
- self.contents.draw_text(4, y, 128, 32, @commands[index])
- end
- #--------------------------------------------------------------------------
- # 只描绘原文字
- #--------------------------------------------------------------------------
- def update_help
- @help_window.set_text(@commands[self.index])
- end
- end
- #==============================================================================
- # ■ Window_Item
- #==============================================================================
- class Harts_Window_ItemList < Window_Selectable
- #--------------------------------------------------------------------------
- #--------------------------------------------------------------------------
- def initialize
- super(160, 64, 480, 416)
- refresh
- self.index = 0
- end
- #--------------------------------------------------------------------------
- #--------------------------------------------------------------------------
- def item
- return @data[self.index]
- end
- #--------------------------------------------------------------------------
- #--------------------------------------------------------------------------
- def refresh
- if self.contents != nil
- self.contents.dispose
- self.contents = nil
- end
- @data = []
- end
- #--------------------------------------------------------------------------
- #--------------------------------------------------------------------------
- def set_item(command)
- refresh
- for i in 1...$data_items.size
- if $game_party.item_number(i) > 0 and $data_items[i].desc == command
- @data.push($data_items[i])
- end
- end
- for i in 1...$data_weapons.size
- if $game_party.weapon_number(i) > 0 and $data_weapons[i].desc == command
- @data.push($data_weapons[i])
- end
- end
- for i in 1...$data_armors.size
- if $game_party.armor_number(i) > 0 and $data_armors[i].desc == command
- @data.push($data_armors[i])
- end
- end
- @item_max = @data.size
- if @item_max > 0
- self.contents = Bitmap.new(width - 32, row_max * 32)
- self.contents.clear
- for i in 0...@item_max
- draw_item(i)
- end
- end
- end
- #--------------------------------------------------------------------------
- #--------------------------------------------------------------------------
- def item_number
- return @item_max
- end
- #--------------------------------------------------------------------------
- #--------------------------------------------------------------------------
- def draw_item(index)
- item = @data[index]
- case item
- when RPG::Item
- number = $game_party.item_number(item.id)
- when RPG::Weapon
- number = $game_party.weapon_number(item.id)
- when RPG::Armor
- number = $game_party.armor_number(item.id)
- end
- if item.is_a?(RPG::Item) and
- $game_party.item_can_use?(item.id)
- self.contents.font.color = normal_color
- else
- self.contents.font.color = disabled_color
- end
- x = 4
- y = index * 32
- bitmap = RPG::Cache.icon(item.icon_name)
- opacity = self.contents.font.color == normal_color ? 255 : 128
- self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
- self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
- self.contents.draw_text(x + 400, y, 16, 32, ":", 1)
- self.contents.draw_text(x + 416, y, 24, 32, number.to_s, 2)
- end
- #--------------------------------------------------------------------------
- #--------------------------------------------------------------------------
- def update_cursor_rect
- self.cursor_rect.empty
- end
- def update_help
- @help_window.set_text(self.item == nil ? "" : self.item.description)
- end
- end
复制代码 替换原来的 |
|