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

Project1

 找回密码
 注册会员
搜索

怎么用脚本修改菜单命令窗口的高度?

查看数: 2025 | 评论数: 4 | 收藏 0
关灯 | 提示:支持键盘翻页<-左 右->
    组图打开中,请稍候......
发布时间: 2014-8-1 09:04

正文摘要:

RT,脚本废快哭了_(:з」∠)_,,改个菜单折腾了一整天,别的都差不多了,就这个实在弄不出来。 默认脚本是用命令个数决定高度的,我想其他命令窗口不改,只把菜单画面的那个上下加长一点,指令居中 大概是这种感觉 ...

回复

克莉丝 发表于 2014-8-1 17:17:41
上下各开一个洞
  1.     @command_window.height = 350
  2.     @command_window.contents = Bitmap.new(@command_window.width-32,@command_window.height-32)
  3.     class<<@command_window
  4.       def draw_item(index, color)
  5.         self.contents.font.color = color
  6.         rect = Rect.new(4, 32 * index - @item_max*32 / 2 +  self.height/2-16, self.contents.width - 8, 32)
  7.         self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  8.         self.contents.draw_text(rect, @commands[index])
  9.       end
  10.       def update_cursor_rect
  11.         if @index < 0
  12.           self.cursor_rect.empty
  13.         return
  14.         end
  15.         row = @index / @column_max
  16.         if row < self.top_row
  17.           self.top_row = row
  18.         end
  19.         if row > self.top_row + (self.page_row_max - 1)
  20.           self.top_row = row - (self.page_row_max - 1)
  21.         end
  22.         cursor_width = self.width / @column_max - 32
  23.         x = @index % @column_max * (cursor_width + 32)
  24.         y = @index / @column_max * 32 - self.oy  - @item_max*32 / 2 +  self.height/2 - 16
  25.         self.cursor_rect.set(x, y, cursor_width, 32)
  26.       end
  27.     end
  28.     @command_window.refresh
  29.     @command_window.update_cursor_rect
复制代码

点评

谢谢!ok了!等级太低无法塞糖,总之大感谢!  发表于 2014-8-1 18:24

评分

参与人数 1梦石 +1 收起 理由
myownroc + 1 认可答案

查看全部评分

克莉丝 发表于 2014-8-1 14:05:21
Window_Command 本身不允许居中显示
  1.     @command_window.height = 250
  2.     class<<@command_window
  3.       def draw_item(index, color)
  4.         self.contents.font.color = color
  5.         rect = Rect.new(4, 32 * index - @item_max*32 / 2 +  self.height/2, self.contents.width - 8, 32)
  6.         self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  7.         self.contents.draw_text(rect, @commands[index])
  8.       end
  9.       def update_cursor_rect
  10.         if @index < 0
  11.           self.cursor_rect.empty
  12.         return
  13.         end
  14.         row = @index / @column_max
  15.         if row < self.top_row
  16.           self.top_row = row
  17.         end
  18.         if row > self.top_row + (self.page_row_max - 1)
  19.           self.top_row = row - (self.page_row_max - 1)
  20.         end
  21.         cursor_width = self.width / @column_max - 32
  22.         x = @index % @column_max * (cursor_width + 32)
  23.         y = @index / @column_max * 32 - self.oy  - @item_max*32 / 2 +  self.height/2
  24.         self.cursor_rect.set(x, y, cursor_width, 32)
  25.       end
  26.     end
  27.     @command_window.refresh
复制代码

点评

辛苦!不过最后一行的命令看不见了,而且在存档或退出界面返回菜单的会有一瞬间光标向上偏移,在新工程里也是一样,怎么破……  发表于 2014-8-1 17:07
冰水金刚 发表于 2014-8-1 09:14:21
建立一个新的窗口,def initialize(width, commands)
super( )
确定窗口大小坐标

然后调整项目坐标
最后调整光标坐标

点评

谢谢!不过这对我来说太进阶了OTL,,,求把葫芦再画详细点,我看我能不能描个瓢  发表于 2014-8-1 13:44
克莉丝 发表于 2014-8-1 09:13:54


点评

谢谢!!没想到这么快就有回帖……窗口布局解决了,不过还是不知道怎么把内容居中诶……试了半天还是有BUG,继续求教_(:з」∠)_  发表于 2014-8-1 13:41
拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

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

GMT+8, 2024-10-1 04:20

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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