查看: 2173|回复: 1

[已经解决] Window_Selectable定制

[复制链接]
梦石
0
星屑
72
在线时间
320 小时
注册时间
2011-8-30
回帖
114
发表于 2013-9-7 13:33:39 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 fm303018 于 2013-9-11 21:50 编辑

QQ图片20130911212624.rar (134.68 KB, 下载次数: 19) 修改

@item_max = 1
    @column_max = 1    改为2 以后
@Index[/url] = -1


  
11.jpg
22.jpg
33.jpg

我想专门为Scene_Menu        定制 window_Selectable 这样保证其他的正常使用 请大家帮我搞一个行吗?不会制作再次定义
只要改变
第二张图 其他回复正常
@item_max = 1
    @column_max = 2    改为2 以后
@Index
= -1

Project2.rar (187.24 KB, 下载次数: 26)

点评

不要自己更改主题标签。  发表于 2013-9-7 16:50
已编辑,可以叫版主来了  发表于 2013-9-7 14:57
天之痕同人游戏填坑中
游戏名称: 天之痕前传
游戏进度: 百分之二十  
游戏素材: 素材制作中。。。
游戏脚本: 百分之九十九
游戏剧本: 百分之五

薄凉看客

梦石
0
星屑
50
在线时间
1269 小时
注册时间
2010-6-20
回帖
1223
发表于 2013-9-7 13:34:35 | 显示全部楼层
本帖最后由 恋′挂机 于 2013-9-7 15:48 编辑

那个是列数,改过之后表示,现有列数为2当然那个样子了
直接这样就可以了。。
[pre lang="ruby" line="1"]#==============================================================================
# ■ Window_Command    超级命令窗体的类。
#------------------------------------------------------------------------------
#   脚本作者:薄凉看客,转载或使用请保留此信息。
#==============================================================================
=begin

在生成Command.new时后边可以有第三个参数——一个数组(另附加一个图标文件名数组)

数组详细说明(数组参数是非必须的,可有可无):
[0:列数, 1:X坐标, 2:Y坐标, 3:Z坐标, 4:未选中字体大小, 5:选中字体大小,
6:未选中字体时的颜色, 7:选中字体时的颜色, 8:未选中时的字体名, 9:选中时的字体名,
10:项目无效化时的字体名, 11:项目无效化1, 12:项目无效化2, 13:项目无效化3,
14:项目无效化4, 15:窗口的不透明度, 16:背景的不透明度, 17:内容的不透明度,
18:是否显示图标]
注:如果需要显示图标,需要再加一个数组参数(非必须)来指定图标文件名(
当然也可以使用默认图标,数组内指定的图标会按012345的顺序依次显示,而
且不管你有几个选项,你都必须指定6个图标名,否则按默认处理)。

举个例子:

#---------把Scene_Menu的26行脚本替换为以下内容,就能看到效果---------

array_menu = []
array_menu[0] = 6#让选择项横着选
array_menu[1] = 0#修改命令窗体的X坐标
array_menu[2] = 100#修改命令窗体的Y坐标为100
array_menu[4] = 15#修改命令窗体未选中时的字体大小为15
array_menu[5] = 22#修改命令窗体选中时的字体大小为22
array_menu[3] = 500#修改Z坐标,保证命令窗体显示在最上方
array_menu[11] = 5#让5号选择项(即结束)无效化
array_menu[15] = 150#修改窗体的不透明度
array_menu[16] = 150#修改背景的不透明度
array_menu[17] = 150#修改内容的不透明度
array_menu[18] = true#给命令窗体显示上图标
icon_commands = ["041-Item10.png", "050-Skill07.png",
"019-Accessory04.png", "045-Skill02.png", "036-Item05.png",
"046-Skill03.png"]#这是指定图标文件名
mmand_window = Window_Command.new(640, [s1, s2, s3, s4, s5, s6],
array_menu, icon_commands)

#---------把Scene_Menu的26行脚本替换为以上内容,就能看到效果---------

