Project1

标题: 一个小脚本:美化战斗时候的角色选项窗口 [打印本页]

作者: 柳柳    时间: 2008-1-25 23:20
标题: 一个小脚本:美化战斗时候的角色选项窗口


直接替换原来的脚本就可以了,现在可以把你当前选中的选项前面加上一个图标。图标编号已经设置好了,基本不用改,如果真想改就从脚本中的:
@icon_list = [1, 52, 128, 144]
这行改吧。这几个是图标编号,看着那个图标素材,用十个手指+10个脚趾慢慢数出正确编号就行了……

脚本:
  1. #==============================================================================
  2. # ■ Window_ActorCommand
  3. #------------------------------------------------------------------------------
  4. #  战斗画面显示角色指令的窗口。
  5. #==============================================================================

  6. class Window_ActorCommand < Window_Selectable
  7.   #--------------------------------------------------------------------------
  8.   # ● 定义实例变量
  9.   #--------------------------------------------------------------------------  
  10.   attr_reader   :commands                 # 命令  
  11.   #--------------------------------------------------------------------------
  12.   # ● 初始化对象
  13.   #     width      : 窗口的宽
  14.   #     commands   : 命令字符串序列
  15.   #     column_max : 行数 (2 行以上时选择)
  16.   #     row_max    : 列数 (0:列数加起来)
  17.   #     spacing : 选项横向排列时间隔空白宽度
  18.   #--------------------------------------------------------------------------
  19.   def initialize(width = 128, commands = [], column_max = 1, row_max = 4, spacing = 32)
  20.     if row_max == 0
  21.       row_max = (commands.size + column_max - 1) / column_max
  22.     end
  23.     super(0, 0, width, row_max * WLH + 32, spacing)
  24.     self.active = false
  25.     @commands = []
  26.     @icon_list = [1, 52, 128, 144]
  27.     @item_max = commands.size
  28.     @column_max = column_max
  29.     @remember_index = -1
  30.     self.index = 0
  31.     # refresh
  32.     update
  33.   end
  34.   #--------------------------------------------------------------------------
  35.   # ● 刷新
  36.   #--------------------------------------------------------------------------
  37.   def refresh
  38.     self.contents.clear
  39.     for i in 0...@item_max
  40.       draw_item(i)
  41.     end
  42.   end
  43.   #--------------------------------------------------------------------------
  44.   # ● 设置自定义特技指令名称
  45.   #     actor :角色
  46.   #--------------------------------------------------------------------------
  47.   def setup(actor)
  48.     s1 = Vocab::attack
  49.     s2 = Vocab::skill
  50.     s3 = Vocab::guard
  51.     s4 = Vocab::item
  52.     if actor.class.skill_name_valid     # 特技指令名称有效?
  53.       s2 = actor.class.skill_name       # 替换指令名
  54.     end
  55.     @commands = [s1, s2, s3, s4]
  56.     @item_max = 4
  57.     refresh
  58.     self.index = 0
  59.   end  
  60.   
  61.   #--------------------------------------------------------------------------
  62.   # ● 描绘项目
  63.   #     index : 项目编号
  64.   #     enabled : 有效标记录。是false 的时候半透明绘画
  65.   #--------------------------------------------------------------------------
  66.   def draw_item(index, enabled = true)
  67.     rect = item_rect(index)
  68.     rect.x += 4
  69.     rect.width -= 8
  70.     self.contents.clear_rect(rect)
  71.     draw_icon(@icon_list[index], rect.x, rect.y, true) if index == self.index
  72.     self.contents.font.color = normal_color
  73.     self.contents.font.color.alpha = enabled ? 255 : 128
  74.     rect.x += 26
  75.     self.contents.draw_text(rect, @commands[index])
  76.   end
  77.   
  78.   #--------------------------------------------------------------------------
  79.   # ● 刷新类型
  80.   #--------------------------------------------------------------------------
  81.   def update
  82.     super
  83.     @remember_index = self.index if self.index == -1
  84.     if @remember_index != self.index
  85.       @remember_index = self.index
  86.       refresh
  87.     end
  88.   end
  89.   
  90. end
复制代码

作者: yangff    时间: 2008-1-25 23:21
{/se}{/se}
作者: 英俊de狗    时间: 2008-1-25 23:23
提示: 作者被禁止或删除 内容自动屏蔽
作者: superufo    时间: 2008-1-25 23:26
提示: 作者被禁止或删除 内容自动屏蔽
作者: 光郎    时间: 2008-1-26 00:41
强大…这次ICON整合后。
即使是柳柳也要用脚趾来数了…
作者: 柳柳    时间: 2008-1-26 00:58
果然,用脚趾数数错了……大家把数字自己改改吧。
作者: 雪雾明日晴    时间: 2008-1-26 00:59
实用的小功能。
其实我觉得还是那种用图片代替选框的更华丽{/cy}
作者: 匈魔剑    时间: 2008-1-26 01:19
柳大真是新奇的构思不断呢。
作者: 叮当    时间: 2008-1-26 02:24
{/fd}就直接用图片做选项就好啦,自由度还大一点…
作者: clamp135    时间: 2008-1-26 03:09
提示: 作者被禁止或删除 内容自动屏蔽
作者: 十翼    时间: 2008-1-26 04:08
柳大真是新奇的构思不断呢。


从某一方面来说.

有趣的构思是建立在实力之上的.
作者: 火鸡三毛老大    时间: 2008-2-20 20:58
直接替换原来的脚本就可以了,现在可以把你当前选中的选项前面加上一个图标。图标编号已经设置好了,基本不用改,如果真想改就从脚本中的:
@icon_list = [1, 52, 128, 144]
这行改吧。这几个是图标编号,看着那个图标素材,用十个手指+10个脚趾慢慢数出正确编号就行了……


直接用网络表格 {/hx}
作者: 御灵    时间: 2008-2-23 20:22
发布完毕。
http://rpg.blue/web/htm/news1001.htm
vip+2




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1