查看: 2372|回复: 2

[已经解决] 光标矩形才显示物品数量,其它不显示

[复制链接]
梦石
0
星屑
445
在线时间
377 小时
注册时间
2012-11-5
回帖
196
发表于 2016-3-6 21:44:11 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
光标矩形才显示物品数量,其它不显示
怎么写?
谢谢!
11.JPG
12.JPG
13.JPG

评分

参与人数 1星屑 +35 收起 理由
RyanBern + 35 手动认可奖励

查看全部评分

梦石
0
星屑
9716
在线时间
2775 小时
注册时间
2008-9-5
回帖
3458

开拓者短篇八RM组冠军短篇九导演组亚军白银编剧

发表于 2016-3-6 22:46:21 | 显示全部楼层
本帖最后由 cinderelmini 于 2016-3-7 16:07 编辑

把这段放在【Window_Item】下面
  1. #==============================================================================
  2. # ■ Window_Item
  3. #------------------------------------------------------------------------------
  4. #  物品画面、战斗画面、显示浏览物品的窗口。
  5. #==============================================================================

  6. class Window_Item < Window_Selectable
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #--------------------------------------------------------------------------
  10.   alias sn_160306_init initialize
  11.   def initialize
  12.     sn_160306_init
  13.     @old_index = -1
  14.   end
  15.   #--------------------------------------------------------------------------
  16.   # ● 描绘项目
  17.   #     index : 项目编号
  18.   #     now   : 是否被选中
  19.   #--------------------------------------------------------------------------
  20.   def draw_item(index, now = false)
  21.     item = @data[index]
  22.     case item
  23.     when RPG::Item
  24.       number = $game_party.item_number(item.id)
  25.     when RPG::Weapon
  26.       number = $game_party.weapon_number(item.id)
  27.     when RPG::Armor
  28.       number = $game_party.armor_number(item.id)
  29.     end
  30.     if item.is_a?(RPG::Item) and
  31.        $game_party.item_can_use?(item.id)
  32.       self.contents.font.color = normal_color
  33.     else
  34.       self.contents.font.color = disabled_color
  35.     end
  36.     x = 4 + index % @column_max * (288 + 32)
  37.     y = index / @column_max * 32
  38.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  39.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  40.     bitmap = RPG::Cache.icon(item.icon_name)
  41.     opacity = self.contents.font.color == normal_color ? 255 : 128
  42.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  43.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  44.     # 被选中的话就描绘数量
  45.     return unless now
  46.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  47.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  48.   end
  49.   
  50.   #--------------------------------------------------------------------------
  51.   # ● 更新描绘物品数量
  52.   #--------------------------------------------------------------------------
  53.   def update_draw_item_number
  54.     return if @old_index == self.index
  55.     return unless self.contents
  56.     draw_item(@old_index, false)
  57.     draw_item(self.index, true)
  58.     @old_index = self.index
  59.   end
  60.   
  61.   #--------------------------------------------------------------------------
  62.   # ● 画面更新
  63.   #--------------------------------------------------------------------------
  64.   alias sn_160306_update update
  65.   def update
  66.     sn_160306_update
  67.     update_draw_item_number
  68.   end
  69. end
复制代码


把这段放在【Window_Skill】下面
  1. #==============================================================================
  2. # ■ Window_Skill
  3. #------------------------------------------------------------------------------
  4. #  特技画面、战斗画面、显示可以使用的特技浏览的窗口。
  5. #==============================================================================

  6. class Window_Skill < Window_Selectable
  7.   #--------------------------------------------------------------------------
  8.   # ● 初始化对像
  9.   #--------------------------------------------------------------------------
  10.   alias sn_160307_init initialize
  11.   def initialize(actor)
  12.     sn_160307_init(actor)
  13.     @old_index = -1
  14.   end
  15.   
  16.   #--------------------------------------------------------------------------
  17.   # ● 描绘项目
  18.   #     index : 项目编号
  19.   #     now   : 是否被选中
  20.   #--------------------------------------------------------------------------
  21.   def draw_item(index, now = false)
  22.     skill = @data[index]
  23.     if @actor.skill_can_use?(skill.id)
  24.       self.contents.font.color = normal_color
  25.     else
  26.       self.contents.font.color = disabled_color
  27.     end
  28.     x = 4 + index % 2 * (288 + 32)
  29.     y = index / 2 * 32
  30.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  31.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  32.     bitmap = RPG::Cache.icon(skill.icon_name)
  33.     opacity = self.contents.font.color == normal_color ? 255 : 128
  34.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  35.     self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
  36.     # 被选中的话就描绘消耗
  37.     return unless now
  38.     self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
  39.   end
  40.   
  41.   #--------------------------------------------------------------------------
  42.   # ● 更新描绘物品数量
  43.   #--------------------------------------------------------------------------
  44.   def update_draw_skill_cost
  45.     return if @old_index == self.index
  46.     return unless self.contents
  47.     draw_item(@old_index, false)
  48.     draw_item(self.index, true)
  49.     @old_index = self.index
  50.   end
  51.   
  52.   #--------------------------------------------------------------------------
  53.   # ● 画面更新
  54.   #--------------------------------------------------------------------------
  55.   alias sn_160307_update update
  56.   def update
  57.     sn_160307_update
  58.     update_draw_skill_cost
  59.   end
  60. end
复制代码

评分

参与人数 2星屑 +10 梦石 +1 收起 理由
RyanBern + 1 认可答案
789456qwe + 10 我很赞同

查看全部评分

回复

使用道具 举报

梦石
0
星屑
445
在线时间
377 小时
注册时间
2012-11-5
回帖
196
 楼主| 发表于 2016-3-7 14:57:41 | 显示全部楼层
cinderelmini 发表于 2016-3-6 22:46
把这段放在Window_Item下面

谢谢大神!
那特技 光标矩形显示SP值,其它不显示
怎么写?
GH.JPG

点评

楼上已更新  发表于 2016-3-7 16:07
回复

使用道具 举报

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

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部