=end
class Window_Command < Window_Selectable
  def initialize(width, command, commands = [], icon_commands = 0)
    if icon_commands = 0 or icon_commands.class != Array
      icon_commands = ["041-Item10.png", "050-Skill07.png",
      "019-Accessory04.png", "045-Skill02.png", "036-Item05.png",
      "046-Skill03.png"]
    elsif icon_commands.class == Array and (icon_commands[0] == nil or
      icon_commands[1] == nil or icon_commands[2] == nil or
      icon_commands[3] == nil or icon_commands[4] == nil or
      icon_commands[5] == nil)
      icon_commands = ["041-Item10.png", "050-Skill07.png",
      "019-Accessory04.png", "045-Skill02.png", "036-Item05.png",
      "046-Skill03.png"]
    end  
    if commands.class != Array
      commands = []
    end  
    if commands[0] == 1 or commands[0] == nil
      if commands[1] == nil and commands[2] != nil
      super(0, commands[2], width, command.size * 32 + 32)
      elsif commands[1] != nil and commands[2] == nil
      super(commands[1], 0, width, command.size * 32 + 32)
      elsif commands[1] == nil and commands[2] == nil
      super(0, 0, width, command.size * 32 + 32)
      elsif commands[1] != nil and commands[2] != nil
      super(commands[1], commands[2], width, command.size * 32 + 32)      
      end
    else
      if commands[1] == nil and commands[2] != nil
      super(0, commands[2], width, 64)
      elsif commands[1] != nil and commands[2] == nil
      super(commands[1], 0, width, 64)
      elsif commands[1] == nil and commands[2] == nil
      super(0, 0, width, 64)
      elsif commands[1] != nil and commands[2] != nil
      super(commands[1], commands[2], width, 64)
      end
    end
    if commands[3] != nil
    self.z = commands[3]
    else
    self.z = 100
    end
    @command = command
    @item_max = @command.size
    if commands[0] != nil
    @column_max = commands[0]
    else
    @column_max = 1
    end
    if commands[4] != nil
    @size1 = commands[4]
    else
    @size1 = 22
    end
    if commands[5] != nil
    @size2 = commands[5]
    else
    @size2 = 22
    end
    if commands[6] != nil
    @color1 = commands[6]
    else
    @color1 = normal_color
    end
    if commands[7] != nil
    @color2 = commands[7]
    else
    @color2 = normal_color
    end
    if commands[8] != nil
    @name1 = commands[8]
    else
    @name1 = "黑体"
    end
    if commands[9] != nil
    @name2 = commands[9]
    else
    @name2 = "黑体"
    end
    if commands[10] != nil
    @name3 = commands[10]
    else
    @name3 = "黑体"
    end
    if commands[11] != nil
    @disable_item1 = commands[11]
    else
    @disable_item1 = -1
    end
    if commands[12] != nil
    @disable_item2 = commands[12]
    else
    @disable_item2 = -1
    end
    if commands[13] != nil
    @disable_item3 = commands[13]
    else
    @disable_item3 = -1
    end
    if commands[14] != nil
    @disable_item4 = commands[14]
    else
    @disable_item4 = -1
    end
    self.contents = Bitmap.new(width - 32, @item_max * 32)
    if commands[15] != nil and commands[15] >= 0 and commands[15] <= 255
      self.opacity = commands[15]
    else
      self.opacity = 255
    end  
    if commands[16] != nil and commands[16] >= 0 and commands[16] <= 255
      self.back_opacity = commands[16]
    else
      self.back_opacity = 255
    end
    if commands[17] != nil and commands[17] >= 0 and commands[17] <= 255
      self.contents_opacity = commands[17]
    else
      self.contents_opacity = 255
    end
    @icon_commands = icon_commands
    @commands = commands
    if @column_max != 1 and @commands[18] == true
    @x1 = 0 % @column_max * ((width - 32) / @column_max)
    @x2 = 1 % @column_max * ((width - 32) / @column_max + 5)
    @x3 = 2 % @column_max * ((width - 32) / @column_max + 5)
    @x4 = 3 % @column_max * ((width - 32) / @column_max + 5)
    @x5 = 4 % @column_max * ((width - 32) / @column_max + 5)
    @x6 = 5 % @column_max * ((width - 32) / @column_max + 5)
    end
    refresh
    self.index = 0
  end
  def refresh
    self.contents.clear
    if @column_max != 1 and @commands[18] == true
      case @item_max
      when 1
      bitmap = RPG::Cache.icon(@icon_commands[0])
      self.contents.blt(@x1, 4, bitmap, Rect.new(0, 0, 24, 24))
      when 2
      bitmap = RPG::Cache.icon(@icon_commands[0])
      self.contents.blt(@x1, 4, bitmap, Rect.new(0, 0, 24, 24))
      bitmap = RPG::Cache.icon(@icon_commands[1])
      self.contents.blt(@x2, 4, bitmap, Rect.new(0, 0, 24, 24))
      when 3
      bitmap = RPG::Cache.icon(@icon_commands[0])
      self.contents.blt(@x1, 4, bitmap, Rect.new(0, 0, 24, 24))
      bitmap = RPG::Cache.icon(@icon_commands[1])
      self.contents.blt(@x2, 4, bitmap, Rect.new(0, 0, 24, 24))
      bitmap = RPG::Cache.icon(@icon_commands[2])
      self.contents.blt(@x3, 4, bitmap, Rect.new(0, 0, 24, 24))
      when 4
      bitmap = RPG::Cache.icon(@icon_commands[0])
      self.contents.blt(@x1, 4, bitmap, Rect.new(0, 0, 24, 24))
      bitmap = RPG::Cache.icon(@icon_commands[1])
      self.contents.blt(@x2, 4, bitmap, Rect.new(0, 0, 24, 24))
      bitmap = RPG::Cache.icon(@icon_commands[2])
      self.contents.blt(@x3, 4, bitmap, Rect.new(0, 0, 24, 24))
      bitmap = RPG::Cache.icon(@icon_commands[3])
      self.contents.blt(@x4, 4, bitmap, Rect.new(0, 0, 24, 24))
      when 5
      bitmap = RPG::Cache.icon(@icon_commands[0])
      self.contents.blt(@x1, 4, bitmap, Rect.new(0, 0, 24, 24))
      bitmap = RPG::Cache.icon(@icon_commands[1])
      self.contents.blt(@x2, 4, bitmap, Rect.new(0, 0, 24, 24))
      bitmap = RPG::Cache.icon(@icon_commands[2])
      self.contents.blt(@x3, 4, bitmap, Rect.new(0, 0, 24, 24))
      bitmap = RPG::Cache.icon(@icon_commands[3])
      self.contents.blt(@x4, 4, bitmap, Rect.new(0, 0, 24, 24))
      bitmap = RPG::Cache.icon(@icon_commands[4])
      self.contents.blt(@x5, 4, bitmap, Rect.new(0, 0, 24, 24))
      when 6
      bitmap = RPG::Cache.icon(@icon_commands[0])
      self.contents.blt(@x1, 4, bitmap, Rect.new(0, 0, 24, 24))
      bitmap = RPG::Cache.icon(@icon_commands[1])
      self.contents.blt(@x2, 4, bitmap, Rect.new(0, 0, 24, 24))
      bitmap = RPG::Cache.icon(@icon_commands[2])
      self.contents.blt(@x3, 4, bitmap, Rect.new(0, 0, 24, 24))
      bitmap = RPG::Cache.icon(@icon_commands[3])
      self.contents.blt(@x4, 4, bitmap, Rect.new(0, 0, 24, 24))
      bitmap = RPG::Cache.icon(@icon_commands[4])
      self.contents.blt(@x5, 4, bitmap, Rect.new(0, 0, 24, 24))   
      bitmap = RPG::Cache.icon(@icon_commands[5])
      self.contents.blt(@x6, 4, bitmap, Rect.new(0, 0, 24, 24))
      end
    elsif @column_max == 1 and @commands[18] == true
      case @item_max
      when 1
      bitmap = RPG::Cache.icon(@icon_commands[0])
      self.contents.blt(0, 4, bitmap, Rect.new(0, 0, 24, 24))
      when 2
      bitmap = RPG::Cache.icon(@icon_commands[0])
      self.contents.blt(0, 4, bitmap, Rect.new(0, 0, 24, 24))      
      bitmap = RPG::Cache.icon(@icon_commands[1])
      self.contents.blt(0, 32 + 4, bitmap, Rect.new(0, 0, 24, 24))
      when 3
      bitmap = RPG::Cache.icon(@icon_commands[0])
      self.contents.blt(0, 4, bitmap, Rect.new(0, 0, 24, 24))      
      bitmap = RPG::Cache.icon(@icon_commands[1])
      self.contents.blt(0, 32 + 4, bitmap, Rect.new(0, 0, 24, 24))
      bitmap = RPG::Cache.icon(@icon_commands[2])
      self.contents.blt(0, 64 + 4, bitmap, Rect.new(0, 0, 24, 24))
      when 4
      bitmap = RPG::Cache.icon(@icon_commands[0])
      self.contents.blt(0, 4, bitmap, Rect.new(0, 0, 24, 24))      
      bitmap = RPG::Cache.icon(@icon_commands[1])
      self.contents.blt(0, 32 + 4, bitmap, Rect.new(0, 0, 24, 24))
      bitmap = RPG::Cache.icon(@icon_commands[2])
      self.contents.blt(0, 64 + 4, bitmap, Rect.new(0, 0, 24, 24))      
      bitmap = RPG::Cache.icon(@icon_commands[3])
      self.contents.blt(0, 64 + 32 + 4, bitmap, Rect.new(0, 0, 24, 24))
      when 5
      bitmap = RPG::Cache.icon(@icon_commands[0])
      self.contents.blt(0, 4, bitmap, Rect.new(0, 0, 24, 24))      
      bitmap = RPG::Cache.icon(@icon_commands[1])
      self.contents.blt(0, 32 + 4, bitmap, Rect.new(0, 0, 24, 24))
      bitmap = RPG::Cache.icon(@icon_commands[2])
      self.contents.blt(0, 64 + 4, bitmap, Rect.new(0, 0, 24, 24))      
      bitmap = RPG::Cache.icon(@icon_commands[3])
      self.contents.blt(0, 64 + 32 + 4, bitmap, Rect.new(0, 0, 24, 24))      
      bitmap = RPG::Cache.icon(@icon_commands[4])
      self.contents.blt(0, 64 + 32 * 2 + 4, bitmap, Rect.new(0, 0, 24, 24))
      when 6
      bitmap = RPG::Cache.icon(@icon_commands[0])
      self.contents.blt(0, 4, bitmap, Rect.new(0, 0, 24, 24))      
      bitmap = RPG::Cache.icon(@icon_commands[1])
      self.contents.blt(0, 32 + 4, bitmap, Rect.new(0, 0, 24, 24))
      bitmap = RPG::Cache.icon(@icon_commands[2])
      self.contents.blt(0, 64 + 4, bitmap, Rect.new(0, 0, 24, 24))      
      bitmap = RPG::Cache.icon(@icon_commands[3])
      self.contents.blt(0, 64 + 32 + 4, bitmap, Rect.new(0, 0, 24, 24))      
      bitmap = RPG::Cache.icon(@icon_commands[4])
      self.contents.blt(0, 64 + 32 * 2 + 4, bitmap, Rect.new(0, 0, 24, 24))      
      bitmap = RPG::Cache.icon(@icon_commands[5])
      self.contents.blt(0, 64 + 32 * 3 + 4, bitmap, Rect.new(0, 0, 24, 24))
      end
    end
    for i in 0...@item_max
      if i == self.index
        self.contents.font.name = @name2
        self.contents.font.color = @color2
        self.contents.font.size = @size2
        color = @color2
        name = @name2
      else
        self.contents.font.size = @size1
        self.contents.font.name = @name1
        self.contents.font.color = @color1
        color = @color1
        name = @name1
      end
      if i == @disable_item1 or i == @disable_item2 or i == @disable_item3 or
        i == @disable_item4
        color = disabled_color
        name = @name3
      end
      draw_item(i, color, name)
    end
  end
  def draw_item(index, color, name)
    self.contents.font.color = color
    self.contents.font.name = name
    if @commands[18] != true
     if @column_max == 1
     rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)  
     else  
     rect = Rect.new(index * width / @column_max + 12,
     0, self.contents.width - 8, 32)
     end
     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
     self.contents.draw_text(rect, @command[index])
     else
     if @column_max == 1
     self.contents.draw_text(4 + 20, 32 * index,
     self.contents.width - 8, 32, @command[index])
     else
     self.contents.draw_text(index * width / @column_max + 12 + 10, 0,
     self.contents.width - 8, 32, @command[index])
     end
    end
  end
  def disable_item(index)
  end
  def update_cursor_rect
    refresh
    super
  end
