本帖最后由 戴迪 于 2017-2-19 00:54 编辑 自己调了装备界面item的列数,改成5行,然后在最后添加了一个移动光标矩形的间距,但是好像不能换行阿- -RUBY 代码复制下载#======== ...
2357691704 发表于 2017-2-19 12:48 #============================================================================== # ■ Window_EquipIte ...
#==============================================================================# ■ Window_EquipItem#------------------------------------------------------------------------------# 装备画面、显示浏览变更装备的候补物品的窗口。#============================================================================== class Window_EquipItem < Window_Selectable #-------------------------------------------------------------------------- # ● 初始化对像 # actor : 角色 # equip_type : 装备部位 (0~3) #-------------------------------------------------------------------------- def initialize(actor, equip_type) super(160, 256, 640, 224) @actor = actor @equip_type = equip_type @column_max = 5 refresh self.active = false self.index = -1 end #-------------------------------------------------------------------------- # ● 获取物品 #-------------------------------------------------------------------------- def item return @data[self.index] end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] # 添加可以装备的武器 if @equip_type == 0 weapon_set = $data_classes[@actor.class_id].weapon_set for i in 1...50 if $game_party.weapon_number(i) > 0 and weapon_set.include?(i) @data.push($data_weapons[i]) end end end # 添加可以装备的防具 if @equip_type != 0 armor_set = $data_classes[@actor.class_id].armor_set for i in 1...$data_armors.size if $game_party.armor_number(i) > 0 and armor_set.include?(i) if $data_armors[i].kind == @equip_type-1 @data.push($data_armors[i]) end end end end # 添加空白 @data.push(nil) # 生成位图、描绘全部项目 @item_max = @data.size self.contents = Bitmap.new(width - 32, row_max * 32) for i in 0...@item_max-1 draw_item(i) end end #-------------------------------------------------------------------------- # ● 项目的描绘 # index : 项目符号 #-------------------------------------------------------------------------- def draw_item(index) item = @data[index] x = 4 + index % 5 * (32) y = index / 5 * 32 case item when RPG::Weapon number = $game_party.weapon_number(item.id) when RPG::Armor number = $game_party.armor_number(item.id) end bitmap = RPG::Cache.icon(item.icon_name) self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24)) self.contents.font.color = normal_color #self.contents.draw_text(x + 28, y, 212, 32, item.name, 0) #self.contents.draw_text(x +32 , y, 16, 32, ":", 1) self.contents.draw_text(x , y, 24, 32, number.to_s, 2) end #-------------------------------------------------------------------------- # ● 刷新帮助文本 #-------------------------------------------------------------------------- def update_help @help_window.set_text(self.item == nil ? "" : self.item.description) end #-------------------------------------------------------------------------- # ● 刷新光标矩形 #-------------------------------------------------------------------------- def update_cursor_rect self.cursor_rect.set(@index * 32,0 , 32, 32) if @index == -1 self.cursor_rect.set(0,0, 0, 0) elsif @index > 4 and @index <= 9 self.cursor_rect.set( (@index - 5 )* 32,32 , 32, 32) elsif @index > 9 and @index <= 14 self.cursor_rect.set( (@index- 10 )* 32,64 , 32, 32) elsif @index > 14 and @index <= 19 self.cursor_rect.set( (@index- 15 )* 32,96 , 32, 32) elsif @index > 19 and @index <= 24 self.cursor_rect.set( (@index- 20 )* 32,128 , 32, 32) elsif @index > 24 self.cursor_rect.set( 24 * 32,128 , 32, 32) @index -= 1 end endend
#============================================================================== # ■ Window_EquipItem #------------------------------------------------------------------------------ # 装备画面、显示浏览变更装备的候补物品的窗口。 #============================================================================== class Window_EquipItem < Window_Selectable #-------------------------------------------------------------------------- # ● 初始化对像 # actor : 角色 # equip_type : 装备部位 (0~3) #-------------------------------------------------------------------------- def initialize(actor, equip_type) super(160, 256, 640, 224) @actor = actor @equip_type = equip_type @column_max = 5 refresh self.active = false self.index = -1 end #-------------------------------------------------------------------------- # ● 获取物品 #-------------------------------------------------------------------------- def item return @data[self.index] end #-------------------------------------------------------------------------- # ● 刷新 #-------------------------------------------------------------------------- def refresh if self.contents != nil self.contents.dispose self.contents = nil end @data = [] # 添加可以装备的武器 if @equip_type == 0 weapon_set = $data_classes[@actor.class_id].weapon_set for i in 1...50 if $game_party.weapon_number(i) > 0 and weapon_set.include?(i) @data.push($data_weapons[i]) end end end # 添加可以装备的防具 if @equip_type != 0 armor_set = $data_classes[@actor.class_id].armor_set for i in 1...$data_armors.size if $game_party.armor_number(i) > 0 and armor_set.include?(i) if $data_armors[i].kind == @equip_type-1 @data.push($data_armors[i]) end end end end # 添加空白 @data.push(nil) # 生成位图、描绘全部项目 @item_max = @data.size self.contents = Bitmap.new(width - 32, row_max * 32) for i in 0...@item_max-1 draw_item(i) end end #-------------------------------------------------------------------------- # ● 项目的描绘 # index : 项目符号 #-------------------------------------------------------------------------- def draw_item(index) item = @data[index] x = 4 + index % 5 * (32) y = index / 5 * 32 case item when RPG::Weapon number = $game_party.weapon_number(item.id) when RPG::Armor number = $game_party.armor_number(item.id) end bitmap = RPG::Cache.icon(item.icon_name) self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24)) self.contents.font.color = normal_color #self.contents.draw_text(x + 28, y, 212, 32, item.name, 0) #self.contents.draw_text(x +32 , y, 16, 32, ":", 1) self.contents.draw_text(x , y, 24, 32, number.to_s, 2) end #-------------------------------------------------------------------------- # ● 刷新帮助文本 #-------------------------------------------------------------------------- def update_help @help_window.set_text(self.item == nil ? "" : self.item.description) end #-------------------------------------------------------------------------- # ● 刷新光标矩形 #-------------------------------------------------------------------------- def update_cursor_rect self.cursor_rect.set(@index * 32,0 , 32, 32) if @index == -1 self.cursor_rect.set(0,0, 0, 0) elsif @index > 4 and @index <= 9 self.cursor_rect.set( (@index - 5 )* 32,32 , 32, 32) elsif @index > 9 and @index <= 14 self.cursor_rect.set( (@index- 10 )* 32,64 , 32, 32) elsif @index > 14 and @index <= 19 self.cursor_rect.set( (@index- 15 )* 32,96 , 32, 32) elsif @index > 19 and @index <= 24 self.cursor_rect.set( (@index- 20 )* 32,128 , 32, 32) elsif @index > 24 self.cursor_rect.set( 24 * 32,128 , 32, 32) @index -= 1 end end end
查看全部评分
折叠内容标题(非必须)
折叠内容
站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作
GMT+8, 2024-11-11 13:18
Powered by Discuz! X3.1
© 2001-2013 Comsenz Inc.