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

Project1

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

[已经解决] Window_Selectable定制

[复制链接]

Lv1.梦旅人

梦石
0
星屑
72
在线时间
320 小时
注册时间
2011-8-30
帖子
141
跳转到指定楼层
1
发表于 2013-9-7 13:33:39 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式

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

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

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

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

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


  




我想专门为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
天之痕同人游戏填坑中
游戏名称: 天之痕前传
游戏进度: 百分之二十  
游戏素材: 素材制作中。。。
游戏脚本: 百分之九十九
游戏剧本: 百分之五

Lv1.梦旅人

薄凉看客

梦石
0
星屑
50
在线时间
1269 小时
注册时间
2010-6-20
帖子
1316
2
发表于 2013-9-7 13:34:35 | 只看该作者
本帖最后由 恋′挂机 于 2013-9-7 15:48 编辑

那个是列数,改过之后表示,现有列数为2当然那个样子了
直接这样就可以了。。
RUBY 代码复制
  1. #==============================================================================
  2. # ■ Window_Command    超级命令窗体的类。
  3. #------------------------------------------------------------------------------
  4. #   脚本作者:薄凉看客,转载或使用请保留此信息。
  5. #==============================================================================
  6. =begin
  7.  
  8. 在生成Command.new时后边可以有第三个参数——一个数组(另附加一个图标文件名数组)
  9.  
  10. 数组详细说明(数组参数是非必须的,可有可无):
  11. [0:列数, 1:X坐标, 2:Y坐标, 3:Z坐标, 4:未选中字体大小, 5:选中字体大小,
  12. 6:未选中字体时的颜色, 7:选中字体时的颜色, 8:未选中时的字体名, 9:选中时的字体名,
  13. 10:项目无效化时的字体名, 11:项目无效化1, 12:项目无效化2, 13:项目无效化3,
  14. 14:项目无效化4, 15:窗口的不透明度, 16:背景的不透明度, 17:内容的不透明度,
  15. 18:是否显示图标]
  16. 注:如果需要显示图标,需要再加一个数组参数(非必须)来指定图标文件名(
  17. 当然也可以使用默认图标,数组内指定的图标会按012345的顺序依次显示,而
  18. 且不管你有几个选项,你都必须指定6个图标名,否则按默认处理)。
  19.  
  20. 举个例子:
  21.  
  22. #---------把Scene_Menu的26行脚本替换为以下内容,就能看到效果---------
  23.  
  24. array_menu = []
  25. array_menu[0] = 6#让选择项横着选
  26. array_menu[1] = 0#修改命令窗体的X坐标
  27. array_menu[2] = 100#修改命令窗体的Y坐标为100
  28. array_menu[4] = 15#修改命令窗体未选中时的字体大小为15
  29. array_menu[5] = 22#修改命令窗体选中时的字体大小为22
  30. array_menu[3] = 500#修改Z坐标,保证命令窗体显示在最上方
  31. array_menu[11] = 5#让5号选择项(即结束)无效化
  32. array_menu[15] = 150#修改窗体的不透明度
  33. array_menu[16] = 150#修改背景的不透明度
  34. array_menu[17] = 150#修改内容的不透明度
  35. array_menu[18] = true#给命令窗体显示上图标
  36. icon_commands = ["041-Item10.png", "050-Skill07.png",
  37. "019-Accessory04.png", "045-Skill02.png", "036-Item05.png",
  38. "046-Skill03.png"]#这是指定图标文件名
  39. mmand_window = Window_Command.new(640, [s1, s2, s3, s4, s5, s6],
  40. array_menu, icon_commands)
  41.  
  42. #---------把Scene_Menu的26行脚本替换为以上内容,就能看到效果---------
  43.  
  44. =end
  45. class Window_Command < Window_Selectable
  46.   def initialize(width, command, commands = [], icon_commands = 0)
  47.     if icon_commands = 0 or icon_commands.class != Array
  48.       icon_commands = ["041-Item10.png", "050-Skill07.png",
  49.       "019-Accessory04.png", "045-Skill02.png", "036-Item05.png",
  50.       "046-Skill03.png"]
  51.     elsif icon_commands.class == Array and (icon_commands[0] == nil or
  52.       icon_commands[1] == nil or icon_commands[2] == nil or
  53.       icon_commands[3] == nil or icon_commands[4] == nil or
  54.       icon_commands[5] == nil)
  55.       icon_commands = ["041-Item10.png", "050-Skill07.png",
  56.       "019-Accessory04.png", "045-Skill02.png", "036-Item05.png",
  57.       "046-Skill03.png"]
  58.     end  
  59.     if commands.class != Array
  60.       commands = []
  61.     end  
  62.     if commands[0] == 1 or commands[0] == nil
  63.       if commands[1] == nil and commands[2] != nil
  64.       super(0, commands[2], width, command.size * 32 + 32)
  65.       elsif commands[1] != nil and commands[2] == nil
  66.       super(commands[1], 0, width, command.size * 32 + 32)
  67.       elsif commands[1] == nil and commands[2] == nil
  68.       super(0, 0, width, command.size * 32 + 32)
  69.       elsif commands[1] != nil and commands[2] != nil
  70.       super(commands[1], commands[2], width, command.size * 32 + 32)      
  71.       end
  72.     else
  73.       if commands[1] == nil and commands[2] != nil
  74.       super(0, commands[2], width, 64)
  75.       elsif commands[1] != nil and commands[2] == nil
  76.       super(commands[1], 0, width, 64)
  77.       elsif commands[1] == nil and commands[2] == nil
  78.       super(0, 0, width, 64)
  79.       elsif commands[1] != nil and commands[2] != nil
  80.       super(commands[1], commands[2], width, 64)
  81.       end
  82.     end
  83.     if commands[3] != nil
  84.     self.z = commands[3]
  85.     else
  86.     self.z = 100
  87.     end
  88.     @command = command
  89.     @item_max = @command.size
  90.     if commands[0] != nil
  91.     @column_max = commands[0]
  92.     else
  93.     @column_max = 1
  94.     end
  95.     if commands[4] != nil
  96.     @size1 = commands[4]
  97.     else
  98.     @size1 = 22
  99.     end
  100.     if commands[5] != nil
  101.     @size2 = commands[5]
  102.     else
  103.     @size2 = 22
  104.     end
  105.     if commands[6] != nil
  106.     @color1 = commands[6]
  107.     else
  108.     @color1 = normal_color
  109.     end
  110.     if commands[7] != nil
  111.     @color2 = commands[7]
  112.     else
  113.     @color2 = normal_color
  114.     end
  115.     if commands[8] != nil
  116.     @name1 = commands[8]
  117.     else
  118.     @name1 = "黑体"
  119.     end
  120.     if commands[9] != nil
  121.     @name2 = commands[9]
  122.     else
  123.     @name2 = "黑体"
  124.     end
  125.     if commands[10] != nil
  126.     @name3 = commands[10]
  127.     else
  128.     @name3 = "黑体"
  129.     end
  130.     if commands[11] != nil
  131.     @disable_item1 = commands[11]
  132.     else
  133.     @disable_item1 = -1
  134.     end
  135.     if commands[12] != nil
  136.     @disable_item2 = commands[12]
  137.     else
  138.     @disable_item2 = -1
  139.     end
  140.     if commands[13] != nil
  141.     @disable_item3 = commands[13]
  142.     else
  143.     @disable_item3 = -1
  144.     end
  145.     if commands[14] != nil
  146.     @disable_item4 = commands[14]
  147.     else
  148.     @disable_item4 = -1
  149.     end
  150.     self.contents = Bitmap.new(width - 32, @item_max * 32)
  151.     if commands[15] != nil and commands[15] >= 0 and commands[15] <= 255
  152.       self.opacity = commands[15]
  153.     else
  154.       self.opacity = 255
  155.     end  
  156.     if commands[16] != nil and commands[16] >= 0 and commands[16] <= 255
  157.       self.back_opacity = commands[16]
  158.     else
  159.       self.back_opacity = 255
  160.     end
  161.     if commands[17] != nil and commands[17] >= 0 and commands[17] <= 255
  162.       self.contents_opacity = commands[17]
  163.     else
  164.       self.contents_opacity = 255
  165.     end
  166.     @icon_commands = icon_commands
  167.     @commands = commands
  168.     if @column_max != 1 and @commands[18] == true
  169.     @x1 = 0 % @column_max * ((width - 32) / @column_max)
  170.     @x2 = 1 % @column_max * ((width - 32) / @column_max + 5)
  171.     @x3 = 2 % @column_max * ((width - 32) / @column_max + 5)
  172.     @x4 = 3 % @column_max * ((width - 32) / @column_max + 5)
  173.     @x5 = 4 % @column_max * ((width - 32) / @column_max + 5)
  174.     @x6 = 5 % @column_max * ((width - 32) / @column_max + 5)
  175.     end
  176.     refresh
  177.     self.index = 0
  178.   end
  179.   def refresh
  180.     self.contents.clear
  181.     if @column_max != 1 and @commands[18] == true
  182.       case @item_max
  183.       when 1
  184.       bitmap = RPG::Cache.icon(@icon_commands[0])
  185.       self.contents.blt(@x1, 4, bitmap, Rect.new(0, 0, 24, 24))
  186.       when 2
  187.       bitmap = RPG::Cache.icon(@icon_commands[0])
  188.       self.contents.blt(@x1, 4, bitmap, Rect.new(0, 0, 24, 24))
  189.       bitmap = RPG::Cache.icon(@icon_commands[1])
  190.       self.contents.blt(@x2, 4, bitmap, Rect.new(0, 0, 24, 24))
  191.       when 3
  192.       bitmap = RPG::Cache.icon(@icon_commands[0])
  193.       self.contents.blt(@x1, 4, bitmap, Rect.new(0, 0, 24, 24))
  194.       bitmap = RPG::Cache.icon(@icon_commands[1])
  195.       self.contents.blt(@x2, 4, bitmap, Rect.new(0, 0, 24, 24))
  196.       bitmap = RPG::Cache.icon(@icon_commands[2])
  197.       self.contents.blt(@x3, 4, bitmap, Rect.new(0, 0, 24, 24))
  198.       when 4
  199.       bitmap = RPG::Cache.icon(@icon_commands[0])
  200.       self.contents.blt(@x1, 4, bitmap, Rect.new(0, 0, 24, 24))
  201.       bitmap = RPG::Cache.icon(@icon_commands[1])
  202.       self.contents.blt(@x2, 4, bitmap, Rect.new(0, 0, 24, 24))
  203.       bitmap = RPG::Cache.icon(@icon_commands[2])
  204.       self.contents.blt(@x3, 4, bitmap, Rect.new(0, 0, 24, 24))
  205.       bitmap = RPG::Cache.icon(@icon_commands[3])
  206.       self.contents.blt(@x4, 4, bitmap, Rect.new(0, 0, 24, 24))
  207.       when 5
  208.       bitmap = RPG::Cache.icon(@icon_commands[0])
  209.       self.contents.blt(@x1, 4, bitmap, Rect.new(0, 0, 24, 24))
  210.       bitmap = RPG::Cache.icon(@icon_commands[1])
  211.       self.contents.blt(@x2, 4, bitmap, Rect.new(0, 0, 24, 24))
  212.       bitmap = RPG::Cache.icon(@icon_commands[2])
  213.       self.contents.blt(@x3, 4, bitmap, Rect.new(0, 0, 24, 24))
  214.       bitmap = RPG::Cache.icon(@icon_commands[3])
  215.       self.contents.blt(@x4, 4, bitmap, Rect.new(0, 0, 24, 24))
  216.       bitmap = RPG::Cache.icon(@icon_commands[4])
  217.       self.contents.blt(@x5, 4, bitmap, Rect.new(0, 0, 24, 24))
  218.       when 6
  219.       bitmap = RPG::Cache.icon(@icon_commands[0])
  220.       self.contents.blt(@x1, 4, bitmap, Rect.new(0, 0, 24, 24))
  221.       bitmap = RPG::Cache.icon(@icon_commands[1])
  222.       self.contents.blt(@x2, 4, bitmap, Rect.new(0, 0, 24, 24))
  223.       bitmap = RPG::Cache.icon(@icon_commands[2])
  224.       self.contents.blt(@x3, 4, bitmap, Rect.new(0, 0, 24, 24))
  225.       bitmap = RPG::Cache.icon(@icon_commands[3])
  226.       self.contents.blt(@x4, 4, bitmap, Rect.new(0, 0, 24, 24))
  227.       bitmap = RPG::Cache.icon(@icon_commands[4])
  228.       self.contents.blt(@x5, 4, bitmap, Rect.new(0, 0, 24, 24))   
  229.       bitmap = RPG::Cache.icon(@icon_commands[5])
  230.       self.contents.blt(@x6, 4, bitmap, Rect.new(0, 0, 24, 24))
  231.       end
  232.     elsif @column_max == 1 and @commands[18] == true
  233.       case @item_max
  234.       when 1
  235.       bitmap = RPG::Cache.icon(@icon_commands[0])
  236.       self.contents.blt(0, 4, bitmap, Rect.new(0, 0, 24, 24))
  237.       when 2
  238.       bitmap = RPG::Cache.icon(@icon_commands[0])
  239.       self.contents.blt(0, 4, bitmap, Rect.new(0, 0, 24, 24))      
  240.       bitmap = RPG::Cache.icon(@icon_commands[1])
  241.       self.contents.blt(0, 32 + 4, bitmap, Rect.new(0, 0, 24, 24))
  242.       when 3
  243.       bitmap = RPG::Cache.icon(@icon_commands[0])
  244.       self.contents.blt(0, 4, bitmap, Rect.new(0, 0, 24, 24))      
  245.       bitmap = RPG::Cache.icon(@icon_commands[1])
  246.       self.contents.blt(0, 32 + 4, bitmap, Rect.new(0, 0, 24, 24))
  247.       bitmap = RPG::Cache.icon(@icon_commands[2])
  248.       self.contents.blt(0, 64 + 4, bitmap, Rect.new(0, 0, 24, 24))
  249.       when 4
  250.       bitmap = RPG::Cache.icon(@icon_commands[0])
  251.       self.contents.blt(0, 4, bitmap, Rect.new(0, 0, 24, 24))      
  252.       bitmap = RPG::Cache.icon(@icon_commands[1])
  253.       self.contents.blt(0, 32 + 4, bitmap, Rect.new(0, 0, 24, 24))
  254.       bitmap = RPG::Cache.icon(@icon_commands[2])
  255.       self.contents.blt(0, 64 + 4, bitmap, Rect.new(0, 0, 24, 24))      
  256.       bitmap = RPG::Cache.icon(@icon_commands[3])
  257.       self.contents.blt(0, 64 + 32 + 4, bitmap, Rect.new(0, 0, 24, 24))
  258.       when 5
  259.       bitmap = RPG::Cache.icon(@icon_commands[0])
  260.       self.contents.blt(0, 4, bitmap, Rect.new(0, 0, 24, 24))      
  261.       bitmap = RPG::Cache.icon(@icon_commands[1])
  262.       self.contents.blt(0, 32 + 4, bitmap, Rect.new(0, 0, 24, 24))
  263.       bitmap = RPG::Cache.icon(@icon_commands[2])
  264.       self.contents.blt(0, 64 + 4, bitmap, Rect.new(0, 0, 24, 24))      
  265.       bitmap = RPG::Cache.icon(@icon_commands[3])
  266.       self.contents.blt(0, 64 + 32 + 4, bitmap, Rect.new(0, 0, 24, 24))      
  267.       bitmap = RPG::Cache.icon(@icon_commands[4])
  268.       self.contents.blt(0, 64 + 32 * 2 + 4, bitmap, Rect.new(0, 0, 24, 24))
  269.       when 6
  270.       bitmap = RPG::Cache.icon(@icon_commands[0])
  271.       self.contents.blt(0, 4, bitmap, Rect.new(0, 0, 24, 24))      
  272.       bitmap = RPG::Cache.icon(@icon_commands[1])
  273.       self.contents.blt(0, 32 + 4, bitmap, Rect.new(0, 0, 24, 24))
  274.       bitmap = RPG::Cache.icon(@icon_commands[2])
  275.       self.contents.blt(0, 64 + 4, bitmap, Rect.new(0, 0, 24, 24))      
  276.       bitmap = RPG::Cache.icon(@icon_commands[3])
  277.       self.contents.blt(0, 64 + 32 + 4, bitmap, Rect.new(0, 0, 24, 24))      
  278.       bitmap = RPG::Cache.icon(@icon_commands[4])
  279.       self.contents.blt(0, 64 + 32 * 2 + 4, bitmap, Rect.new(0, 0, 24, 24))      
  280.       bitmap = RPG::Cache.icon(@icon_commands[5])
  281.       self.contents.blt(0, 64 + 32 * 3 + 4, bitmap, Rect.new(0, 0, 24, 24))
  282.       end
  283.     end
  284.     for i in 0...@item_max
  285.       if i == self.index
  286.         self.contents.font.name = @name2
  287.         self.contents.font.color = @color2
  288.         self.contents.font.size = @size2
  289.         color = @color2
  290.         name = @name2
  291.       else
  292.         self.contents.font.size = @size1
  293.         self.contents.font.name = @name1
  294.         self.contents.font.color = @color1
  295.         color = @color1
  296.         name = @name1
  297.       end
  298.       if i == @disable_item1 or i == @disable_item2 or i == @disable_item3 or
  299.         i == @disable_item4
  300.         color = disabled_color
  301.         name = @name3
  302.       end
  303.       draw_item(i, color, name)
  304.     end
  305.   end
  306.   def draw_item(index, color, name)
  307.     self.contents.font.color = color
  308.     self.contents.font.name = name
  309.     if @commands[18] != true
  310.      if @column_max == 1
  311.      rect = Rect.new(4, 32 * index, self.contents.width - 8, 32)  
  312.      else  
  313.      rect = Rect.new(index * width / @column_max + 12,
  314.      0, self.contents.width - 8, 32)
  315.      end
  316.      self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  317.      self.contents.draw_text(rect, @command[index])
  318.      else
  319.      if @column_max == 1
  320.      self.contents.draw_text(4 + 20, 32 * index,
  321.      self.contents.width - 8, 32, @command[index])
  322.      else
  323.      self.contents.draw_text(index * width / @column_max + 12 + 10, 0,
  324.      self.contents.width - 8, 32, @command[index])
  325.      end
  326.     end
  327.   end
  328.   def disable_item(index)
  329.   end
  330.   def update_cursor_rect
  331.     refresh
  332.     super
  333.   end
  334. end