end
[/pre]


好了~!
截图:
1.jpg
脚本:
[pre lang="ruby" line="1"]#==============================================================================
# ■ Window_Command
#------------------------------------------------------------------------------
#  一般的命令选择行窗口。
#==============================================================================

class Window_MenuCommand < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 初始化对像
  #     width    : 窗口的宽
  #     commands : 命令字符串序列
  #--------------------------------------------------------------------------
  def initialize(width, commands)
    # 由命令的个数计算出窗口的高
    ###################修改了计算高的方法
    super(0, 0, width, 2 * 32 + 32 + 32)
    #############################
    @item_max = commands.size
    @commands = commands
    ############这是列数可以自己改相应的改下方描绘项目
    @column_max = 2
    ########################
    self.contents = Bitmap.new(width - 32, @item_max * 32)
    refresh
    self.index = 0
  end
  #--------------------------------------------------------------------------
  # ● 刷新
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    for i in 0...@item_max
      draw_item(i, normal_color)
    end
  end
  #--------------------------------------------------------------------------
  # ● 描绘项目
  #     index : 项目编号
  #     color : 文字色
  #--------------------------------------------------------------------------
  def draw_item(index, color)
    self.contents.font.color = color
    ###########描绘项目修改
    #修改方法介绍:
=begin
x = 4 + index % 2 * (130 + 32)
y = index / 2 * 32
现在是有2列,如果需要有3列、4列……
修改这里:x = 4 + index % 3 * (130 + 32)
          y = index / 3 * 32
