设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1751|回复: 2
打印 上一主题 下一主题

[已经解决] 怎么把物品图标改为1行4个

 关闭 [复制链接]

Lv1.梦旅人

梦石
0
星屑
65
在线时间
1089 小时
注册时间
2010-7-31
帖子
62
跳转到指定楼层
1
发表于 2011-10-13 20:00:59 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
怎么把物品的图标改为1行放4个
  1. #==============================================================================
  2. # ■ Window_Item
  3. #------------------------------------------------------------------------------
  4. #  物品画面、战斗画面、显示浏览物品的窗口。
  5. #==============================================================================

  6. class Window_Item < Window_Selectable
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #--------------------------------------------------------------------------
  10.   def initialize
  11.     super(0, 64, 640, 416)
  12.     @column_max = 4
  13.     refresh
  14.     self.index = 0
  15.     # 战斗中的情况下将窗口移至中央并将其半透明化
  16.     if $game_temp.in_battle
  17.       self.y = 64
  18.       self.height = 256
  19.       self.back_opacity = 160
  20.     end
  21.   end
  22.   #--------------------------------------------------------------------------
  23.   # ● 获取物品
  24.   #--------------------------------------------------------------------------
  25.   def item
  26.     return @data[self.index]
  27.   end
  28.   #--------------------------------------------------------------------------
  29.   # ● 刷新
  30.   #--------------------------------------------------------------------------
  31.   def refresh
  32.     if self.contents != nil
  33.       self.contents.dispose
  34.       self.contents = nil
  35.     end
  36.     @data = []
  37.     # 添加物品
  38.     for i in 1...$data_items.size
  39.       if $game_party.item_number(i) > 0
  40.         @data.push($data_items[i])
  41.       end
  42.     end
  43.     # 在战斗中以外添加武器、防具
  44.     unless $game_temp.in_battle
  45.       for i in 1...$data_weapons.size
  46.         if $game_party.weapon_number(i) > 0
  47.           @data.push($data_weapons[i])
  48.         end
  49.       end
  50.       for i in 1...$data_armors.size
  51.         if $game_party.armor_number(i) > 0
  52.           @data.push($data_armors[i])
  53.         end
  54.       end
  55.     end
  56.     # 如果项目数不是 0 就生成位图、重新描绘全部项目
  57.     @item_max = @data.size
  58.     if @item_max > 0
  59.       self.contents = Bitmap.new(width - 32, row_max * 32)
  60.       for i in 0...@item_max
  61.         draw_item(i)
  62.       end
  63.     end
  64.   end
  65.   #--------------------------------------------------------------------------
  66.   # ● 描绘项目
  67.   #     index : 项目编号
  68.   #--------------------------------------------------------------------------
  69.   def draw_item(index)
  70.     item = @data[index]
  71.     case item
  72.     when RPG::Item
  73.       number = $game_party.item_number(item.id)
  74.     when RPG::Weapon
  75.       number = $game_party.weapon_number(item.id)
  76.     when RPG::Armor
  77.       number = $game_party.armor_number(item.id)
  78.     end
  79.     if item.is_a?(RPG::Item) and
  80.        $game_party.item_can_use?(item.id)
  81.       self.contents.font.color = normal_color
  82.     else
  83.       self.contents.font.color = disabled_color
  84.     end
  85.     x = 4 + index % 2 * (288 + 32)
  86.     y = index / 2 * 32
  87.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  88.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  89.     bitmap = RPG::Cache.icon(item.icon_name)
  90.     opacity = self.contents.font.color == normal_color ? 255 : 128
  91.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  92.     #self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  93.     #self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  94.     #self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  95.   end
  96.   #--------------------------------------------------------------------------
  97.   # ● 刷新帮助文本
  98.   #--------------------------------------------------------------------------
  99.   def update_help
  100.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  101.   end
  102. end
复制代码
这样只能有一行4个选项,可视图标还是一行两个,我该怎么修改呢

Lv2.观梦者

(?????)

梦石
0
星屑
700
在线时间
1327 小时
注册时间
2011-7-18
帖子
3184

贵宾

