赞 | 20 |
VIP | 0 |
好人卡 | 0 |
积分 | 45 |
经验 | 9447 |
最后登录 | 2024-5-13 |
在线时间 | 382 小时 |
Lv3.寻梦者
- 梦石
- 0
- 星屑
- 4531
- 在线时间
- 382 小时
- 注册时间
- 2012-11-8
- 帖子
- 275
|
本帖最后由 qq634488405 于 2023-8-9 08:33 编辑
- #--------------------------------------------------------------------------
- # ● 描绘项目
- # index : 项目编号
- # color : 文字色
- #--------------------------------------------------------------------------
- def draw_item(index, color)
- self.contents.font.color = color
- # 计算得出当前index所对应的内容所在的行
- row_index = index / @column_max
- # 根据余数得出所在的列
- for y in 0...@column_max
- if index % @column_max == y
- a = y * @width_txt
- b = 32 * row_index
- t_size = self.contents.text_size(@commands[index]).width
- a_off = (@width_txt - t_size) / 2 + a - 24
- rect = Rect.new( a, b, @width_txt, 32)
- self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
- case @type
- when 2 # 空白正方形框
- bitmap = RPG::Cache.picture("Rect_Unselected.png")
- self.contents.blt(a,b+4,bitmap,Rect.new(0,0,20,24),255)
- when 3 # 空白圆形
- bitmap = RPG::Cache.picture("Ball_Unselected.png")
- self.contents.blt(a_off,b+4,bitmap,Rect.new(0,0,20,24),255)
- when 4 # 空白正方形框及装备框
- bitmap = [RPG::Cache.picture("Rect_Unselected.png"),
- RPG::Cache.picture("Rect_Unselected_Equiped.png")]
- self.contents.blt(a_off,b+4,bitmap[0],Rect.new(0,0,20,24),255)
- when 6 # 空白圆形反色
- bitmap = RPG::Cache.picture("GBall_Unselected.png")
- self.contents.blt(a_off,b+4,bitmap,Rect.new(0,0,20,24),255)
- end
- self.contents.draw_text(rect, @commands[index],@align)
- break
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新光标矩形
- #--------------------------------------------------------------------------
- def update_cursor_rect
- # 光标位置不满 0 的情况下
- if @index < 0
- self.cursor_rect.empty
- return
- end
- # 获取当前的行
- row = @index / @column_max
- # 当前行被显示开头行前面的情况下
- if row < self.top_row
- # 从当前行向开头行滚动
- self.top_row = row
- end
- # 当前行被显示末尾行之后的情况下
- if row > self.top_row + (self.page_row_max - 1)
- # 从当前行向末尾滚动
- self.top_row = row - (self.page_row_max - 1)
- end
- # 计算光标的宽
- cursor_width = @width_txt
- # 计算光标坐标
- x = @index % @column_max * cursor_width
- y = @index / @column_max * 32 - self.oy
- y += self.oy if @type != 0
- t_size = self.contents.text_size(@commands[@index]).width
- x_off = (@width_txt - t_size) / 2 + x - 24
- case @type
- when 0 # 光标矩形
- self.cursor_rect.set(x, y, @width_txt, 32)
- when 1 # 三角光标
- bitmap = RPG::Cache.picture("Cursor.png")
- self.contents.blt(x_off, y+4,bitmap,Rect.new(0, 0, 20, 24),255)
- when 2 # 正方形选择框
- bitmap = RPG::Cache.picture("Rect_Selected.png")
- self.contents.blt(x, y+4,bitmap,Rect.new(0, 0, 20, 24),255)
- when 3 # 圆形选择框
- bitmap = RPG::Cache.picture("Ball_Selected.png")
- self.contents.blt(x_off, y+4,bitmap,Rect.new(0, 0, 20, 24),255)
- when 4 # 空白正方形框及装备框
- bitmap = [RPG::Cache.picture("Rect_Selected.png"),
- RPG::Cache.picture("Rect_Selected_Equiped.png")]
- self.contents.blt(x,y+4,bitmap[0],Rect.new(0,0,20,24),255)
- when 5 # 反色显示
- @new_command.set_size(@width_txt,32)
- @new_command.set_up(16+x+self.x,16+y+self.y,@commands[@index])
- @new_command.update
- when 6 # 圆形选择框反色
- bitmap = RPG::Cache.picture("GBall_Selected.png")
- self.contents.blt(x_off, y+4,bitmap,Rect.new(0, 0, 20, 24),255)
- when 7 # 手指选择
- bitmap = RPG::Cache.picture("Hand.png")
- self.contents.blt(x, y+3,bitmap,Rect.new(0, 0, 28, 26),255)
- end
- end
复制代码
这是我改的Window_Selectable里的两个方法,实现了用图片替换原本菜单中的方框选择框。
大致思路就是draw_item描绘未选中时的图形,update_cursor_rect描绘选中后的图形
类似的,你只要把draw_item改成显示未选择的图片,update_cursor_rect里显示选中的图片
如果你怕影响其他菜单,那就单独在你需要改变的那个菜单类里重载这两个方法
我这个图片尺寸一样的所以可以直接覆盖掉。如果无法覆盖掉的话那就draw_item的时候跳过光标位置的选项
效果如下图
|
|