这样还是不会有效果,继续改括号中的130:
       比如:x = 4 + index % 3 * (50 + 32)
      把选项距离拉近
=end
   
    x = 4 + index % 2 * (130 + 32)
    y = index / 2 * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    self.contents.draw_text(rect, @commands[index])
  end
  #--------------------------------------------------------------------------
  # ● 项目无效化
  #     index : 项目编号
  #--------------------------------------------------------------------------
  def disable_item(index)
    draw_item(index, disabled_color)
  end
end
[/pre]

设置示例:
2.jpg
注意是:Window_MenuCommand.new


额,我自己帮助自己认可好了(关键是经验!!)有截图
QQ图片20130907154551.jpg
@弗雷德 @︶ㄣ牛排ぶ  

点评

谢谢热心解答  发表于 2013-9-7 15:22
是调用自定义图片吗?如果是RPG::Cache.picture就可以了,或者在场景中@a = Sprite.new;@a.bitmap = Bitmap.new(……)下方释放掉@a.bitmap.dispose;@a.dispose  发表于 2013-9-7 15:22
什么意思?描述清楚点啊  发表于 2013-9-7 15:18
哥根据你的脚本,改动自己图片式脚本完成修改谢谢  发表于 2013-9-7 15:16
有下局啊  发表于 2013-9-7 14:44

评分

参与人数 1星屑 +154 收起 理由
弗雷德 + 154 认可答案

查看全部评分

回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部