2
发表于 2011-10-13 20:18:28 | 只看该作者
本帖最后由 各种压力的猫君 于 2011-10-13 20:25 编辑
  1. #==============================================================================
  2. # ■ Window_Item
  3. #------------------------------------------------------------------------------
  4. #  物品画面、战斗画面、显示浏览物品的窗口。
  5. #==============================================================================

  6. class Window_Item < Window_Selectable
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #--------------------------------------------------------------------------
  10.   def initialize
  11.     super(0, 64, 640, 416)
  12. #==============================================================================
  13.     # 变成4列
  14.     @column_max = 4
  15. #==============================================================================
  16.     refresh
  17.     self.index = 0
  18.     # 战斗中的情况下将窗口移至中央并将其半透明化
  19.     if $game_temp.in_battle
  20.       self.y = 64
  21.       self.height = 256
  22.       self.back_opacity = 160
  23.     end
  24.   end
  25.   #--------------------------------------------------------------------------
  26.   # ● 获取物品
  27.   #--------------------------------------------------------------------------
  28.   def item
  29.     return @data[self.index]
  30.   end
  31.   #--------------------------------------------------------------------------
  32.   # ● 刷新
  33.   #--------------------------------------------------------------------------
  34.   def refresh
  35.     if self.contents != nil
  36.       self.contents.dispose
  37.       self.contents = nil
  38.     end
  39.     @data = []
  40.     # 添加报务
  41.     for i in 1...$data_items.size
  42.       if $game_party.item_number(i) > 0
  43.         @data.push($data_items[i])
  44.       end
  45.     end
  46.     # 在战斗中以外添加武器、防具
  47.     unless $game_temp.in_battle
  48.       for i in 1...$data_weapons.size
  49.         if $game_party.weapon_number(i) > 0
  50.           @data.push($data_weapons[i])
  51.         end
  52.       end
  53.       for i in 1...$data_armors.size
  54.         if $game_party.armor_number(i) > 0
  55.           @data.push($data_armors[i])
  56.         end
  57.       end
  58.     end
  59.     # 如果项目数不是 0 就生成位图、重新描绘全部项目
  60.     @item_max = @data.size
  61.     if @item_max > 0
  62.       self.contents = Bitmap.new(width - 32, row_max * 32)
  63.       for i in 0...@item_max
  64.         draw_item(i)
  65.       end
  66.     end
  67.   end
  68.   #--------------------------------------------------------------------------
  69.   # ● 描绘项目
  70.   #     index : 项目编号
  71.   #--------------------------------------------------------------------------
  72.   def draw_item(index)
  73.     item = @data[index]
  74.     case item
  75.     when RPG::Item
  76.       number = $game_party.item_number(item.id)
  77.     when RPG::Weapon
  78.       number = $game_party.weapon_number(item.id)
  79.     when RPG::Armor
  80.       number = $game_party.armor_number(item.id)
  81.     end
  82.     if item.is_a?(RPG::Item) and
  83.        $game_party.item_can_use?(item.id)
  84.       self.contents.font.color = normal_color
  85.     else
  86.       self.contents.font.color = disabled_color
  87.     end
  88. #==============================================================================
  89.     # 坐标计算公式改变
  90.     x = 4 + index % 4 * (128 + 32)
  91.     y = index / 4 * 32
  92. #==============================================================================
  93.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  94.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  95.     bitmap = RPG::Cache.icon(item.icon_name)
  96.     opacity = self.contents.font.color == normal_color ? 255 : 128
  97.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  98. #==============================================================================
  99.     # x坐标微调,物品名最大长度缩短
  100.     self.contents.draw_text(x + 25, y, 66, 32, item.name, 0)
  101.     self.contents.draw_text(x + 89, y, 16, 32, ":", 1)
  102.     self.contents.draw_text(x + 99, y, 24, 32, number.to_s, 2)
  103. #==============================================================================
  104.   end
  105.   #--------------------------------------------------------------------------
  106.   # ● 刷新帮助文本
  107.   #--------------------------------------------------------------------------
  108.   def update_help
  109.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  110.   end
  111. end
复制代码
这样改过之后物品名称最长3个字,超出的会被捏扁。
改过的部分在双分割线以内 - - 自己看注释对照原脚本
回复

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
65
在线时间
1089 小时
注册时间
2010-7-31
帖子
62
3
 楼主| 发表于 2011-10-13 21:13:43 | 只看该作者
本帖最后由 酱爆 于 2011-10-13 21:17 编辑
各种压力的猫君 发表于 2011-10-13 20:18
这样改过之后物品名称最长3个字,超出的会被捏扁。
改过的部分在双分割线以内 - - 自己看注释对照原脚本 ...


以解决
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-5-5 17:53

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表