好了~!
截图:

脚本:
RUBY 代码复制
  1. #==============================================================================
  2. # ■ Window_Command
  3. #------------------------------------------------------------------------------
  4. #  一般的命令选择行窗口。
  5. #==============================================================================
  6.  
  7. class Window_MenuCommand < Window_Selectable
  8.   #--------------------------------------------------------------------------
  9.   # ● 初始化对像
  10.   #     width    : 窗口的宽
  11.   #     commands : 命令字符串序列
  12.   #--------------------------------------------------------------------------
  13.   def initialize(width, commands)
  14.     # 由命令的个数计算出窗口的高
  15.     ###################修改了计算高的方法
  16.     super(0, 0, width, 2 * 32 + 32 + 32)
  17.     #############################
  18.     @item_max = commands.size
  19.     @commands = commands
  20.     ############这是列数可以自己改相应的改下方描绘项目
  21.     @column_max = 2
  22.     ########################
  23.     self.contents = Bitmap.new(width - 32, @item_max * 32)
  24.     refresh
  25.     self.index = 0
  26.   end
  27.   #--------------------------------------------------------------------------
  28.   # ● 刷新
  29.   #--------------------------------------------------------------------------
  30.   def refresh
  31.     self.contents.clear
  32.     for i in 0...@item_max
  33.       draw_item(i, normal_color)
  34.     end
  35.   end
  36.   #--------------------------------------------------------------------------
  37.   # ● 描绘项目
  38.   #     index : 项目编号
  39.   #     color : 文字色
  40.   #--------------------------------------------------------------------------
  41.   def draw_item(index, color)
  42.     self.contents.font.color = color
  43.     ###########描绘项目修改
  44.     #修改方法介绍:
  45. =begin
  46. x = 4 + index % 2 * (130 + 32)
  47. y = index / 2 * 32
  48. 现在是有2列,如果需要有3列、4列……
  49. 修改这里:x = 4 + index % 3 * (130 + 32)
  50.           y = index / 3 * 32
  51. 这样还是不会有效果,继续改括号中的130:
  52.        比如:x = 4 + index % 3 * (50 + 32)
  53.       把选项距离拉近
  54. =end
  55.  
  56.     x = 4 + index % 2 * (130 + 32)
  57.     y = index / 2 * 32
  58.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  59.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  60.     self.contents.draw_text(rect, @commands[index])
  61.   end
  62.   #--------------------------------------------------------------------------
  63.   # ● 项目无效化
  64.   #     index : 项目编号
  65.   #--------------------------------------------------------------------------
  66.   def disable_item(index)
  67.     draw_item(index, disabled_color)
  68.   end
  69. end


设置示例:

注意是:Window_MenuCommand.new


额,我自己帮助自己认可好了(关键是经验!!)有截图

@弗雷德 @︶ㄣ牛排ぶ  

点评

谢谢热心解答  发表于 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 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-9-29 23:38

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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