查看: 10236|回复: 33

[原创发布] 窗口增强系统核心 v1.7 完整更新及范例

[复制链接]

遠航の猫咪

梦石
3
星屑
27057
在线时间
2428 小时
注册时间
2005-10-15
回帖
989

开拓者

发表于 2017-12-3 02:38:18 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 SailCat 于 2018-9-7 01:12 编辑

嗯,不仅是移植VA的Window_Base及一些相关内容——
然后加了点私货,然后和XP的默认设定做了一些一致性调整
毕竟是用RGSS1的后台Window类去死命的黑,有些实现方法确实挺绕的
本来想把RGSS3的padding也做上的,结果发现XP写死了16……要做的话只能双窗口,一真的透明背景显示内容,一假的显示背景……太累了,而且Z值没法弄。
为了解放写死的文本行高32,不得不重写了游戏里的所!有!窗口,我也是醉了。于是顺便按VA的继承风格把某些窗口整个重做了。
具体功能呢——见分割定义1的注释部分吧,反正VA VX的皮肤是能直接用了,不会出问题。最好你留一个默认的001-Blue01不然战斗光标就没了
以下是直接使用VA默认皮肤的结果:
1.png
以下用了一个论坛内的VX皮肤,并把行高调整为24
捕获1.PNG

查看代码

  1. #==============================================================================
  2. # ■ 窗口增强系统核心 v1.7 by SailCat
  3. #------------------------------------------------------------------------------
  4. #   方法:本脚本插入到Main之前使用,且需在所有依赖此脚本的其他插件之前
  5. #   依赖:SEP 插件公共核心
  6. #   版本:v1.7 (Build 180907)
  7. #   效果:
  8. #    1. VX、VA格式的皮肤全兼容,直接调用不转换,并对XP的战斗光标做了兼容性处理
  9. #    2. 支持RGSS2的窗口式样,包括边框、底色、平铺+拉伸双背景、色调调整
  10. #    3. 支持RGSS3的窗口开闭效果
  11. #    4. 保留RGSS1的主背景平铺设定,即允许双平铺背景
  12. #    5. 支持窗口快速按屏幕定位的脚本接口,含靠边、移动、缩放功能
  13. #    6. 生成窗口时可以直接指定皮肤文件名,且不受Game_System设定影响
  14. #    7. 无须更改窗口皮肤,可以单独关闭平铺层的背景
  15. #    8. 文字颜色有VX/VA/MV系的32种,而不是XP系的8种,默认颜色与XP保持一致
  16. #    9. 文字行高可调整
  17. #    10.VA风格的血条
  18. #    11.增加了Window_Handler模块,用于处理交互类窗口的消息钩子和按键钩子
  19. #    12.增加了Window_HorzCommand类,用于处理水平排列的命令窗口
  20. #    13.增加了Window_Data类,用于处理游戏数据(物品、特技、武器、防具)列表
  21. #    14.增加了Window_Numeric类,用于处理数值输入的窗口
  22. #    15.追加了大量可以在所有窗口(不仅是对话窗口)中使用的文本控制符
  23. #   配置:有大量配置项,见脚本配置区的具体说明,所有默认设定均为RGSS1的默认值
  24. #   冲突:其他窗口增强脚本和使用默认窗口的自定义界面脚本
  25. #   说明:
  26. #    1. 在不改变配置项的情况下,仅插入本插件并不会对窗口产生任何特殊效果
  27. #    2. 以下窗口的继承关系被调整:
  28. #       Window_Item         从继承Window_Selectable调整为继承Window_Data
  29. #       Window_Skill        从继承Window_Selectable调整为继承Window_Data
  30. #       Window_EquipRight   从继承Window_Selectable调整为继承Window_Data
  31. #       Window_EquipItem    从继承Window_Selectable调整为继承Window_Data
  32. #       Window_ShopCommand  从继承Window_Selectable调整为继承Window_HorzCommand
  33. #       Window_ShopBuy      从继承Window_Selectable调整为继承Window_Data
  34. #       Window_ShopSell     从继承Window_Selectable调整为继承Window_Data
  35. #       Window_ShopNumber   从继承Window_Base      调整为继承Window_Numeric
  36. #       Window_InputNumber  从继承Window_Base      调整为继承Window_Numeric
  37. #       Window_PartyCommand 从继承Window_Selectable调整为继承Window_HorzCommand
  38. #    2. 调整窗口的色调:
  39. #       初始设定:在下面的配置区设定,默认为不改变色调
  40. #       全局调整:使用$game_system.window_tone = Tone.new(r, g, b, gray)
  41. #       个别调整:使用window.tone = Tone.new(r, g, b, gray)
  42. #                 或者window.tone.set(r, g, b, gray)
  43. #    3. 窗口的开闭效果:
  44. #       window.openness = x (x为0-255) 设置打开度,0为完全关,255为完全开
  45. #       window.open或window.close,在相应的Scene的main里调用
  46. #    4. 窗口的位置效果:
  47. #       移动:window.moveto(x, y)           将窗口移动到指定的坐标处
  48. #       缩放:window.resize(width, height)  将窗口的大小更改为指定值
  49. #       对齐:window.align(dir, rect)       将窗口在矩形内按方位对齐
  50. #       靠边:window.dock(other, dir, align)将窗口靠在另一个窗口边上,并对齐
  51. #    5. 交互类窗口的按键和事件挂接:
  52. #       按键:window.set_handler(按键名, method(方法名)),按键为Input系的常量名
  53. #       事件:window.set_handler(事件符号, method(方法名)),事件符号有以下:
  54. #             :index_changed : 选择项改变(仅启用时触发)
  55. #             :visible_changed : 显示/隐藏状态改变(全时触发)
  56. #             :activated : 窗口被启用
  57. #             :deactivated : 窗口被禁用
  58. #             也可自行定义你需要的事件符号
  59. #       取消:window.reset_handler(按键名或事件符号)
  60. #       触发:window.call_handler(自定义事件符号,[方法参数]),按键是自动触发的
  61. #    6. 本插件追加了以下原RGSS1默认对话框没有的控制符:
  62. #       \P[n]   显示队伍中排名第n的角色的名字
  63. #       \E[n]   显示第n号敌人的名字
  64. #       \T[n]   显示敌队中排名第n的敌人的名字
  65. #       \$      显示货币单位
  66. #       \D[?n]  显示第n号游戏数据的名字,当?为:
  67. #          S    特技(带有图标)
  68. #          I    物品(带有图标)
  69. #          W    武器(带有图标)
  70. #          A    防具(带有图标)
  71. #          C    职业
  72. #          B    状态
  73. #          T    图块
  74. #          M    地图
  75. #          E    属性
  76. #          V    事件(本地图内)
  77. #       \I[str] 显示文件名为str的图标
  78. #       \/      人工换行
  79. #       \|      制表位(推进到8字符的倍数)
  80. #       \{      将字体改大6号
  81. #       \}      将字体改小6号
  82. #       \*      开始或者结束文字粗体
  83. #       \_      开始或者结束文字斜体
  84. #       \~      清除格式
  85. #       \:      行首缩进(下一行从此处开始)
  86. #       \`      取消缩进(下一行从头开始)
  87. #       \J[n]   跳至n像素位置
  88. #       \O[n]   将文字不透明度更改为n
  89. #    6. 本插件增强了对话框\v控制符的功能,如下:
  90. #       \V[n]   变换为n号变量的值(原功能),可以嵌套使用
  91. #       \V[Nn.sym] 变换为第n号角色的指定属性值,.sym可为.hp .str之类,下同
  92. #       \V[Pn.sym] 变换为队伍中排名第n的角色的指定属性值
  93. #       \V[En.sym] 变换为第n号敌人的指定属性值
  94. #       \V[Tn.sym] 变换为敌队中排名第n的敌人的指定属性值
  95. #    7. 本插件增强了对话框\c控制符的功能,如下:
  96. #       \C[n]   变换为n号颜色,其中n的取值是0-63
  97. #       \C[#rrggbb] 直接以HTML写法指定颜色,也可写成#rrggbbaa(带透明度)
  98. #       \C[name] 直接以颜色名指定颜色,支持144种颜色名,见下方Color类的常量表
  99. #    8. 所有控制符,大小写不敏感。
  100. #    9. 上述控制符,也可以写在物品、特技、武器、防具的说明中,同样有效。
  101. #==============================================================================
  102. #==============================================================================
  103. # ■ SailCat's 插件公用
  104. #==============================================================================
  105. module SailCat
  106.   $sailcat_import ||= {}
  107.   #--------------------------------------------------------------------------
  108.   # ● 脚本配置区
  109.   #--------------------------------------------------------------------------
  110.   module Window_Config
  111.     STRETCH = true                        # 主背景拉伸(true)/平铺(false)
  112.     TILE_EFFECT = false                   # 开启平铺背景效果
  113.     OPEN_HORZ = false                     # 打开方向,false垂直,true水平
  114.     CLOSE_HORZ = false                    # 关闭方向,false垂直,true水平
  115.     FONT_SIZE_STEP = 6                    # 字体变化步长
  116.     FONT_SIZE_MAX = 64                    # 字体大小上限
  117.     FONT_SIZE_MIN = 10                    # 字体大小下限
  118.     DEFAULT_TONE = Tone.new(0, 0, 0, 0)   # 默认窗口色调
  119.     DISABLED_ALPHA = 128                  # 无效项的透明度
  120.     ICON_WIDTH = 24                       # 图标的宽
  121.     ICON_HEIGHT = 24                      # 图标的高
  122.     ICON_PADDING = 4                      # 图标与正文的间距
  123.     LINE_HEIGHT = 32                      # 文字行高
  124.     ARROW_FOR_VX = "001-Blue01"           # 使用 VX 皮肤时的指定光标皮肤
  125.     CURSOR_PADDING = 32                   # 多列选择窗口光标的间隔
  126.     CURSOR_PADDING_HORZCOMMAND = 32       # 水平命令窗口光标的间隔
  127.     TARGET_SELF_OFFSET_DEFAULT = 10       # 目标窗口选中自己的偏移值,一般不改
  128.     SHOW_GAUGE = false                    # 是否描绘数值槽
  129.     SHOW_SHOP_HINT = false                # 是否显示商店帮助信息
  130.     NUM_KI = Input::SHIFT                 # 数值窗口中千位变化的修饰键
  131.     NUM_MI = Input::CTRL                  # 数值窗口中百万位变化的修饰键
  132.     NUM_BI = Input::ALT                   # 数值窗口中十亿位变化的修饰键
  133.     BACK_OPACITY_DEFAULT = 255            # 总括设置的窗口背景不透明度
  134.     BACK_OPACITY_IN_BATTLE = 160          # 战斗中的窗口背景不透明度
  135.     PALETTE_XP = [                        # 使用 XP 皮肤时的默认调色板
  136.       "#FFFFFF", "#8080FF", "#FF8080", "#80FF80",
  137.       "#80FFFF", "#FF80FF", "#FFFF80", "#C0C0C0", # 基本颜色 0-7
  138.       "#808080", "#2080CC", "#FF3810", "#00A010",
  139.       "#3E9ADE", "#A098FF", "#FFCC20", "#000000", # 扩展颜色 8-15
  140.       "#C0E0FF", "#FFFF40", "#FF4000", "#202040",
  141.       "#E08040", "#E0C040", "#4080C0", "#40C0E0", # 系统颜色 16-23
  142.       "#66CC40", "#C08080", "#20A0D6", "#CCC0FF",
  143.       "#00A040", "#00E060", "#A060E0", "#C080FF"  # 系统颜色 24-31
  144.     ]
  145.     VOCAB_NUM_HINTS = [                   # 数值输入窗口的提示文字
  146.       "←→:±1 ", "↑↓:±10 ", "L/R:±100\n",
  147.       "%s+:x1000倍 ", "", "\n",
  148.       "%s+:x100万倍 ", "", "\n",
  149.       "%s+:x10亿倍", "X:最小", "Z:清零", "Y:最大"
  150.     ]
  151.   end
  152.   #--------------------------------------------------------------------------
  153.   # ● 植入与依赖检查
  154.   #--------------------------------------------------------------------------
  155.   dependency = []
  156.   unless $sailcat_import[:CoreEngine].to_f >= 1.2
  157.     dependency.push "[CoreEngine] SEP 插件公共核心(v1.2以上版本)"
  158.   end
  159.   raise "缺少依赖插件:\n" + dependency.join("\n") unless dependency.empty?
  160.   $sailcat_import[:WindowCore] = 1.5
  161. end

  162. #==============================================================================
  163. # ■ Vocab
  164. #==============================================================================
  165. module Vocab
  166.   include SailCat::Window_Config
  167.   def self.help_text
  168.     @help_text ||= {}
  169.   end
  170. end

  171. #==============================================================================
  172. # ■ Input
  173. #==============================================================================
  174. module Input
  175.   #--------------------------------------------------------------------------
  176.   # ● 获得键名
  177.   #--------------------------------------------------------------------------
  178.   def self.key_name(key)
  179.     constants.each do |name|
  180.       return name if const_get(name) == key
  181.     end
  182.   end
  183. end

  184. #==============================================================================
  185. # ■ String
  186. #==============================================================================
  187. class String
  188.   #--------------------------------------------------------------------------
  189.   # ● 是否含控制符
  190.   #--------------------------------------------------------------------------
  191.   def escaped?;           not self["\"].nil?;                            end
  192. end

  193. #==============================================================================
  194. # ■ Color
  195. #==============================================================================
  196. class Color
  197.   #--------------------------------------------------------------------------
  198.   # ● 颜色常量
  199.   #--------------------------------------------------------------------------
  200.   ALICEBLUE = Color.html("#F0F8FF")
  201.   ANTIQUEWHITE = Color.html("#FAEBD7")
  202.   AQUA = Color.html("#00FFFF")
  203.   AQUAMARINE = Color.html("#7FFFD4")
  204.   AZURE = Color.html("#F0FFFF")
  205.   BEIGE = Color.html("#F5F5DC")
  206.   BISQUE = Color.html("#FFE4C4")
  207.   BLACK = Color.html("#000000")
  208.   BLANCHEDALMOND = Color.html("#FFEBCD")
  209.   BLUE = Color.html("#0000FF")
  210.   BLUEVIOLET = Color.html("#8A2BE2")
  211.   BROWN = Color.html("#A52A2A")
  212.   BURLYWOOD = Color.html("#DEB887")
  213.   CADETBLUE = Color.html("#5F9EA0")
  214.   CHARTREUSE = Color.html("#7FFF00")
  215.   CHOCOLATE = Color.html("#D2691E")
  216.   CORAL = Color.html("#FF7F50")
  217.   CORNFLOWERBLUE = Color.html("#6495ED")
  218.   CORNSILK = Color.html("#FFF8DC")
  219.   CRIMSON = Color.html("#DC143C")
  220.   CYAN = Color.html("#00FFFF")
  221.   DARKBLUE = Color.html("#00008B")
  222.   DARKCYAN = Color.html("#008B8B")
  223.   DARKGOLDENROD = Color.html("#B8860B")
  224.   DARKGRAY = Color.html("#A9A9A9")
  225.   DARKGREEN = Color.html("#006400")
  226.   DARKKHAKI = Color.html("#BDB76B")
  227.   DARKMAGENTA = Color.html("#8B008B")
  228.   DARKOLIVEGREEN = Color.html("#556B2F")
  229.   DARKORANGE = Color.html("#FF8C00")
  230.   DARKORCHID = Color.html("#9932CC")
  231.   DARKRED = Color.html("#8B0000")
  232.   DARKSALMON = Color.html("#E9967A")
  233.   DARKSEAGREEN = Color.html("#8FBC8F")
  234.   DARKSLATEBLUE = Color.html("#483D8B")
  235.   DARKSLATEGRAY = Color.html("#2F4F4F")
  236.   DARKTURQUOISE = Color.html("#00CED1")
  237.   DARKVIOLET = Color.html("#9400D3")
  238.   DEEPPINK = Color.html("#FF1493")
  239.   DEEPSKYBLUE = Color.html("#00BFFF")
  240.   DIMGRAY = Color.html("#696969")
  241.   DODGERBLUE = Color.html("#1E90FF")
  242.   FELDSPAR = Color.html("#D19275")
  243.   FIREBRICK = Color.html("#B22222")
  244.   FLORALWHITE = Color.html("#FFFAF0")
  245.   FORESTGREEN = Color.html("#228B22")
  246.   FUCHSIA = Color.html("#FF00FF")
  247.   GAINSBORO = Color.html("#DCDCDC")
  248.   GHOSTWHITE = Color.html("#F8F8FF")
  249.   GOLD = Color.html("#FFD700")
  250.   GOLDENROD = Color.html("#DAA520")
  251.   GRAY = Color.html("#808080")
  252.   GREEN = Color.html("#008000")
  253.   GREENYELLOW = Color.html("#ADFF2F")
  254.   HONEYDEW = Color.html("#F0FFF0")
  255.   HOTPINK = Color.html("#FF69B4")
  256.   INDIANRED  = Color.html("#CD5C5C")
  257.   INDIGO  = Color.html("#4B0082")
  258.   IVORY = Color.html("#FFFFF0")
  259.   KHAKI = Color.html("#F0E68C")
  260.   LAVENDER = Color.html("#E6E6FA")
  261.   LAVENDERBLUSH = Color.html("#FFF0F5")
  262.   LAWNGREEN = Color.html("#7CFC00")
  263.   LEMONCHIFFON = Color.html("#FFFACD")
  264.   LIGHTBLUE = Color.html("#ADD8E6")
  265.   LIGHTCORAL = Color.html("#F08080")
  266.   LIGHTCYAN = Color.html("#E0FFFF")
  267.   LIGHTGOLDENRODYELLOW = Color.html("#FAFAD2")
  268.   LIGHTGREY = Color.html("#D3D3D3")
  269.   LIGHTGREEN = Color.html("#90EE90")
  270.   LIGHTPINK = Color.html("#FFB6C1")
  271.   LIGHTSALMON = Color.html("#FFA07A")
  272.   LIGHTSEAGREEN = Color.html("#20B2AA")
  273.   LIGHTSKYBLUE = Color.html("#87CEFA")
  274.   LIGHTSLATEBLUE = Color.html("#8470FF")
  275.   LIGHTSLATEGRAY = Color.html("#778899")
  276.   LIGHTSTEELBLUE = Color.html("#B0C4DE")
  277.   LIGHTYELLOW = Color.html("#FFFFE0")
  278.   LIME = Color.html("#00FF00")
  279.   LIMEGREEN = Color.html("#32CD32")
  280.   LINEN = Color.html("#FAF0E6")
  281.   MAGENTA = Color.html("#FF00FF")
  282.   MAROON = Color.html("#800000")
  283.   MEDIUMAQUAMARINE = Color.html("#66CDAA")
  284.   MEDIUMBLUE = Color.html("#0000CD")
  285.   MEDIUMORCHID = Color.html("#BA55D3")
  286.   MEDIUMPURPLE = Color.html("#9370D8")
  287.   MEDIUMSEAGREEN = Color.html("#3CB371")
  288.   MEDIUMSLATEBLUE = Color.html("#7B68EE")
  289.   MEDIUMSPRINGGREEN = Color.html("#00FA9A")
  290.   MEDIUMTURQUOISE = Color.html("#48D1CC")
  291.   MEDIUMVIOLETRED = Color.html("#C71585")
  292.   MIDNIGHTBLUE = Color.html("#191970")
  293.   MINTCREAM = Color.html("#F5FFFA")
  294.   MISTYROSE = Color.html("#FFE4E1")
  295.   MOCCASIN = Color.html("#FFE4B5")
  296.   NAVAJOWHITE = Color.html("#FFDEAD")
  297.   NAVY = Color.html("#000080")
  298.   OLDLACE = Color.html("#FDF5E6")
  299.   OLIVE = Color.html("#808000")
  300.   OLIVEDRAB = Color.html("#6B8E23")
  301.   ORANGE = Color.html("#FFA500")
  302.   ORANGERED = Color.html("#FF4500")
  303.   ORCHID = Color.html("#DA70D6")
  304.   PALEGOLDENROD = Color.html("#EEE8AA")
  305.   PALEGREEN = Color.html("#98FB98")
  306.   PALETURQUOISE = Color.html("#AFEEEE")
  307.   PALEVIOLETRED = Color.html("#D87093")
  308.   PAPAYAWHIP = Color.html("#FFEFD5")
  309.   PEACHPUFF = Color.html("#FFDAB9")
  310.   PERU = Color.html("#CD853F")
  311.   PINK = Color.html("#FFC0CB")
  312.   PLUM = Color.html("#DDA0DD")
  313.   POWDERBLUE = Color.html("#B0E0E6")
  314.   PURPLE = Color.html("#800080")
  315.   RED = Color.html("#FF0000")
  316.   ROSYBROWN = Color.html("#BC8F8F")
  317.   ROYALBLUE = Color.html("#4169E1")
  318.   SADDLEBROWN = Color.html("#8B4513")
  319.   SALMON = Color.html("#FA8072")
  320.   SANDYBROWN = Color.html("#F4A460")
  321.   SEAGREEN = Color.html("#2E8B57")
  322.   SEASHELL = Color.html("#FFF5EE")
  323.   SIENNA = Color.html("#A0522D")
  324.   SILVER = Color.html("#C0C0C0")
  325.   SKYBLUE = Color.html("#87CEEB")
  326.   SLATEBLUE = Color.html("#6A5ACD")
  327.   SLATEGRAY = Color.html("#708090")
  328.   SNOW = Color.html("#FFFAFA")
  329.   SPRINGGREEN = Color.html("#00FF7F")
  330.   STEELBLUE = Color.html("#4682B4")
  331.   TAN = Color.html("#D2B48C")
  332.   TEAL = Color.html("#008080")
  333.   THISTLE = Color.html("#D8BFD8")
  334.   TOMATO = Color.html("#FF6347")
  335.   TRANSPARENT = Color.html("#00000000")
  336.   TURQUOISE = Color.html("#40E0D0")
  337.   VIOLET = Color.html("#EE82EE")
  338.   VIOLETRED = Color.html("#D02090")
  339.   WHEAT = Color.html("#F5DEB3")
  340.   WHITE = Color.html("#FFFFFF")
  341.   WHITESMOKE = Color.html("#F5F5F5")
  342.   YELLOW = Color.html("#FFFF00")
  343.   YELLOWGREEN = Color.html("#9ACD32")
  344. end

  345. #==============================================================================
  346. # ■ RPG_Cache
  347. #==============================================================================
  348. module RPG
  349.   module Cache
  350.     #--------------------------------------------------------------------------
  351.     # ● 取得图标
  352.     #     filename : 图标文件名
  353.     #     enabled  : 图标有效(彩色)或无效(黑白)
  354.     #--------------------------------------------------------------------------
  355.     def self.icon(filename, enabled = true)
  356.       if enabled
  357.         self.load_bitmap("Graphics/Icons/", filename)
  358.       else
  359.         @disabled ||={}
  360.         key = [filename]
  361.         if (not @disabled.include?(key)) or @disabled[key].disposed?
  362.           @disabled[key] = self.icon(filename, true).to_grayscale
  363.         end
  364.         @disabled[key]         
  365.       end
  366.     end
  367.   end
  368. end

  369. #==============================================================================
  370. # ■ Game_System
  371. #==============================================================================
  372. class Game_System
  373.   include SailCat::Window_Config
  374.   #--------------------------------------------------------------------------
  375.   # ● 取得窗口的色调
  376.   #--------------------------------------------------------------------------
  377.   def window_tone
  378.     # 返回窗口的色调,未设置返回默认值
  379.     @window_tone ||= DEFAULT_TONE
  380.   end
  381.   #--------------------------------------------------------------------------
  382.   # ● 设置窗口的色调
  383.   #     value : 色调值,传入错误的参数不会更改色调
  384.   #--------------------------------------------------------------------------
  385.   def window_tone=(value)
  386.     @window_tone = value if value.is_a?(Tone)
  387.   end
  388. end

  389. #==============================================================================
  390. # ■ Game_Event
  391. #==============================================================================
  392. class Game_Event
  393.   #--------------------------------------------------------------------------
  394.   # ● 事件的名称
  395.   #--------------------------------------------------------------------------
  396.   def name
  397.     @event.name
  398.   end
  399. end

  400. #==============================================================================
  401. # ■ Arrow_Base
  402. #==============================================================================
  403. class Arrow_Base < Sprite
  404.   #--------------------------------------------------------------------------
  405.   # ● 定义实例变量
  406.   #--------------------------------------------------------------------------
  407.   attr_reader   :index                    # 光标位置
  408.   attr_reader   :help_window              # 帮助窗口
  409.   #--------------------------------------------------------------------------
  410.   # ● 初始化对像
  411.   #     viewport : 显示端口
  412.   #--------------------------------------------------------------------------
  413.   def initialize(viewport)
  414.     super(viewport)
  415.     self.bitmap = RPG::Cache.windowskin($game_system.windowskin_name)
  416.     if self.bitmap.width != 192
  417.       self.bitmap = RPG::Cache.windowskin(SailCat::Window_Config::ARROW_FOR_VX)
  418.     end
  419.     self.ox = 16
  420.     self.oy = 64
  421.     self.z = 2500
  422.     @blink_count = 0
  423.     @index = 0
  424.     @help_window = nil
  425.     update
  426.   end
  427. end

  428. #==============================================================================
  429. # ■ Window_Base
  430. #==============================================================================
  431. class Window_Base
  432.   include SailCat::Window_Config
  433.   #--------------------------------------------------------------------------
  434.   # ● 方法重定义
  435.   #--------------------------------------------------------------------------
  436.   unless method_defined?(:sailcat_windowcore_dispose)
  437.     alias sailcat_windowcore_dispose dispose
  438.     alias sailcat_windowcore_back_opacity= back_opacity=
  439.   end
  440.   #--------------------------------------------------------------------------
  441.   # ● 定义实例变量
  442.   #--------------------------------------------------------------------------
  443.   attr_reader   :tone                     # 窗口的色调
  444.   attr_reader   :openness                 # 窗口的开启程度
  445.   attr_reader   :windowskin_name          # 窗口皮肤 文件名
  446.   attr_accessor :windowskin_fix           # 窗口皮肤 锁定标志
  447.   #--------------------------------------------------------------------------
  448.   # ● 初始化对像
  449.   #     x      : 窗口的 X 坐标
  450.   #     y      : 窗口的 Y 坐标
  451.   #     width  : 窗口的宽
  452.   #     height : 窗口的宽
  453.   #     ws_name: 皮肤文件名
  454.   #--------------------------------------------------------------------------
  455.   def initialize(x, y, width, height, ws_name = nil)
  456.     super()
  457.     @windowskin_name = ws_name || $game_system.windowskin_name
  458.     self.windowskin = RPG::Cache.windowskin(@windowskin_name)
  459.     @windowskin_fix = @windowskin_name != $game_system.windowskin_name
  460.     @back_sprite = Sprite.new
  461.     @back_sprite.ox = 0
  462.     @back_sprite.oy = 0
  463.     @tile_sprite = Sprite.new
  464.     @tile_sprite.ox = 0
  465.     @tile_sprite.oy = 0
  466.     @tile_sprite.visible = true
  467.     @openness = 255
  468.     @opening = false
  469.     @closing = false
  470.     @move_duration = 0
  471.     @old_contents = nil
  472.     self.stretch = STRETCH
  473.     self.x = x
  474.     self.y = y
  475.     self.width = width <= 0 ? width + SCREEN_W : width
  476.     self.height = height <= 0 ? height + SCREEN_H : height
  477.     self.z = 100
  478.     self.sailcat_windowcore_back_opacity = 0
  479.     self.back_opacity = BACK_OPACITY_DEFAULT
  480.     self.tone = $game_system.window_tone
  481.     draw_background
  482.     self.tile_effect = TILE_EFFECT
  483.   end
  484.   #--------------------------------------------------------------------------
  485.   # ● 建立内容
  486.   #--------------------------------------------------------------------------
  487.   def create_contents
  488.     contents.dispose if contents
  489.     self.contents = Bitmap.new(width - 32, height - 32)
  490.   end
  491.   #--------------------------------------------------------------------------
  492.   # ● 单独设置皮肤
  493.   #--------------------------------------------------------------------------
  494.   def windowskin_name=(windowskin_name)
  495.     @windowskin_name = windowskin_name
  496.     @windowskin_fix = true
  497.     self.windowskin = RPG::Cache.windowskin(@windowskin_name)
  498.   end
  499.   #--------------------------------------------------------------------------
  500.   # ● 更新窗口皮肤
  501.   #--------------------------------------------------------------------------
  502.   def windowskin=(ws)
  503.     # 如果是VX的皮肤规格,转为XP格式
  504.     if ws.width == 128 and ws.height == 128
  505.       @vx_skin = true
  506.       b = Bitmap.new(192, 128)
  507.       b.blt(0, 0, ws, Rect.new(0, 0, 64, 128))
  508.       b.blt(128, 0, ws, Rect.new(64, 0, 64, 96))
  509.       b.stretch_blt(Rect.new(152, 24, 16, 8), ws, Rect.new(64, 96, 64, 32))
  510.       ws.dispose
  511.       ws = b
  512.     # 如果是XP的皮肤规格,直接使用
  513.     else
  514.       @vx_skin = false
  515.     end
  516.     super
  517.     unless @tiled_bitmap.nil? or @tiled_bitmap.disposed?
  518.       @tiled_bitmap.dispose
  519.     end
  520.     @tiled_bitmap = Bitmap.new(SCREEN_W - 4, SCREEN_H - 4)
  521.     exp = @vx_skin ? 6 : 7
  522.     for i in 0..(SCREEN_W - 5 >> exp)
  523.       for j in 0..(SCREEN_H - 5 >> exp)
  524.         @tiled_bitmap.blt(i << exp, j << exp, self.windowskin,
  525.           Rect.new(0, 0, 1 << exp, 1 << exp))
  526.       end
  527.     end
  528.     draw_background unless @back_sprite.nil?
  529.   end
  530.   #--------------------------------------------------------------------------
  531.   # ● 更改色调
  532.   #     tone : 窗口的色调
  533.   #--------------------------------------------------------------------------
  534.   def tone=(tone)
  535.     @tone = tone
  536.     @back_sprite.tone = tone
  537.     @tile_sprite.tone = tone
  538.   end
  539.   #--------------------------------------------------------------------------
  540.   # ● 更新窗口打开
  541.   #--------------------------------------------------------------------------
  542.   def update_open
  543.     self.openness += @step_open
  544.     @opening = false if open?
  545.   end
  546.   #--------------------------------------------------------------------------
  547.   # ● 打开判定
  548.   #--------------------------------------------------------------------------
  549.   def open?
  550.     @openness == 255
  551.   end
  552.   #--------------------------------------------------------------------------
  553.   # ● 更新窗口关闭
  554.   #--------------------------------------------------------------------------
  555.   def update_close
  556.     self.openness -= @step_open
  557.     @closing = false if close?
  558.   end
  559.   #--------------------------------------------------------------------------
  560.   # ● 关闭判定
  561.   #--------------------------------------------------------------------------
  562.   def close?
  563.     @openness == 0
  564.   end
  565.   #--------------------------------------------------------------------------
  566.   # ● 打开
  567.   #--------------------------------------------------------------------------
  568.   def open(duration = 6)
  569.     @opening = true unless open?
  570.     @closing = false
  571.     @step_open = (255.0 / [duration, 1].max).ceil
  572.     self
  573.   end
  574.   #--------------------------------------------------------------------------
  575.   # ● 关闭
  576.   #--------------------------------------------------------------------------
  577.   def close(duration = 6)
  578.     @closing = true unless close?
  579.     @opening = false
  580.     @step_open = (255.0 / [duration, 1].max).ceil
  581.     self
  582.   end
  583.   #--------------------------------------------------------------------------
  584.   # ● 显示
  585.   #--------------------------------------------------------------------------
  586.   def show
  587.     self.visible = true
  588.     self
  589.   end
  590.   #--------------------------------------------------------------------------
  591.   # ● 隐藏
  592.   #--------------------------------------------------------------------------
  593.   def hide
  594.     self.visible = false
  595.     self
  596.   end
  597.   #--------------------------------------------------------------------------
  598.   # ● 启用
  599.   #--------------------------------------------------------------------------
  600.   def activate
  601.     self.active = true
  602.     self
  603.   end
  604.   #--------------------------------------------------------------------------
  605.   # ● 禁用
  606.   #--------------------------------------------------------------------------
  607.   def deactivate
  608.     self.active = false
  609.     self
  610.   end
  611.   #--------------------------------------------------------------------------
  612.   # ● 绘制主背景
  613.   #--------------------------------------------------------------------------
  614.   def draw_background
  615.     if stretch
  616.       @back_sprite.bitmap = self.windowskin
  617.       if @vx_skin
  618.         @back_sprite.src_rect = Rect.new(0, 0, 64, 64)
  619.       else
  620.         @back_sprite.src_rect = Rect.new(0, 0, 128, 128)
  621.       end
  622.       @back_sprite.zoom_x = (width - 4) / (@vx_skin ? 64.0 : 128.0)
  623.       @back_sprite.zoom_y = (height - 4) / (@vx_skin ? 64.0 : 128.0)
  624.     else
  625.       @back_sprite.bitmap = @tiled_bitmap
  626.       @back_sprite.src_rect = Rect.new(0, 0, width - 4, height - 4)
  627.       @back_sprite.zoom_x = 1.0
  628.       @back_sprite.zoom_y = 1.0
  629.     end
  630.   end
  631.   #--------------------------------------------------------------------------
  632.   # ● 绘制平铺背景(水印)
  633.   #--------------------------------------------------------------------------
  634.   def draw_tileback
  635.     return if self.tile_effect == false or @scan_bitmap != nil
  636.     if @vx_skin
  637.       @scan_bitmap = Bitmap.new(SCREEN_W - 4, SCREEN_H - 4)
  638.       for i in 0..(SCREEN_W - 5 >> 6)
  639.         for j in 0..(SCREEN_H - 5 >> 6)
  640.           @scan_bitmap.blt(i << 6, j << 6,
  641.             self.windowskin, Rect.new(0, 64, 64, 64))
  642.         end
  643.       end
  644.     else
  645.       @scan_bitmap = Bitmap.new(SCREEN_W - 4, SCREEN_H - 4)
  646.       for i in 0..(SCREEN_H - 5 >> 1)
  647.         @scan_bitmap.fill_rect(0, (i << 1) + 1, SCREEN_W - 4, 1,
  648.           Color.new(5, 5, 5, 40))
  649.       end
  650.     end
  651.     @tile_sprite.bitmap = @scan_bitmap
  652.     @tile_sprite.src_rect = Rect.new(0, 0, width - 4, height - 4)
  653.     @tile_sprite.zoom_x = 1.0
  654.     @tile_sprite.zoom_y = 1.0
  655.   end
  656.   #--------------------------------------------------------------------------
  657.   # ● 释放
  658.   #--------------------------------------------------------------------------
  659.   def dispose
  660.     sailcat_windowcore_dispose
  661.     @back_sprite.dispose
  662.     @tile_sprite.dispose
  663.     @tiled_bitmap.dispose if @tiled_bitmap
  664.     @scan_bitmap.dispose if @scan_bitmap
  665.   end
  666.   #--------------------------------------------------------------------------
  667.   # ● 背景透明度
  668.   #--------------------------------------------------------------------------
  669.   def back_opacity
  670.     return @back_opacity
  671.   end
  672.   #--------------------------------------------------------------------------
  673.   # ● 调整透明度
  674.   #--------------------------------------------------------------------------
  675.   def opacity=(value)
  676.     super
  677.     real_value = value.limit(0, 255) * self.back_opacity / 255
  678.     @back_sprite.opacity = @tile_sprite.opacity = real_value
  679.   end
  680.   #--------------------------------------------------------------------------
  681.   # ● 调整背景透明度
  682.   #--------------------------------------------------------------------------
  683.   def back_opacity=(value)
  684.     @back_opacity = value.limit(0, 255)
  685.     @back_sprite.opacity = @back_opacity * self.opacity / 255
  686.     @tile_sprite.opacity = @back_opacity * self.opacity / 255
  687.   end
  688.   #--------------------------------------------------------------------------
  689.   # ● 设置窗口 X 坐标
  690.   #     x : 新的 X 坐标
  691.   #--------------------------------------------------------------------------
  692.   def x=(x)
  693.     @real_x = x
  694.     super
  695.     @tile_sprite.x = @back_sprite.x = x + 2
  696.   end
  697.   #--------------------------------------------------------------------------
  698.   # ● 设置窗口 Y 坐标
  699.   #     x : 新的 Y 坐标
  700.   #--------------------------------------------------------------------------
  701.   def y=(y)
  702.     @real_y = y
  703.     super
  704.     @tile_sprite.y = @back_sprite.y = y + 2
  705.   end
  706.   #--------------------------------------------------------------------------
  707.   # ● 设置窗口 Z 坐标
  708.   #     z : 新的 Z 坐标
  709.   #--------------------------------------------------------------------------
  710.   def z=(z)
  711.     super
  712.     @tile_sprite.z = @back_sprite.z = z - 1
  713.   end
  714.   #--------------------------------------------------------------------------
  715.   # ● 设置窗口宽度
  716.   #     width : 新的宽度
  717.   #--------------------------------------------------------------------------
  718.   def width=(width)
  719.     @real_width = width
  720.     super
  721.     update_back_size
  722.   end
  723.   #--------------------------------------------------------------------------
  724.   # ● 设置窗口高度
  725.   #     height : 新的高度
  726.   #--------------------------------------------------------------------------
  727.   def height=(height)
  728.     @real_height = height
  729.     super
  730.     update_back_size
  731.   end
  732.   #--------------------------------------------------------------------------
  733.   # ● 取得窗口占用的矩形
  734.   #--------------------------------------------------------------------------
  735.   def rect
  736.     Rect.new(x, y, width, height)
  737.   end
  738.   #--------------------------------------------------------------------------
  739.   # ● 更新背景大小
  740.   #--------------------------------------------------------------------------
  741.   def update_back_size
  742.     if stretch
  743.       @back_sprite.zoom_x = (width - 4) / (@vx_skin ? 64.0 : 128.0)
  744.       @back_sprite.zoom_y = (height - 4) / (@vx_skin ? 64.0 : 128.0)
  745.     else
  746.       @back_sprite.src_rect = Rect.new(0, 0, width - 4, height - 4)
  747.     end
  748.     @tile_sprite.src_rect = Rect.new(0, 0, width - 4, height - 4)
  749.   end
  750.   #--------------------------------------------------------------------------
  751.   # ● 重设窗口大小
  752.   #     width    : 新的宽度
  753.   #     height   : 新的高度
  754.   #     duration : 重设效果持续时间
  755.   #--------------------------------------------------------------------------
  756.   def resize(width, height, duration = 0)
  757.     move(self.x, self.y, width, height, duration)
  758.     self
  759.   end
  760.   #--------------------------------------------------------------------------
  761.   # ● 移动窗口位置
  762.   #     x        : 新的 X 坐标
  763.   #     y        : 新的 Y 坐标
  764.   #     duration : 重设效果持续时间
  765.   #--------------------------------------------------------------------------
  766.   def moveto(x, y, duration = 0)
  767.     move(x, y, self.width, self.height, duration)
  768.     self
  769.   end
  770.   #--------------------------------------------------------------------------
  771.   # ● 窗口居中
  772.   #     rect : 居中的参考矩形
  773.   #--------------------------------------------------------------------------
  774.   def center(rect = Rect.new(0, 0, SCREEN_W, SCREEN_H))
  775.     moveto(rect.x + (rect.width - self.width >> 1),
  776.       rect.y + (rect.height - self.height >> 1))
  777.     self
  778.   end
  779.   #--------------------------------------------------------------------------
  780.   # ● 窗口对齐
  781.   #     d : 对齐方向(1-9)
  782.   #     rect : 对齐的参考矩形
  783.   #--------------------------------------------------------------------------
  784.   def align(d, rect = Rect.new(0, 0, SCREEN_W, SCREEN_H))
  785.     self.x = rect.x + ((rect.width - self.width) * ((d - 1) % 3) >> 1)
  786.     self.y = rect.y + ((rect.height - self.height) * (2 - (d - 1) / 3) >> 1)
  787.     self
  788.   end
  789.   #--------------------------------------------------------------------------
  790.   # ● 窗口贴合
  791.   #     other : 被贴合的另一窗口
  792.   #     d     : 贴合方向(2/4/6/8)
  793.   #     a     : 对齐方向(2=>1/2/3, 4=>1/4/7, 6=>3/6/9, 8=>7/8/9)
  794.   #--------------------------------------------------------------------------
  795.   def dock(other, d, a = d)
  796.     rect = other.rect
  797.     case d
  798.     when 2, 8
  799.       self.x = rect.x + ((rect.width - self.width) * ((a - 1) % 3) >> 1)
  800.       self.y = d == 2 ? rect.top - self.height : rect.bottom
  801.     when 4, 6
  802.       self.x = d == 4 ? rect.right : rect.left - self.width
  803.       self.y = rect.y + ((rect.height - self.height) * (2 - (a - 1) / 3) >> 1)
  804.     end
  805.     self
  806.   end
  807.   #--------------------------------------------------------------------------
  808.   # ● 执行移动窗口
  809.   #--------------------------------------------------------------------------
  810.   def move(x, y, width = nil, height = nil, duration = 0)
  811.     return if moving?
  812.     width ||= self.width
  813.     height ||= self.height
  814.     return if x == self.x and y == self.y and
  815.       width == self.width and height == self.height
  816.     if duration == 0
  817.       self.x = x
  818.       self.y = y
  819.       self.width = width
  820.       self.height = height
  821.       return
  822.     end
  823.     @move_duration = duration
  824.     @step_x = (x - @real_x) * 1.0 / @move_duration
  825.     @step_y = (y - @real_y) * 1.0 / @move_duration
  826.     @step_width = (width - @real_width) * 1.0 / @move_duration
  827.     @step_height = (height - @real_height) * 1.0 / @move_duration
  828.     @real_x = x
  829.     @real_y = y
  830.     @real_width = width
  831.     @real_height = height
  832.     if self.width != width or self.height != height
  833.       @old_contents = contents.clone
  834.     end
  835.     self
  836.   end
  837.   #--------------------------------------------------------------------------
  838.   # ● 移动中判定
  839.   #--------------------------------------------------------------------------
  840.   def moving?
  841.     @move_duration > 0
  842.   end
  843.   #--------------------------------------------------------------------------
  844.   # ● 更新移动窗口
  845.   #--------------------------------------------------------------------------
  846.   def update_move
  847.     @move_duration -= 1 if @move_duration > 0
  848.     last_x = @real_x
  849.     last_y = @real_y
  850.     last_width = @real_width
  851.     last_height = @real_height
  852.     self.x = last_x - Integer(@step_x * @move_duration)
  853.     self.y = last_y - Integer(@step_y * @move_duration)
  854.     self.width = last_width - Integer(@step_width * @move_duration)
  855.     self.height = last_height - Integer(@step_height * @move_duration)
  856.     if self.width != last_width or self.height != last_height
  857.       create_contents
  858.       contents.blt(0, 0, @old_contents, Rect.new(0, 0, width, height))
  859.     end
  860.     @real_x = last_x
  861.     @real_y = last_y
  862.     @real_width = last_width
  863.     @real_height = last_height
  864.     if @old_contents != nil and @move_duration == 0
  865.       @old_contents.dispose
  866.       @old_contents = nil
  867.     end
  868.   end
  869.   #--------------------------------------------------------------------------
  870.   # ● 改变窗口可视性
  871.   #     visible : 新的可视性
  872.   #--------------------------------------------------------------------------
  873.   def visible=(visible)
  874.     super
  875.     @back_sprite.visible = visible
  876.     @tile_sprite.visible = visible
  877.   end
  878.   #--------------------------------------------------------------------------
  879.   # ● 改变窗口背景绘制方式
  880.   #     stretch : 新的绘制方式(平铺/拉伸)
  881.   #--------------------------------------------------------------------------
  882.   def stretch=(stretch)
  883.     if stretch != self.stretch
  884.       super
  885.       @back_sprite.bitmap.dispose if stretch
  886.       draw_background
  887.     end
  888.   end
  889.   #--------------------------------------------------------------------------
  890.   # ● 改变窗口开放度
  891.   #--------------------------------------------------------------------------
  892.   def openness=(openness)
  893.     last_x = @real_x
  894.     last_y = @real_y
  895.     last_w = @real_width
  896.     last_h = @real_height
  897.     dir = (@openness > openness ? CLOSE_HORZ : OPEN_HORZ)
  898.     # 设置开放度
  899.     @openness = openness.limit(0, 255)
  900.     # 非完全打开时,隐藏内容
  901.     if @openness > 0 and self.contents
  902.       self.contents_opacity = 0
  903.       @old_contents = self.contents.clone
  904.       self.contents.dispose
  905.       self.contents = nil
  906.     end
  907.     # 水平打开/关闭
  908.     if dir
  909.       self.x = last_x + (last_w >> 1) * (255 - @openness) / 255
  910.       self.width = last_w * @openness / 255
  911.       @real_x = last_x
  912.       @real_width = last_w
  913.     # 垂直打开/关闭
  914.     else
  915.       self.y = last_y + (last_h >> 1) * (255 - @openness) / 255
  916.       self.height = last_h * @openness / 255
  917.       @real_y = last_y
  918.       @real_height = last_h
  919.     end
  920.     # 仅完全打开时显示内容
  921.     if open?
  922.       self.contents ||= @old_contents || create_contents
  923.       self.contents_opacity = 255
  924.       @old_contents = nil
  925.     end
  926.   end
  927.   #--------------------------------------------------------------------------
  928.   # ● 是否显示水印
  929.   #--------------------------------------------------------------------------
  930.   def tile_effect
  931.     @tile_sprite.visible
  932.   end
  933.   #--------------------------------------------------------------------------
  934.   # ● 设置是否显示水印
  935.   #     tile_effect : 是否显示水印(true/false)
  936.   #--------------------------------------------------------------------------
  937.   def tile_effect=(tile_effect)
  938.     @tile_sprite.visible = tile_effect
  939.     draw_tileback
  940.   end
  941.   #--------------------------------------------------------------------------
  942.   # ● 更新
  943.   #--------------------------------------------------------------------------
  944.   def update
  945.     super
  946.     # 如果窗口的外观被变更了、再设置
  947.     if $game_system.windowskin_name != @windowskin_name and not @windowskin_fix
  948.       @windowskin_name = $game_system.windowskin_name
  949.       self.windowskin = RPG::Cache.windowskin(@windowskin_name)
  950.     end
  951.     update_open if @opening
  952.     update_close if @closing
  953.     update_move if moving?
  954.   end
  955.   #--------------------------------------------------------------------------
  956.   # ● 皮肤内是否含有调色板
  957.   #--------------------------------------------------------------------------
  958.   def skin_has_palette?
  959.     @vx_skin || windowskin.get_pixel(152, 24).alpha > 0
  960.   end
  961.   #--------------------------------------------------------------------------
  962.   # ● 取得颜色
  963.   #     n     : 颜色索引(0-63)
  964.   #     alpha : 强制指定不透明度(0-255)
  965.   #--------------------------------------------------------------------------
  966.   def text_color(n, alpha = nil)
  967.     i = n & 31
  968.     alpha = (alpha || 255) * DISABLED_ALPHA / 255 if n >= 31
  969.     if skin_has_palette?
  970.       c = windowskin.get_pixel(152 + ((i & 7) << 1), 24 + ((i & 24) >> 2))
  971.     else
  972.       v = PALETTE_XP[n & 31]
  973.       c = v ? Color.html(v) : Color.new(255, 255, 255, 255)
  974.     end
  975.     c.alpha = alpha if alpha
  976.     return c
  977.   end
  978.   #--------------------------------------------------------------------------
  979.   # ● 取得特殊文字色
  980.   #--------------------------------------------------------------------------
  981.   def normal_color;      text_color(0);   end;    # 普通文字色
  982.   def system_color;      text_color(16);  end;    # 系统文字色
  983.   def crisis_color;      text_color(17);  end;    # 危机文字色
  984.   def knockout_color;    text_color(18);  end;    # 战斗不能文字色
  985.   def gauge_back_color;  text_color(19);  end;    # 数值槽背景色
  986.   def hp_gauge_color1;   text_color(20);  end;    # HP 槽颜色1
  987.   def hp_gauge_color2;   text_color(21);  end;    # HP 槽颜色2
  988.   def sp_gauge_color1;   text_color(22);  end;    # SP 槽颜色1
  989.   def sp_gauge_color2;   text_color(23);  end;    # SP 槽颜色2
  990.   def sp_cost_color;     text_color(23);  end;    # SP 消费色
  991.   def power_up_color;    text_color(24);  end;    # 数值上升比较色
  992.   def power_down_color;  text_color(25);  end;    # 数值下降比较色
  993.   def exp_gauge_color1;  text_color(28);  end;    # EXP 槽颜色1
  994.   def exp_gauge_color2;  text_color(29);  end;    # EXP 槽颜色2
  995.   def disabled_color;    text_color(32);  end;    # 无效文字色
  996.   #--------------------------------------------------------------------------
  997.   # ● 取得变化值颜色
  998.   #--------------------------------------------------------------------------
  999.   def param_change_color(change)
  1000.     return power_up_color   if change > 0
  1001.     return power_down_color if change < 0
  1002.     return normal_color
  1003.   end
  1004.   #--------------------------------------------------------------------------
  1005.   # ● 取得HTML颜色
  1006.   #     str : HTML颜色值
  1007.   #--------------------------------------------------------------------------
  1008.   def html_color(str)
  1009.     if str[0] == ?#
  1010.       Color.html(str) rescue normal_color
  1011.     else
  1012.       Color.const_get(str.upcase) rescue normal_color
  1013.     end
  1014.   end
  1015.   #--------------------------------------------------------------------------
  1016.   # ● 取得行高
  1017.   #     lines : 行数
  1018.   #--------------------------------------------------------------------------
  1019.   def line_height(lines = 1)
  1020.     return LINE_HEIGHT * lines
  1021.   end
  1022.   #--------------------------------------------------------------------------
  1023.   # ● 取得容纳指定行数的窗口高
  1024.   #     lines : 行数
  1025.   #--------------------------------------------------------------------------
  1026.   def window_h(lines = 1)
  1027.     return line_height(lines) + 32
  1028.   end
  1029.   #--------------------------------------------------------------------------
  1030.   # ● 更改文字颜色
  1031.   #     enabled : 颜色是否为无效状态
  1032.   #--------------------------------------------------------------------------
  1033.   def change_color(color, enabled = true)
  1034.     contents.font.color = color
  1035.     contents.font.color.alpha = DISABLED_ALPHA unless enabled
  1036.   end
  1037.   #--------------------------------------------------------------------------
  1038.   # ● 绘制文字(与Bitmap调用方法相同)
  1039.   #--------------------------------------------------------------------------
  1040.   def draw_text(*args)
  1041.     contents.draw_text(*args)
  1042.   end
  1043.   #--------------------------------------------------------------------------
  1044.   # ● 取得文字尺寸矩形(与Bitmap调用方法相同)
  1045.   #--------------------------------------------------------------------------
  1046.   def text_size(str)
  1047.     contents.text_size(str.to_s)
  1048.   end
  1049.   #--------------------------------------------------------------------------
  1050.   # ● 绘制带有控制符的文字
  1051.   #--------------------------------------------------------------------------
  1052.   def draw_text_ex(x, y, text)
  1053.     reset_font_settings
  1054.     text = convert_escape_characters(text)
  1055.     pos = [x, y, x, calc_line_height(text)]
  1056.     process_character(text.slice!(/./m), text, pos) until text.empty?
  1057.   end
  1058.   #--------------------------------------------------------------------------
  1059.   # ● 重设字体
  1060.   #--------------------------------------------------------------------------
  1061.   def reset_font_settings(keep_color = false)
  1062.     change_color(normal_color) unless keep_color
  1063.     contents.font.size = Font.default_size
  1064.     contents.font.bold = Font.default_bold
  1065.     contents.font.italic = Font.default_italic
  1066.   end
  1067.   #--------------------------------------------------------------------------
  1068.   # ● 变换控制符
  1069.   #--------------------------------------------------------------------------
  1070.   def convert_escape_characters(text)
  1071.     result = text.to_s.clone
  1072.     result.gsub!(/\\/)              { "\e" }
  1073.     result.gsub!(/\e\e/)            { "\" }
  1074.     result.gsub!(/\e\//)            { "\n" }
  1075.     result.gsub!(/\e\|/)            { "\t" }
  1076.     begin
  1077.       last_result = result.clone
  1078.       result.gsub!(/\eV\[(\d+)\]/i) { $game_variables[$1.to_i] }
  1079.     end until last_result == result
  1080.     result.gsub!(/\eV\[N(\d+)\.(\w+)\]/i)  { battler_param(0, $1.to_i, $2) }
  1081.     result.gsub!(/\eV\[P(\d+)\.(\w+)\]/i)  { battler_param(1, $1.to_i, $2) }
  1082.     result.gsub!(/\eV\[E(\d+)\.(\w+)\]/i)  { battler_param(2, $1.to_i, $2) }
  1083.     result.gsub!(/\eV\[T(\d+)\.(\w+)\]/i)  { battler_param(3, $1.to_i, $2) }
  1084.     result.gsub!(/\eD\[S(\d+)\]/i)  { item_name($data_skills,  $1.to_i) }
  1085.     result.gsub!(/\eD\[I(\d+)\]/i)  { item_name($data_items,   $1.to_i) }
  1086.     result.gsub!(/\eD\[W(\d+)\]/i)  { item_name($data_weapons, $1.to_i) }
  1087.     result.gsub!(/\eD\[A(\d+)\]/i)  { item_name($data_armors,  $1.to_i) }
  1088.     result.gsub!(/\eD\[C(\d+)\]/i)  { data_name(0, $1.to_i) }
  1089.     result.gsub!(/\eD\[B(\d+)\]/i)  { data_name(1, $1.to_i) }
  1090.     result.gsub!(/\eD\[T(\d+)\]/i)  { data_name(2, $1.to_i) }
  1091.     result.gsub!(/\eD\[M(\d+)\]/i)  { data_name(3, $1.to_i) }
  1092.     result.gsub!(/\eD\[E(\d+)\]/i)  { data_name(4, $1.to_i) }
  1093.     result.gsub!(/\eD\[V(\d+)\]/i)  { event_name($1.to_i) }
  1094.     result.gsub!(/\eN\[(\d+)\]/i)   { actor_name($1.to_i) }
  1095.     result.gsub!(/\eP\[(\d+)\]/i)   { party_member_name($1.to_i) }
  1096.     result.gsub!(/\eE\[(\d+)\]/i)   { enemy_name($1.to_i) }
  1097.     result.gsub!(/\eT\[(\d+)\]/i)   { troop_member_name($1.to_i) }
  1098.     result.gsub!(/\e\$/)            { Vocab.gold }
  1099.     result
  1100.   end
  1101.   #--------------------------------------------------------------------------
  1102.   # ● 物品的名称
  1103.   #--------------------------------------------------------------------------
  1104.   def item_name(catalog, n)
  1105.     item = catalog[n]
  1106.     item ? "\eI[#{item.icon_name}]#{item.name}" : ""
  1107.   end
  1108.   #--------------------------------------------------------------------------
  1109.   # ● 数据的名称
  1110.   #--------------------------------------------------------------------------
  1111.   def data_name(type, n)
  1112.     case type
  1113.     when 0
  1114.       get_name($data_classes[n])
  1115.     when 1
  1116.       get_name($data_states[n])
  1117.     when 2
  1118.       get_name($data_tilesets[n])
  1119.     when 3
  1120.       $data_mapinfos ||= load_data("Data/MapInfos.rxdata")
  1121.       n = $game_map.map_id if n == 0
  1122.       get_name($data_mapinfos[n])
  1123.     when 4
  1124.       $data_system.elements[n] || ""
  1125.     end
  1126.   end
  1127.   #--------------------------------------------------------------------------
  1128.   # ● 获得名称
  1129.   #--------------------------------------------------------------------------
  1130.   def get_name(object)
  1131.     object ? object.name : ""
  1132.   end
  1133.   #--------------------------------------------------------------------------
  1134.   # ● 事件的名称
  1135.   #--------------------------------------------------------------------------
  1136.   def event_name(n)
  1137.     $game_map ? get_name($game_system.map_interpreter.get_character(n)) : ""
  1138.   end
  1139.   #--------------------------------------------------------------------------
  1140.   # ● 角色的名称
  1141.   #--------------------------------------------------------------------------
  1142.   def actor_name(n)
  1143.     n >= 1 ? get_name($game_actors[n]) : ""
  1144.   end
  1145.   #--------------------------------------------------------------------------
  1146.   # ● 队伍顺序角色的名称
  1147.   #--------------------------------------------------------------------------
  1148.   def party_member_name(n)
  1149.     n >= 1 ? get_name($game_party.actors[n - 1]) : ""
  1150.   end
  1151.   #--------------------------------------------------------------------------
  1152.   # ● 敌人的名称
  1153.   #--------------------------------------------------------------------------
  1154.   def enemy_name(n)
  1155.     n >= 1 ? get_name($data_enemies[n]) : ""
  1156.   end
  1157.   #--------------------------------------------------------------------------
  1158.   # ● 队伍顺序敌人的名称
  1159.   #--------------------------------------------------------------------------
  1160.   def troop_member_name(n)
  1161.     n >= 1 ? get_name($game_troop.enemies[n - 1]) : ""
  1162.   end
  1163.   #--------------------------------------------------------------------------
  1164.   # ● 战斗者的指数
  1165.   #--------------------------------------------------------------------------
  1166.   def battler_param(type, n, param)
  1167.     case type
  1168.     when 0
  1169.       battler = $game_actors[n]
  1170.     when 1
  1171.       battler = n >= 1 ? $game_party.actors[n - 1] : nil
  1172.     when 2
  1173.       battler = $data_enemies[n]
  1174.     when 3
  1175.       battler = n >= 1 ? $game_troop.enemies[n - 1] : nil
  1176.     end
  1177.     battler ? (battler.send(param.downcase) rescue 0) : 0
  1178.   end
  1179.   #--------------------------------------------------------------------------
  1180.   # ● 逐字符解析
  1181.   #     c    : 字符
  1182.   #     text : 剩余的文字
  1183.   #     pos  : 绘制位置
  1184.   #--------------------------------------------------------------------------
  1185.   def process_character(c, text, pos)
  1186.     case c
  1187.     when "\n"   # 折行
  1188.       process_new_line(text, pos)
  1189.     when "\f"   # 折页
  1190.       process_new_page(text, pos)
  1191.     when "\t"   # 制表位
  1192.       process_tab_stop(text, pos)
  1193.     when "\e"   # 控制字符
  1194.       process_escape_character(obtain_escape_code(text), text, pos)
  1195.     else        # 普通字符
  1196.       process_normal_character(c, pos)
  1197.     end
  1198.   end
  1199.   #--------------------------------------------------------------------------
  1200.   # ● 绘制下一个普通字符
  1201.   #--------------------------------------------------------------------------
  1202.   def process_normal_character(c, pos)
  1203.     text_width = text_size(c).width
  1204.     draw_text(pos[0], pos[1], text_width << 1, pos[3], c)
  1205.     pos[0] += text_width
  1206.   end
  1207.   #--------------------------------------------------------------------------
  1208.   # ● 折行处理
  1209.   #--------------------------------------------------------------------------
  1210.   def process_new_line(text, pos)
  1211.     pos[0] = pos[2]
  1212.     pos[1] += pos[3]
  1213.     pos[3] = calc_line_height(text)
  1214.   end
  1215.   #--------------------------------------------------------------------------
  1216.   # ● 折页处理
  1217.   #--------------------------------------------------------------------------
  1218.   def process_new_page(text, pos)
  1219.   end
  1220.   #--------------------------------------------------------------------------
  1221.   # ● 制表位处理
  1222.   #--------------------------------------------------------------------------
  1223.   def process_tab_stop(text, pos)
  1224.     tab_width = text_size(" ").width << 3
  1225.     pos[0] = (pos[0] / tab_width + 1) * tab_width
  1226.   end
  1227.   #--------------------------------------------------------------------------
  1228.   # ● 获得控制符
  1229.   #--------------------------------------------------------------------------
  1230.   def obtain_escape_code(text)
  1231.     text.slice!(/^[\040-\176]/i)
  1232.   end
  1233.   #--------------------------------------------------------------------------
  1234.   # ● 获得控制符参数值
  1235.   #--------------------------------------------------------------------------
  1236.   def obtain_escape_param(text)
  1237.     text.slice!(/^\[[^\133-\135]+\]/)[/[^\133-\135]+/] rescue ""
  1238.   end
  1239.   #--------------------------------------------------------------------------
  1240.   # ● 处理控制字符
  1241.   #     code : 控制命令符
  1242.   #--------------------------------------------------------------------------
  1243.   def process_escape_character(code, text, pos)
  1244.     case code.upcase
  1245.     when 'C'
  1246.       param = obtain_escape_param(text)
  1247.       change_color(param[/^\d+$/] ? text_color(param.to_i) : html_color(param))
  1248.     when 'O'
  1249.       param = obtain_escape_param(text)
  1250.       contents.font.color.alpha = param[/^\d+$/] ? param.to_f : 255.0
  1251.     when 'I'
  1252.       process_draw_icon(obtain_escape_param(text), pos)
  1253.     when 'J'
  1254.       param = obtain_escape_param(text)
  1255.       pos[0] = param.to_i if param[/^\d+$/]
  1256.     when '{'
  1257.       make_font_bigger
  1258.     when '}'
  1259.       make_font_smaller
  1260.     when '*'
  1261.       make_font_bold
  1262.     when '_'
  1263.       make_font_italic
  1264.     when '~'
  1265.       reset_font_settings
  1266.     when ':'
  1267.       pos[2] = pos[0]
  1268.     when '`'
  1269.       pos[2] = 0
  1270.     end
  1271.   end
  1272.   #--------------------------------------------------------------------------
  1273.   # ● 绘画图标
  1274.   #--------------------------------------------------------------------------
  1275.   def process_draw_icon(icon_name, pos)
  1276.     draw_icon(icon_name, pos[0] + ICON_PADDING, pos[1], true, pos[3])
  1277.     pos[0] += ICON_WIDTH + (ICON_PADDING << 1)
  1278.   end
  1279.   #--------------------------------------------------------------------------
  1280.   # ● 增大字体
  1281.   #--------------------------------------------------------------------------
  1282.   def make_font_bigger
  1283.     contents.font.size += FONT_SIZE_STEP if contents.font.size < FONT_SIZE_MAX
  1284.   end
  1285.   #--------------------------------------------------------------------------
  1286.   # ● 缩小字体
  1287.   #--------------------------------------------------------------------------
  1288.   def make_font_smaller
  1289.     contents.font.size -= FONT_SIZE_STEP if contents.font.size > FONT_SIZE_MIN
  1290.   end
  1291.   #--------------------------------------------------------------------------
  1292.   # ● 加粗字体
  1293.   #--------------------------------------------------------------------------
  1294.   def make_font_bold
  1295.     contents.font.bold = !contents.font.bold
  1296.   end
  1297.   #--------------------------------------------------------------------------
  1298.   # ● 倾斜字体
  1299.   #--------------------------------------------------------------------------
  1300.   def make_font_italic
  1301.     contents.font.italic = !contents.font.italic
  1302.   end
  1303.   #--------------------------------------------------------------------------
  1304.   # ● 计算行高
  1305.   #     restore_font_size : 计算后恢复原字体大小
  1306.   #--------------------------------------------------------------------------
  1307.   def calc_line_height(text, restore_font_size = true)
  1308.     result = [line_height, contents.font.size].max
  1309.     last_font_size = contents.font.size
  1310.     text.slice(/^.*$/).scan(/\e[\{\}~]/).each do |esc|
  1311.       make_font_bigger  if esc == "\e{"
  1312.       make_font_smaller if esc == "\e}"
  1313.       contents.font.size = Font.default_size if esc == "\e~"
  1314.       result = [result, contents.font.size].max
  1315.     end
  1316.     contents.font.size = last_font_size if restore_font_size
  1317.     result
  1318.   end
  1319.   #--------------------------------------------------------------------------
  1320.   # ● 计算列宽
  1321.   #     restore_font_size : 计算后恢复原字体大小
  1322.   #--------------------------------------------------------------------------
  1323.   def calc_text_width(text, restore_font_size = true)
  1324.     last_font_size = contents.font.size
  1325.     last_font_bold = contents.font.bold
  1326.     last_font_italic = contents.font.italic
  1327.     result = col_width = 0
  1328.     esc = false
  1329.     text.scan(/^.*$/).each do |line|
  1330.       filter_escape_char(line)
  1331.       line.scan(/./).each do |char|
  1332.         case char
  1333.         when "\t"
  1334.           tab_width = text_size(" ").width << 3
  1335.           col_width = (col_width / tab_width + 1) * tab_width if col_width > 0
  1336.         when "\e"
  1337.           esc = true
  1338.         else
  1339.           if esc
  1340.             col_width += calc_escape_width(char)
  1341.             esc = false
  1342.           else
  1343.             col_width += text_size(char).width
  1344.           end
  1345.         end
  1346.       end
  1347.       result = [result, col_width].max
  1348.     end
  1349.     if restore_font_size
  1350.       contents.font.size = last_font_size
  1351.       contents.font.bold = last_font_bold
  1352.       contents.font.italic = last_font_italic
  1353.     end
  1354.     result
  1355.   end
  1356.   #--------------------------------------------------------------------------
  1357.   # ● 过滤控制符
  1358.   #     line : 行文字
  1359.   #--------------------------------------------------------------------------
  1360.   def filter_escape_char(line)
  1361.     line.gsub!(/\e[CO]\[[^\133-\135]+\]/i) { "" }
  1362.     line.gsub!(/\eI\[[^\133-\135]+\]/i) { "\eI"}
  1363.   end
  1364.   #--------------------------------------------------------------------------
  1365.   # ● 计算控制符所占宽度
  1366.   #     char : 控制符
  1367.   #--------------------------------------------------------------------------
  1368.   def calc_escape_width(char)
  1369.     make_font_bigger  if char == "{"
  1370.     make_font_smaller if char == "}"
  1371.     make_font_bold if char == "*"
  1372.     make_font_italic if char == "_"
  1373.     reset_font_settings(true) if char == "~"
  1374.     return ICON_WIDTH + (ICON_PADDING << 1) if char == "I"
  1375.     0
  1376.   end
  1377.   #--------------------------------------------------------------------------
  1378.   # ● 绘制值槽
  1379.   #     rate   : 比例
  1380.   #     color1 : 左侧颜色
  1381.   #     color2 : 右侧颜色
  1382.   #--------------------------------------------------------------------------
  1383.   def draw_gauge(x, y, width, rate, color1, color2)
  1384.     return unless SHOW_GAUGE
  1385.     fill_w = (width * rate).to_i
  1386.     gauge_y = y + line_height - 8
  1387.     contents.fill_rect(x, gauge_y, width, 6, gauge_back_color)
  1388.     contents.gradient_fill_rect(x, gauge_y, fill_w, 6, color1, color2)
  1389.   end
  1390.   #--------------------------------------------------------------------------
  1391.   # ● 绘制图标
  1392.   #--------------------------------------------------------------------------
  1393.   def draw_icon(icon_name, x, y, enabled = true, line = line_height)
  1394.     bitmap = RPG::Cache.icon(icon_name, enabled)
  1395.     rect = Rect.new(0, 0, ICON_WIDTH, ICON_HEIGHT)
  1396.     height = [line, contents.font.size].max
  1397.     oy = [(height - ICON_HEIGHT) >> 1, 0].max
  1398.     contents.blt(x, y + oy, bitmap, rect, enabled ? 255 : DISABLED_ALPHA)
  1399.   end
  1400.   #--------------------------------------------------------------------------
  1401.   # ● 取得HP的颜色
  1402.   #--------------------------------------------------------------------------
  1403.   def hp_color(actor)
  1404.     return knockout_color if actor.hp == 0
  1405.     return crisis_color if actor.hp < actor.maxhp >> 2
  1406.     return normal_color
  1407.   end
  1408.   #--------------------------------------------------------------------------
  1409.   # ● 取得SP的颜色
  1410.   #--------------------------------------------------------------------------
  1411.   def sp_color(actor)
  1412.     return crisis_color if actor.sp < actor.maxsp >> 2
  1413.     return normal_color
  1414.   end
  1415.   #--------------------------------------------------------------------------
  1416.   # ● 取得EXP的颜色
  1417.   #--------------------------------------------------------------------------
  1418.   def exp_color(actor)
  1419.     return normal_color
  1420.   end
  1421.   #--------------------------------------------------------------------------
  1422.   # ● 名称的描绘
  1423.   #     actor : 角色
  1424.   #     x     : 描画目标 X 坐标
  1425.   #     y     : 描画目标 Y 坐标
  1426.   #     width : 描画目标宽度
  1427.   #--------------------------------------------------------------------------
  1428.   def draw_actor_name(actor, x, y, width = 120)
  1429.     change_color(normal_color)
  1430.     draw_text(x, y, width, line_height, actor.name)
  1431.   end
  1432.   #--------------------------------------------------------------------------
  1433.   # ● 职业的描绘
  1434.   #--------------------------------------------------------------------------
  1435.   def draw_actor_class(actor, x, y, width = 236)
  1436.     change_color(normal_color)
  1437.     draw_text(x, y, width, line_height, actor.class_name)
  1438.   end
  1439.   #--------------------------------------------------------------------------
  1440.   # ● 等级的描绘
  1441.   #--------------------------------------------------------------------------
  1442.   def draw_actor_level(actor, x, y)
  1443.     change_color(system_color)
  1444.     draw_text(x, y, 32, line_height, Vocab.level_a)
  1445.     change_color(normal_color)
  1446.     draw_text(x + 32, y, 24, line_height, actor.level.to_s, 2)
  1447.   end
  1448.   #--------------------------------------------------------------------------
  1449.   # ● 描绘状态
  1450.   #--------------------------------------------------------------------------
  1451.   def draw_actor_state(actor, x, y, width = 120, always = true)
  1452.     text = make_battler_state_text(actor, width, always)
  1453.     change_color(actor.hp == 0 ? knockout_color : normal_color)
  1454.     draw_text(x, y, width, line_height, text)
  1455.   end
  1456.   #--------------------------------------------------------------------------
  1457.   # ● 描绘当前和最大值
  1458.   #     current : 当前值
  1459.   #     max     : 最大值
  1460.   #     color1  : 当前值颜色
  1461.   #     color2  : 最大值颜色
  1462.   #--------------------------------------------------------------------------
  1463.   def draw_current_and_max_values(x, y, width, current, max, color1, color2)
  1464.     change_color(color1)
  1465.     half = (width - 12) >> 1
  1466.     if half < text_size(max).width
  1467.       draw_text(x, y, width, line_height, current, 2)
  1468.     else
  1469.       draw_text(x, y, half, line_height, current, 2)
  1470.       change_color(color2)
  1471.       draw_text(x + half, y, 12, line_height, "/", 1)
  1472.       draw_text(x + half + 12, y, half, line_height, max, 0)
  1473.     end
  1474.   end
  1475.   #--------------------------------------------------------------------------
  1476.   # ● 描绘 EXP
  1477.   #--------------------------------------------------------------------------
  1478.   def draw_actor_exp(actor, x, y, width = 204)
  1479.     draw_gauge(x, y, width, actor.exp_rate, exp_gauge_color1, exp_gauge_color2)
  1480.     change_color(system_color)
  1481.     draw_text(x, y, 24, line_height, Vocab.exp_a)
  1482.     draw_current_and_max_values(x + 24, y, width - 24, actor.exp_s,
  1483.       actor.next_exp_s, normal_color, normal_color)
  1484.   end
  1485.   #--------------------------------------------------------------------------
  1486.   # ● 描绘 HP
  1487.   #--------------------------------------------------------------------------
  1488.   def draw_actor_hp(actor, x, y, width = 144)
  1489.     draw_gauge(x, y, width, actor.hp_rate, hp_gauge_color1, hp_gauge_color2)
  1490.     change_color(system_color)
  1491.     draw_text(x, y, 32, line_height, Vocab.hp)
  1492.     draw_current_and_max_values(x + 32, y, width - 32, actor.hp, actor.maxhp,
  1493.       hp_color(actor), normal_color)
  1494.   end
  1495.   #--------------------------------------------------------------------------
  1496.   # ● 描绘 SP
  1497.   #--------------------------------------------------------------------------
  1498.   def draw_actor_sp(actor, x, y, width = 144)
  1499.     draw_gauge(x, y, width, actor.sp_rate, sp_gauge_color1, sp_gauge_color2)
  1500.     change_color(system_color)
  1501.     draw_text(x, y, 32, line_height, Vocab.sp)
  1502.     draw_current_and_max_values(x + 32, y, width - 32, actor.sp, actor.maxsp,
  1503.       sp_color(actor), normal_color)
  1504.   end
  1505.   #--------------------------------------------------------------------------
  1506.   # ● 描画数值键对
  1507.   #     key  : 数值键名
  1508.   #     value: 数值
  1509.   #     ref  : 参考数值
  1510.   #--------------------------------------------------------------------------
  1511.   def draw_key_value_pair(x, y, key, value, ref = nil, width = 136)
  1512.     key_width = text_size(key).width + 8
  1513.     change_color(system_color)
  1514.     draw_text(x, y, key_width, line_height, key)
  1515.     change_color(param_change_color(value - (ref || value)))
  1516.     draw_text(x + key_width, y, width - key_width, line_height, value.to_s, 2)
  1517.   end
  1518.   #--------------------------------------------------------------------------
  1519.   # ● 描绘能力值
  1520.   #     type  : 能力值种类 (0~6)
  1521.   #--------------------------------------------------------------------------
  1522.   def draw_actor_parameter(actor, x, y, type, width = 156)
  1523.     symbol = [:atk, :pdef, :mdef, :str, :dex, :agi, :int][type]
  1524.     parameter_name = Vocab.send(symbol)
  1525.     parameter_value = actor.send(symbol)
  1526.     draw_key_value_pair(x, y, parameter_name, parameter_value, nil, width)
  1527.   end
  1528.   #--------------------------------------------------------------------------
  1529.   # ● 描绘物品名
  1530.   #     item : 物品
  1531.   #     enabled : 是否可用
  1532.   #--------------------------------------------------------------------------
  1533.   def draw_item_name(item, x, y, enabled = true, width = 240)
  1534.     return unless item
  1535.     draw_icon(item.icon_name, x, y, enabled)
  1536.     change_color(normal_color, enabled)
  1537.     x += ICON_WIDTH + ICON_PADDING
  1538.     draw_text(x, y, width - ICON_WIDTH - ICON_PADDING, line_height, item.name)
  1539.   end
  1540.   #--------------------------------------------------------------------------
  1541.   # ● 描绘金钱数目
  1542.   #--------------------------------------------------------------------------
  1543.   def draw_currency_value(value, unit, x, y, width)
  1544.     cx = text_size(unit).width
  1545.     change_color(normal_color)
  1546.     draw_text(x, y, width - cx - 2, line_height, value, 2)
  1547.     change_color(system_color)
  1548.     draw_text(x, y, width, line_height, unit, 2)
  1549.   end
  1550. end

  1551. #==============================================================================
  1552. # ■ Window_Handler
  1553. #------------------------------------------------------------------------------
  1554. #  窗口的激活和按键事件处理模块,被Window_Selectable和Window_Numeric共同引用。
  1555. #==============================================================================
  1556. module Window_Handler
  1557.   include Input
  1558.   #--------------------------------------------------------------------------
  1559.   # ● 定义实例变量
  1560.   #--------------------------------------------------------------------------
  1561.   attr_reader   :handler                  # 按键/事件处理钩子
  1562.   #--------------------------------------------------------------------------
  1563.   # ● 注入按键/事件处理
  1564.   #--------------------------------------------------------------------------
  1565.   def set_handler(key, method)
  1566.     method ? @handler[key] = method : reset_handler(key)
  1567.   end
  1568.   #--------------------------------------------------------------------------
  1569.   # ● 取消按键/事件处理
  1570.   #--------------------------------------------------------------------------
  1571.   def reset_handler(key)
  1572.     @handler.delete(key)
  1573.   end
  1574.   #--------------------------------------------------------------------------
  1575.   # ● 触发按键/事件处理
  1576.   #--------------------------------------------------------------------------
  1577.   def call_handler(key, *args)
  1578.     if @handler[key]
  1579.       @handler[key].call(*args)
  1580.       Input.update unless key.is_a?(Symbol)
  1581.     end
  1582.   end
  1583.   #--------------------------------------------------------------------------
  1584.   # ● 事件处理判定
  1585.   #--------------------------------------------------------------------------
  1586.   def handled?(key)
  1587.     @handler.has_key?(key)
  1588.   end
  1589.   #--------------------------------------------------------------------------
  1590.   # ● 更新光标输入
  1591.   #--------------------------------------------------------------------------
  1592.   def update_cursor
  1593.     update_up   (Input.trigger?(UP   )) if Input.repeat?(UP   )
  1594.     update_down (Input.trigger?(DOWN )) if Input.repeat?(DOWN )
  1595.     update_left (Input.trigger?(LEFT )) if Input.repeat?(LEFT )
  1596.     update_right(Input.trigger?(RIGHT)) if Input.repeat?(RIGHT)
  1597.     update_pageup   if Input.repeat?(L) and not handled?(L)
  1598.     update_pagedown if Input.repeat?(R) and not handled?(R)
  1599.   end
  1600.   #--------------------------------------------------------------------------
  1601.   # ● 设置按键输入
  1602.   #--------------------------------------------------------------------------
  1603.   def update_keypress
  1604.     update_cursor if cursor_respond?
  1605.     [A, B, C, X, Y, Z, L, R, F5, F6, F7, F8, F9, CTRL, ALT, SHIFT].each do |k|
  1606.       call_handler(k) if Input.trigger?(k)
  1607.     end
  1608.   end
  1609. end

  1610. #==============================================================================
  1611. # ■ Window_Selectable
  1612. #==============================================================================
  1613. class Window_Selectable
  1614.   include Window_Handler
  1615.   #--------------------------------------------------------------------------
  1616.   # ● 定义实例变量
  1617.   #--------------------------------------------------------------------------
  1618.   attr_reader   :item_max
  1619.   #--------------------------------------------------------------------------
  1620.   # ● 方法重定义
  1621.   #--------------------------------------------------------------------------
  1622.   unless method_defined?(:sailcat_windowcore_initialize)
  1623.     alias sailcat_windowcore_initialize initialize
  1624.     alias sailcat_windowcore_index= index=
  1625.     alias sailcat_windowcore_update_cursor_rect update_cursor_rect
  1626.   end
  1627.   #--------------------------------------------------------------------------
  1628.   # ● 初始化对像
  1629.   #     x      : 窗口的 X 坐标
  1630.   #     y      : 窗口的 Y 坐标
  1631.   #     width  : 窗口的宽
  1632.   #     height : 窗口的高
  1633.   #--------------------------------------------------------------------------
  1634.   def initialize(x, y, width, height)
  1635.     sailcat_windowcore_initialize(x, y, width, height)
  1636.     @handler = {}
  1637.   end
  1638.   #--------------------------------------------------------------------------
  1639.   # ● 设置光标的位置
  1640.   #     index : 新的光标位置
  1641.   #--------------------------------------------------------------------------
  1642.   def index=(index)
  1643.     need_call = (@index != index and self.active)
  1644.     self.sailcat_windowcore_index = index
  1645.     call_handler(:index_changed) if need_call
  1646.   end
  1647.   #--------------------------------------------------------------------------
  1648.   # ● 设置可见性
  1649.   #--------------------------------------------------------------------------
  1650.   def visible=(visible)
  1651.     need_call = self.visible != visible
  1652.     super
  1653.     call_handler(:visible_changed) if need_call
  1654.   end
  1655.   #--------------------------------------------------------------------------
  1656.   # ● 设置启用性
  1657.   #--------------------------------------------------------------------------
  1658.   def active=(active)
  1659.     call_handler(active ? :activated : :deactivated) if self.active != active
  1660.     super
  1661.     update_help if self.active and @help_window
  1662.   end
  1663.   #--------------------------------------------------------------------------
  1664.   # ● 获取开头行
  1665.   #--------------------------------------------------------------------------
  1666.   def top_row
  1667.     self.oy / item_height
  1668.   end
  1669.   #--------------------------------------------------------------------------
  1670.   # ● 设置开头行
  1671.   #     row : 显示开头的行
  1672.   #--------------------------------------------------------------------------
  1673.   def top_row=(row)
  1674.     # 窗口未开启时不调整
  1675.     return if self.openness < 255
  1676.     # row 未满 0 的场合更正为 0
  1677.     if row < 0
  1678.       row = 0
  1679.     end
  1680.     # row 超过 row_max - 1 的情况下更正为 row_max - 1
  1681.     if row > row_max - 1
  1682.       row = row_max - 1
  1683.     end
  1684.     self.oy = row * item_height
  1685.   end
  1686.   #--------------------------------------------------------------------------
  1687.   # ● 获取 1 页可以显示的行数
  1688.   #--------------------------------------------------------------------------
  1689.   def page_row_max
  1690.     (self.height - 32) / item_height
  1691.   end
  1692.   #--------------------------------------------------------------------------
  1693.   # ● 建立内容
  1694.   #--------------------------------------------------------------------------
  1695.   def create_contents
  1696.     contents.dispose if contents
  1697.     self.contents = Bitmap.new(width - 32, row_max * item_height)
  1698.   end
  1699.   #--------------------------------------------------------------------------
  1700.   # ● 获取光标间距
  1701.   #--------------------------------------------------------------------------
  1702.   def cursor_padding
  1703.     CURSOR_PADDING
  1704.   end
  1705.   #--------------------------------------------------------------------------
  1706.   # ● 获取列宽
  1707.   #--------------------------------------------------------------------------
  1708.   def column_width
  1709.     (self.width - cursor_padding * (@column_max - 1) - 32) / @column_max
  1710.   end
  1711.   #--------------------------------------------------------------------------
  1712.   # ● 获取数据项高
  1713.   #--------------------------------------------------------------------------
  1714.   def item_height
  1715.     line_height(1)
  1716.   end
  1717.   #--------------------------------------------------------------------------
  1718.   # ● 获取数据项矩形
  1719.   #--------------------------------------------------------------------------
  1720.   def item_rect(index)
  1721.     x = index % @column_max * (column_width + cursor_padding)
  1722.     y = index / @column_max * item_height
  1723.     Rect.new(x, y, column_width, item_height)
  1724.   end
  1725.   #--------------------------------------------------------------------------
  1726.   # ● 更新光标矩形
  1727.   #--------------------------------------------------------------------------
  1728.   def update_cursor_rect
  1729.     sailcat_windowcore_update_cursor_rect
  1730.     # 更新光标矩形
  1731.     self.cursor_rect = item_rect(@index).offset(0, -self.oy) if @index >= 0
  1732.   end
  1733.   #--------------------------------------------------------------------------
  1734.   # ● 光标有效判定
  1735.   #--------------------------------------------------------------------------
  1736.   def cursor_respond?
  1737.     @item_max > 0 and @index >= 0
  1738.   end
  1739.   #--------------------------------------------------------------------------
  1740.   # ● 刷新画面
  1741.   #--------------------------------------------------------------------------
  1742.   def update
  1743.     super
  1744.     update_keypress if self.active
  1745.   end
  1746.   #--------------------------------------------------------------------------
  1747.   # ● 方向键处理
  1748.   #--------------------------------------------------------------------------
  1749.   def update_up(force);     update_index(8, force);                       end
  1750.   def update_down(force);   update_index(2, force);                       end
  1751.   def update_left(force);   update_index(4, force);                       end
  1752.   def update_right(force);  update_index(6, force);                       end
  1753.   #--------------------------------------------------------------------------
  1754.   # ● L键处理
  1755.   #--------------------------------------------------------------------------
  1756.   def update_pageup
  1757.     if Input.press?(CTRL)
  1758.       self.index = 0
  1759.     else
  1760.       scroll_page(top_row > 0 ? -1 : 0)
  1761.     end
  1762.   end
  1763.   #--------------------------------------------------------------------------
  1764.   # ● R键处理
  1765.   #--------------------------------------------------------------------------
  1766.   def update_pagedown
  1767.     if Input.press?(CTRL)
  1768.       self.index = @item_max - 1
  1769.     else
  1770.       scroll_page(top_row + page_row_max - 1 < row_max - 1 ? 1 : 0)
  1771.     end
  1772.   end
  1773.   #--------------------------------------------------------------------------
  1774.   # ● 更新移动位置
  1775.   #--------------------------------------------------------------------------
  1776.   def update_index(dir, force)
  1777.     step = dir == 2 ? @column_max : (dir == 8 ? -@column_max : dir - 5)
  1778.     columns = 2 - ((dir - 5).abs >> 1)
  1779.     if @column_max >= columns and (force or valid?(step))
  1780.       step += @item_max if step < 0
  1781.       $game_system.se_play($data_system.cursor_se)
  1782.       self.index = (@index + step) % @item_max
  1783.     end
  1784.   end
  1785.   #--------------------------------------------------------------------------
  1786.   # ● 有效移动判定
  1787.   #--------------------------------------------------------------------------
  1788.   def valid?(offset)
  1789.     @index + offset >= 0 and @index + offset < @item_max
  1790.   end
  1791.   #--------------------------------------------------------------------------
  1792.   # ● 翻页处理
  1793.   #--------------------------------------------------------------------------
  1794.   def scroll_page(value)
  1795.     return if value == 0
  1796.     $game_system.se_play($data_system.cursor_se)
  1797.     self.top_row += page_row_max * value
  1798.     self.index = (@index + page_item_max * value).limit(0, @item_max - 1)
  1799.   end
  1800. end

  1801. #==============================================================================
  1802. # ■ Window_Command
  1803. #==============================================================================
  1804. class Window_Command
  1805.   #--------------------------------------------------------------------------
  1806.   # ● 初始化对像
  1807.   #     width    : 窗口的宽
  1808.   #     commands : 命令字符串序列
  1809.   #--------------------------------------------------------------------------
  1810.   def initialize(width, commands)
  1811.     # 由命令的个数计算出窗口的高
  1812.     super(0, 0, width, window_h(commands.size))
  1813.     @item_max = commands.size
  1814.     @commands = commands
  1815.     create_contents
  1816.     refresh
  1817.     self.index = 0
  1818.   end
  1819.   #--------------------------------------------------------------------------
  1820.   # ● 描绘项目
  1821.   #     index : 项目编号
  1822.   #     color : 文字色
  1823.   #--------------------------------------------------------------------------
  1824.   def draw_item(index, color)
  1825.     change_color(color)
  1826.     rect = item_rect(index).inflate(-4, 0)
  1827.     contents.clear_rect(rect)
  1828.     draw_text(rect, @commands[index])
  1829.   end
  1830. end


  1831. #==============================================================================
  1832. # ■ Window_HorzCommand
  1833. #------------------------------------------------------------------------------
  1834. #  水平排列的命令窗口。
  1835. #==============================================================================
  1836. class Window_HorzCommand < Window_Selectable
  1837.   #--------------------------------------------------------------------------
  1838.   # ● 初始化对像
  1839.   #--------------------------------------------------------------------------
  1840.   def initialize(width, commands)
  1841.     super(0, 0, width, window_h)
  1842.     @item_max = @column_max = commands.size
  1843.     @commands = commands
  1844.     create_contents
  1845.     refresh
  1846.     self.index = 0
  1847.   end
  1848.   #--------------------------------------------------------------------------
  1849.   # ● 刷新
  1850.   #--------------------------------------------------------------------------
  1851.   def refresh
  1852.     contents.clear
  1853.     for i in 0...@item_max
  1854.       draw_item(i, system_color)
  1855.     end
  1856.   end
  1857.   #--------------------------------------------------------------------------
  1858.   # ● 描绘项目
  1859.   #     index : 项目编号
  1860.   #     color : 文字色
  1861.   #--------------------------------------------------------------------------
  1862.   def draw_item(index, color)
  1863.     change_color(color)
  1864.     rect = item_rect(index)
  1865.     contents.clear_rect(rect)
  1866.     draw_text(rect, @commands[index], 1)
  1867.   end
  1868.   #--------------------------------------------------------------------------
  1869.   # ● 项目无效化
  1870.   #     index : 项目编号
  1871.   #--------------------------------------------------------------------------
  1872.   def disable_item(index)
  1873.     draw_item(index, disabled_color)
  1874.   end
  1875.   #--------------------------------------------------------------------------
  1876.   # ● 获取光标间距
  1877.   #--------------------------------------------------------------------------
  1878.   def cursor_padding
  1879.     CURSOR_PADDING_HORZCOMMAND
  1880.   end
  1881. end

  1882. #==============================================================================
  1883. # ■ Window_MenuStatus
  1884. #==============================================================================
  1885. class Window_MenuStatus
  1886.   #--------------------------------------------------------------------------
  1887.   # ● 初始化目标
  1888.   #--------------------------------------------------------------------------
  1889.   def initialize
  1890.     super(0, 0, -160, 0)
  1891.     refresh
  1892.     deactivate
  1893.     self.index = -1
  1894.   end
  1895.   #--------------------------------------------------------------------------
  1896.   # ● 获取数据项高
  1897.   #--------------------------------------------------------------------------
  1898.   def item_height
  1899.     [(self.height - 32) / [@item_max, 4].max, line_height(3)].max
  1900.   end
  1901.   #--------------------------------------------------------------------------
  1902.   # ● 刷新
  1903.   #--------------------------------------------------------------------------
  1904.   def refresh
  1905.     @item_max = $game_party.actors.size
  1906.     create_contents
  1907.     draw_actors
  1908.   end
  1909.   #--------------------------------------------------------------------------
  1910.   # ● 绘制角色
  1911.   #--------------------------------------------------------------------------
  1912.   def draw_actors
  1913.     x = 64
  1914.     data_width = column_width - x - 36
  1915.     col1 = [204, data_width >> 1].max
  1916.     col2 = data_width - col1
  1917.     for i in 0...$game_party.actors.size
  1918.       y = i * item_height
  1919.       actor = $game_party.actors[i]
  1920.       draw_actor_graphic(actor, x - 40, y + item_height * 5 / 6)
  1921.       draw_actor_name(actor, x, y)
  1922.       draw_actor_class(actor, x + 144, y, data_width - 112)
  1923.       draw_actor_level(actor, x, y + item_height / 3)
  1924.       draw_actor_state(actor, x + 90, y + item_height / 3, col1 - 90)
  1925.       draw_actor_exp(actor, x, y + item_height * 2 / 3, col1)
  1926.       draw_actor_hp(actor, x + col1 + 32, y + item_height / 3, col2)
  1927.       draw_actor_sp(actor, x + col1 + 32, y + item_height * 2 / 3, col2)
  1928.     end
  1929.   end
  1930.   #--------------------------------------------------------------------------
  1931.   # ● 刷新光标矩形
  1932.   #--------------------------------------------------------------------------
  1933.   def update_cursor_rect
  1934.     super
  1935.   end
  1936. end

  1937. #==============================================================================
  1938. # ■ Window_Data
  1939. #------------------------------------------------------------------------------
  1940. #  显示物品、特技、武器、防具的列表窗口。
  1941. #==============================================================================
  1942. class Window_Data < Window_Selectable
  1943.   #--------------------------------------------------------------------------
  1944.   # ● 初始化对像
  1945.   #--------------------------------------------------------------------------
  1946.   def initialize(x, y, width, height, back_opacity = nil, column_max = 2)
  1947.     super(x, y, width, height)
  1948.     self.back_opacity = back_opacity || BACK_OPACITY_DEFAULT
  1949.     @column_max = column_max
  1950.     refresh
  1951.     self.index = 0
  1952.   end
  1953.   #--------------------------------------------------------------------------
  1954.   # ● 获取物品
  1955.   #--------------------------------------------------------------------------
  1956.   def item
  1957.     return @data[self.index]
  1958.   end
  1959.   #--------------------------------------------------------------------------
  1960.   # ● 刷新
  1961.   #--------------------------------------------------------------------------
  1962.   def refresh
  1963.     make_data
  1964.     @item_max = @data.size
  1965.     if @item_max > 0
  1966.       create_contents
  1967.       @drawn = [false] * @item_max
  1968.       draw_page(top_row * @column_max)
  1969.     else
  1970.       contents.dispose if contents
  1971.       self.contents = nil
  1972.     end
  1973.   end
  1974.   #--------------------------------------------------------------------------
  1975.   # ● 生成数据
  1976.   #--------------------------------------------------------------------------
  1977.   def make_data
  1978.     @data = []
  1979.   end
  1980.   #--------------------------------------------------------------------------
  1981.   # ● 绘制指定页
  1982.   #--------------------------------------------------------------------------
  1983.   def draw_page(index)
  1984.     return if @item_max == 0
  1985.     for i in index...index + page_item_max
  1986.       draw_item(i) if i < @item_max and not @drawn[i]
  1987.     end
  1988.   end
  1989.   #--------------------------------------------------------------------------
  1990.   # ● 翻页更新绘制
  1991.   #--------------------------------------------------------------------------
  1992.   def top_row=(row)
  1993.     super
  1994.     draw_page(row * @column_max) if self.openness == 255
  1995.   end
  1996.   #--------------------------------------------------------------------------
  1997.   # ● 描绘项目
  1998.   #     index : 项目编号
  1999.   #--------------------------------------------------------------------------
  2000.   def draw_item(index)
  2001.     item = @data[index]
  2002.     @drawn[index] = true
  2003.     case item
  2004.     when RPG::Skill
  2005.       number = item.sp_cost
  2006.     when RPG::Item, RPG::Weapon, RPG::Armor
  2007.       number = $game_party.any_number(item)
  2008.     else
  2009.       return
  2010.     end
  2011.     enabled = (@enable_proc == nil or @enable_proc.call(item))
  2012.     rect = item_rect(index).inflate(-4, 0)
  2013.     contents.clear_rect(rect)
  2014.     if item.is_a?(RPG::Skill)
  2015.       draw_item_name(item, rect.x, rect.y, enabled, rect.width - 48)
  2016.       change_color(enabled ? sp_cost_color : disabled_color)
  2017.       draw_text(rect.right - 48, rect.y, 48, item_height, number, 2)
  2018.     else
  2019.       number_width = text_size(ITEM_MAX).width.limit(24, 66) + 16
  2020.       draw_item_name(item, rect.x, rect.y, enabled, rect.width - number_width)
  2021.       draw_text(rect.right - number_width, rect.y, 16, item_height, ":", 1)
  2022.       draw_text(rect.right - number_width + 16, rect.y,
  2023.         number_width - 16, item_height, number, 2)
  2024.     end
  2025.   end
  2026.   #--------------------------------------------------------------------------
  2027.   # ● 刷新帮助文本
  2028.   #--------------------------------------------------------------------------
  2029.   def update_help
  2030.     @help_window.set_text(self.item == nil ? "" : self.item.description)
  2031.   end
  2032. end

  2033. #==============================================================================
  2034. # ■ Window_Item
  2035. #==============================================================================
  2036. class Window_Item < Window_Data
  2037.   #--------------------------------------------------------------------------
  2038.   # ● 初始化对像
  2039.   #--------------------------------------------------------------------------
  2040.   def initialize
  2041.     if $game_temp.in_battle
  2042.       super(0, window_h, 0, -window_h - window_h(4), BACK_OPACITY_IN_BATTLE)
  2043.     else
  2044.       super(0, window_h, 0, -window_h)
  2045.     end
  2046.   end
  2047.   #--------------------------------------------------------------------------
  2048.   # ● 生成数据
  2049.   #--------------------------------------------------------------------------
  2050.   def make_data
  2051.     super
  2052.     @data = $game_party.send($game_temp.in_battle ? :sorted_items : :all_items)
  2053.     @enable_proc = Proc.new {|item|
  2054.       item.is_a?(RPG::Item) and $game_party.item_can_use?(item.id)}
  2055.   end
  2056. end

  2057. #==============================================================================
  2058. # ■ Window_Skill
  2059. #==============================================================================
  2060. class Window_Skill < Window_Data
  2061.   #--------------------------------------------------------------------------
  2062.   # ● 初始化对像
  2063.   #--------------------------------------------------------------------------
  2064.   def initialize(actor)
  2065.     @actor = actor
  2066.     if $game_temp.in_battle
  2067.       super(0, window_h, 0, -window_h - window_h(4), BACK_OPACITY_IN_BATTLE)
  2068.     else
  2069.       super(0, window_h << 1, 0, -window_h << 1)
  2070.     end
  2071.   end
  2072.   #--------------------------------------------------------------------------
  2073.   # ● 生成数据
  2074.   #--------------------------------------------------------------------------
  2075.   def make_data
  2076.     super
  2077.     @data.concat(@actor.learned_skills)
  2078.     @enable_proc = Proc.new {|skill| @actor.skill_can_use?(skill.id)}
  2079.   end
  2080.   #--------------------------------------------------------------------------
  2081.   # ● 获取选中的特技
  2082.   #--------------------------------------------------------------------------
  2083.   def skill
  2084.     item
  2085.   end
  2086. end

  2087. #==============================================================================
  2088. # ■ Window_Target
  2089. #==============================================================================
  2090. class Window_Target
  2091.   #--------------------------------------------------------------------------
  2092.   # ● 初始化对像
  2093.   #--------------------------------------------------------------------------
  2094.   def initialize
  2095.     super(0, 0, (SCREEN_W + CURSOR_PADDING) >> 1, 0)
  2096.     self.back_opacity = 255
  2097.     self.z += 10
  2098.     refresh
  2099.   end
  2100.   #--------------------------------------------------------------------------
  2101.   # ● 获取数据项高
  2102.   #--------------------------------------------------------------------------
  2103.   def item_height
  2104.     [(self.height - 32) / [@item_max, 4].max, line_height(3)].max
  2105.   end
  2106.   #--------------------------------------------------------------------------
  2107.   # ● 刷新
  2108.   #--------------------------------------------------------------------------
  2109.   def refresh
  2110.     @item_max = $game_party.actors.size
  2111.     create_contents
  2112.     draw_actors
  2113.   end
  2114.   #--------------------------------------------------------------------------
  2115.   # ● 绘制角色
  2116.   #--------------------------------------------------------------------------
  2117.   def draw_actors
  2118.     col = (column_width - 16) >> 1
  2119.     for i in 0...$game_party.actors.size
  2120.       x = 4
  2121.       y = i * item_height
  2122.       actor = $game_party.actors[i]
  2123.       draw_actor_name(actor, x, y, col)
  2124.       draw_actor_class(actor, x + col, y, col + 8)
  2125.       draw_actor_level(actor, x + 8, y + item_height / 3)
  2126.       draw_actor_state(actor, x + 8, y + item_height * 2 / 3, col)
  2127.       draw_actor_hp(actor, x + 8 + col, y + item_height / 3, col)
  2128.       draw_actor_sp(actor, x + 8 + col, y + item_height * 2 / 3, col)
  2129.     end
  2130.   end
  2131.   #--------------------------------------------------------------------------
  2132.   # ● 刷新光标矩形
  2133.   #--------------------------------------------------------------------------
  2134.   def update_cursor_rect
  2135.     if @index <= -2
  2136.       y = (@index + TARGET_SELF_OFFSET_DEFAULT) * item_height
  2137.       if @index < self.top_row
  2138.         self.top_row = @index
  2139.       elsif @index > self.top_row + (self.page_row_max - 1)
  2140.         self.top_row = @index - (self.page_row_max - 1)
  2141.       end
  2142.       cursor_rect.set(0, y - self.oy, column_width, line_height)
  2143.     elsif @index == -1
  2144.       cursor_rect.set(0, 0, contents.width, contents.height)
  2145.     else
  2146.       super
  2147.     end
  2148.   end
  2149. end

  2150. #==============================================================================
  2151. # ■ Window_EquipRight
  2152. #==============================================================================
  2153. class Window_EquipRight < Window_Data
  2154.   #--------------------------------------------------------------------------
  2155.   # ● 初始化对像
  2156.   #     actor : 角色
  2157.   #--------------------------------------------------------------------------
  2158.   def initialize(actor)
  2159.     @actor = actor
  2160.     width = [368, SCREEN_W >> 1].max
  2161.     super(SCREEN_W - width, window_h, width, window_h(5), nil, 1)
  2162.   end
  2163.   #--------------------------------------------------------------------------
  2164.   # ● 生成数据
  2165.   #--------------------------------------------------------------------------
  2166.   def make_data
  2167.     super
  2168.     @data.concat(@actor.all_equipment)
  2169.   end
  2170.   #--------------------------------------------------------------------------
  2171.   # ● 描绘项目
  2172.   #     index : 项目编号
  2173.   #--------------------------------------------------------------------------
  2174.   def draw_item(index)
  2175.     item = @data[index]
  2176.     word = Vocab.send([:weapon, :armor1, :armor2, :armor3, :armor4][index])
  2177.     change_color(system_color)
  2178.     draw_text(4, item_height * index, 92, item_height, word)
  2179.     draw_item_name(item, 92, item_height * index,
  2180.       !@actor.equip_fix?(index), column_width - 100)
  2181.   end
  2182. end

  2183. #==============================================================================
  2184. # ■ Window_EquipItem
  2185. #==============================================================================
  2186. class Window_EquipItem < Window_Data
  2187.   #--------------------------------------------------------------------------
  2188.   # ● 初始化对像
  2189.   #     actor      : 角色
  2190.   #     equip_type : 装备部位 (0~3)
  2191.   #--------------------------------------------------------------------------
  2192.   def initialize(actor, equip_type)
  2193.     @actor = actor
  2194.     @equip_type = equip_type
  2195.     super(0, window_h + window_h(5), 0, -window_h - window_h(5))
  2196.     self.active = false
  2197.     self.index = -1
  2198.   end
  2199.   #--------------------------------------------------------------------------
  2200.   # ● 生成数据
  2201.   #--------------------------------------------------------------------------
  2202.   def make_data
  2203.     super
  2204.     # 添加可以装备的武器
  2205.     if @equip_type == 0
  2206.       weapon_set = $data_classes[@actor.class_id].weapon_set
  2207.       @data.push($game_party.sorted_weapons.select do |weapon|
  2208.         weapon_set.include?(weapon.id)
  2209.       end)
  2210.     end
  2211.     # 添加可以装备的防具
  2212.     if @equip_type != 0
  2213.       armor_set = $data_classes[@actor.class_id].armor_set
  2214.       @data.push($game_party.sorted_armors.select do |armor|
  2215.         armor_set.include?(armor.id) and armor.kind == @equip_type - 1
  2216.       end)
  2217.     end
  2218.     # 添加空白
  2219.     @data.push(nil)
  2220.   end
  2221. end

  2222. #==============================================================================
  2223. # ■ Window_ShopCommand
  2224. #==============================================================================
  2225. class Window_ShopCommand < Window_HorzCommand
  2226.   #--------------------------------------------------------------------------
  2227.   # ● 初始化对像
  2228.   #--------------------------------------------------------------------------
  2229.   def initialize
  2230.     super(SCREEN_W - 160, [Vocab.buy, Vocab.sell, Vocab.cancel])
  2231.     moveto(0, window_h)
  2232.   end
  2233. end

  2234. #==============================================================================
  2235. # ■ Window_ShopBuy
  2236. #==============================================================================
  2237. class Window_ShopBuy < Window_Data
  2238.   #--------------------------------------------------------------------------
  2239.   # ● 初始化对像
  2240.   #     shop_goods : 商品
  2241.   #--------------------------------------------------------------------------
  2242.   def initialize(shop_goods)
  2243.     @shop_goods = shop_goods
  2244.     width = [368, SCREEN_W >> 1].max
  2245.     super(0, window_h << 1, width, -window_h << 1, nil, 1)
  2246.   end
  2247.   #--------------------------------------------------------------------------
  2248.   # ● 生成数据
  2249.   #--------------------------------------------------------------------------
  2250.   def make_data
  2251.     super
  2252.     sets = [$data_items, $data_weapons, $data_armors]
  2253.     @data.concat(@shop_goods.map {|i| sets[i[0]][i[1]]}).compact!
  2254.     @enable_proc = Proc.new {|item| item.price <= $game_party.gold and
  2255.       (!ITEM_MAX or $game_party.any_number(item) < ITEM_MAX)}
  2256.   end
  2257.   #--------------------------------------------------------------------------
  2258.   # ● 描绘项目
  2259.   #     index : 项目编号
  2260.   #--------------------------------------------------------------------------
  2261.   def draw_item(index)
  2262.     item = @data[index]
  2263.     number = item.price
  2264.     enabled = @enable_proc.call(item)
  2265.     rect = item_rect(index).inflate(-4, 0)
  2266.     contents.clear_rect(rect)
  2267.     draw_item_name(item, rect.x, rect.y, enabled, rect.width - 88)
  2268.     draw_text(rect.right - 88, rect.y, 88, item_height, number.to_s, 2)
  2269.   end
  2270. end

  2271. #==============================================================================
  2272. # ■ Window_ShopSell
  2273. #==============================================================================
  2274. class Window_ShopSell < Window_Data
  2275.   #--------------------------------------------------------------------------
  2276.   # ● 初始化对像
  2277.   #--------------------------------------------------------------------------
  2278.   def initialize
  2279.     super(0, window_h << 1, 0, -window_h << 1)
  2280.   end
  2281.   #--------------------------------------------------------------------------
  2282.   # ● 生成数据
  2283.   #--------------------------------------------------------------------------
  2284.   def make_data
  2285.     super
  2286.     @data.concat($game_party.all_items)
  2287.     @enable_proc = Proc.new {|item| item.price > 0}
  2288.   end
  2289. end

  2290. #==============================================================================
  2291. # ■ Window_Message
  2292. #==============================================================================
  2293. class Window_Message
  2294.   #--------------------------------------------------------------------------
  2295.   # ● 初始化状态
  2296.   #--------------------------------------------------------------------------
  2297.   def initialize
  2298.     super(80, SCREEN_H - window_h(4) - 16, SCREEN_W - 160, window_h(4))
  2299.     create_contents
  2300.     hide
  2301.     self.z = 9998
  2302.     @fade_in = false
  2303.     @fade_out = false
  2304.     @contents_showing = false
  2305.     @cursor_width = 0
  2306.     deactivate
  2307.     self.index = -1
  2308.   end
  2309.   #--------------------------------------------------------------------------
  2310.   # ● 建立内容
  2311.   #--------------------------------------------------------------------------
  2312.   def create_contents
  2313.     contents.dispose if contents
  2314.     self.contents = Bitmap.new(width - 32, height - 32)
  2315.   end
  2316.   #--------------------------------------------------------------------------
  2317.   # ● 刷新
  2318.   #--------------------------------------------------------------------------
  2319.   def refresh
  2320.     contents.clear
  2321.     x = $game_temp.choice_start == 0 ? 8 : 0
  2322.     y = 0
  2323.     @cursor_width = 0
  2324.     @lines = 0
  2325.     # 有等待显示的文字的情况下
  2326.     if $game_temp.message_text != nil
  2327.       draw_text_ex(4 + x, y, $game_temp.message_text)
  2328.     end
  2329.     # 选择项的情况
  2330.     if $game_temp.choice_max > 0
  2331.       @item_max = $game_temp.choice_max
  2332.       activate
  2333.       self.index = 0
  2334.     end
  2335.     # 输入数值的情况
  2336.     make_input_number_window if $game_temp.num_input_variable_id > 0
  2337.   end
  2338.   #--------------------------------------------------------------------------
  2339.   # ● 折行处理
  2340.   #--------------------------------------------------------------------------
  2341.   def process_new_line(text, pos)
  2342.     @lines += 1
  2343.     # 刷新选择项及光标的高
  2344.     if @lines == $game_temp.choice_start
  2345.       pos[2] += 8
  2346.     elsif @lines > $game_temp.choice_start
  2347.       @cursor_width = [@cursor_width, pos[0]].max - 4
  2348.     end
  2349.     super
  2350.   end
  2351.   #--------------------------------------------------------------------------
  2352.   # ● 处理控制字符
  2353.   #     code : 控制命令符
  2354.   #--------------------------------------------------------------------------
  2355.   def process_escape_character(code, text, pos)
  2356.     super
  2357.     case code.upcase
  2358.     when 'G'
  2359.       make_gold_window
  2360.     end
  2361.   end
  2362.   #--------------------------------------------------------------------------
  2363.   # ● 生成金钱窗口
  2364.   #--------------------------------------------------------------------------
  2365.   def make_gold_window
  2366.     return if @gold_window
  2367.     @gold_window = Window_Gold.new
  2368.     @gold_window.x = SCREEN_W - 80 - @gold_window.width
  2369.     if $game_temp.in_battle
  2370.       @gold_window.y = (SCREEN_H >> 1) - @gold_window.height + 16
  2371.     else
  2372.       @gold_window.y = self.y >= 128 ? 32 : SCREEN_H - @gold_window.height - 32
  2373.     end
  2374.     @gold_window.opacity = self.opacity
  2375.     @gold_window.back_opacity = self.back_opacity
  2376.   end
  2377.   #--------------------------------------------------------------------------
  2378.   # ● 生成数值输入窗口
  2379.   #--------------------------------------------------------------------------
  2380.   def make_input_number_window
  2381.     digits_max = $game_temp.num_input_digits_max
  2382.     number = $game_variables[$game_temp.num_input_variable_id]
  2383.     @input_number_window = Window_InputNumber.new(digits_max)
  2384.     @input_number_window.number = number
  2385.     @input_number_window.x = self.x - 8
  2386.     @input_number_window.y = self.y + line_height($game_temp.num_input_start)
  2387.   end
  2388.   #--------------------------------------------------------------------------
  2389.   # ● 设置窗口位置与不透明度
  2390.   #--------------------------------------------------------------------------
  2391.   def reset_window
  2392.     if $game_temp.in_battle
  2393.       self.y = 16
  2394.     else
  2395.       case $game_system.message_position
  2396.       when 0  # 上
  2397.         self.y = 16
  2398.       when 1  # 中
  2399.         self.y = (SCREEN_H - self.height) >> 1
  2400.       when 2  # 下
  2401.         self.y = SCREEN_H - self.height - 16
  2402.       end
  2403.     end
  2404.     self.opacity = $game_system.message_frame == 0 ? 255 : 0
  2405.     self.back_opacity = 160
  2406.   end
  2407.   #--------------------------------------------------------------------------
  2408.   # ● 刷新光标矩形
  2409.   #--------------------------------------------------------------------------
  2410.   def update_cursor_rect
  2411.     if @index >= 0
  2412.       n = $game_temp.choice_start + @index
  2413.       self.cursor_rect.set(8, line_height(n), @cursor_width, line_height)
  2414.     else
  2415.       self.cursor_rect.empty
  2416.     end
  2417.   end
  2418. end

  2419. #==============================================================================
  2420. # ■ Window_PartyCommand
  2421. #==============================================================================
  2422. class Window_PartyCommand < Window_HorzCommand
  2423.   #--------------------------------------------------------------------------
  2424.   # ● 初始化对像
  2425.   #--------------------------------------------------------------------------
  2426.   def initialize
  2427.     super(SCREEN_W, [Vocab.fight, Vocab.escape])
  2428.     self.back_opacity = BACK_OPACITY_IN_BATTLE
  2429.     @column_max = 4
  2430.     contents.clear
  2431.     draw_item(0, normal_color)
  2432.     draw_item(1, $game_temp.battle_can_escape ? normal_color : disabled_color)
  2433.     update_cursor_rect
  2434.     deactivate
  2435.     hide
  2436.   end
  2437.   #--------------------------------------------------------------------------
  2438.   # ● 描绘项目
  2439.   #     index : 项目标号
  2440.   #     color : 文字颜色
  2441.   #--------------------------------------------------------------------------
  2442.   def draw_item(index, color)
  2443.     change_color(color)
  2444.     rect = item_rect(index + 1).inflate(-4, 0)
  2445.     contents.clear_rect(rect)
  2446.     draw_text(rect, @commands[index], 1)
  2447.   end
  2448.   #--------------------------------------------------------------------------
  2449.   # ● 更新光标矩形
  2450.   #--------------------------------------------------------------------------
  2451.   def update_cursor_rect
  2452.     self.cursor_rect = item_rect(@index + 1)
  2453.   end
  2454. end

  2455. #==============================================================================
  2456. # ■ Window_DebugLeft
  2457. #==============================================================================
  2458. class Window_DebugLeft
  2459.   #--------------------------------------------------------------------------
  2460.   # ● 初始化对像
  2461.   #--------------------------------------------------------------------------
  2462.   def initialize
  2463.     super(0, 0, 192, 0)
  2464.     @step = (SCREEN_H - window_h(3) - 32) / item_height
  2465.     @switch_max = ($data_system.switches.size + @step - 2) / @step
  2466.     @variable_max = ($data_system.variables.size + @step - 2) / @step
  2467.     @item_max = @switch_max + @variable_max
  2468.     create_contents
  2469.     refresh
  2470.   end
  2471.   #--------------------------------------------------------------------------
  2472.   # ● 刷新
  2473.   #--------------------------------------------------------------------------
  2474.   def refresh
  2475.     contents.clear
  2476.     @switch_max.times do |i|
  2477.       text = sprintf("S [%04d-%04d]", i * @step + 1, (i + 1) * @step)
  2478.       draw_text(item_rect(i).inflate(-4, 0), text)
  2479.     end
  2480.     @variable_max.times do |i|
  2481.       text = sprintf("V [%04d-%04d]", i * @step + 1, (i + 1) * @step)
  2482.       draw_text(item_rect(i + @switch_max).inflate(-4, 0), text)
  2483.     end
  2484.   end
  2485.   #--------------------------------------------------------------------------
  2486.   # ● 获取开头显示的 ID
  2487.   #--------------------------------------------------------------------------
  2488.   def top_id
  2489.     if self.index < @switch_max
  2490.       self.index * @step + 1
  2491.     else
  2492.       (self.index - @switch_max) * @step + 1
  2493.     end
  2494.   end
  2495. end

  2496. #==============================================================================
  2497. # ■ Window_DebugRight
  2498. #==============================================================================
  2499. class Window_DebugRight
  2500.   #--------------------------------------------------------------------------
  2501.   # ● 定义实例变量
  2502.   #--------------------------------------------------------------------------
  2503.   attr_reader   :mode                     # 模式 (0:开关、1:变量)
  2504.   attr_reader   :top_id                   # 开头显示的 ID
  2505.   #--------------------------------------------------------------------------
  2506.   # ● 初始化对像
  2507.   #--------------------------------------------------------------------------
  2508.   def initialize
  2509.     super(192, 0, -192, -window_h(3))
  2510.     deactivate
  2511.     @mode = 0
  2512.     @top_id = 1
  2513.     @item_max = page_row_max
  2514.     create_contents
  2515.     refresh
  2516.     self.index = -1
  2517.   end
  2518.   #--------------------------------------------------------------------------
  2519.   # ● 刷新
  2520.   #--------------------------------------------------------------------------
  2521.   def refresh
  2522.     contents.clear
  2523.     for i in 0..page_row_max
  2524.       if @mode == 0
  2525.         name = $data_system.switches[@top_id + i].to_s
  2526.         status = $game_switches[@top_id + i] ? "[ON]" : "[OFF]"
  2527.       else
  2528.         name = $data_system.variables[@top_id + i].to_s
  2529.         status = $game_variables[@top_id + i].to_s
  2530.       end
  2531.       id_text = sprintf("%04d:", @top_id + i)
  2532.       width = text_size(id_text).width
  2533.       rect = item_rect(i).inflate(-4, 0)
  2534.       x = rect.x
  2535.       y = rect.y
  2536.       draw_text(x, y, width, item_height, id_text)
  2537.       draw_text(x + width, y, rect.right - width - 100, item_height, name)
  2538.       draw_text(rect.right - 100, y, 100, item_height, status, 2)
  2539.     end
  2540.   end
  2541.   #--------------------------------------------------------------------------
  2542.   # ● 左键处理
  2543.   #--------------------------------------------------------------------------
  2544.   def update_left(force)
  2545.     $scene.set_variable(@top_id + @index, -1) if @mode == 1
  2546.   end
  2547.   #--------------------------------------------------------------------------
  2548.   # ● 右键处理
  2549.   #--------------------------------------------------------------------------
  2550.   def update_right(force)
  2551.     $scene.set_variable(@top_id + @index, +1) if @mode == 1
  2552.   end
  2553.   #--------------------------------------------------------------------------
  2554.   # ● L键处理
  2555.   #--------------------------------------------------------------------------
  2556.   def update_pageup
  2557.     $scene.set_variable(@top_id + @index, +10) if @mode == 1
  2558.   end
  2559.   #--------------------------------------------------------------------------
  2560.   # ● R键处理
  2561.   #--------------------------------------------------------------------------
  2562.   def update_pagedown
  2563.     $scene.set_variable(@top_id + @index, -10) if @mode == 1
  2564.   end
  2565. end

  2566. #==============================================================================
  2567. # ■ Window_Help
  2568. #==============================================================================
  2569. class Window_Help
  2570.   #--------------------------------------------------------------------------
  2571.   # ● 初始化对像
  2572.   #--------------------------------------------------------------------------
  2573.   def initialize
  2574.     super(0, 0, 0, window_h)
  2575.     create_contents
  2576.   end
  2577.   #--------------------------------------------------------------------------
  2578.   # ● 设置文本
  2579.   #     text  : 窗口显示的字符串
  2580.   #     align : 对齐方式 (0..左对齐、1..中间对齐、2..右对齐)
  2581.   #--------------------------------------------------------------------------
  2582.   def set_text(text, align = 0)
  2583.     # 如果文本和对齐方式的至少一方与上次的不同
  2584.     if text != @text or align != @align
  2585.       # 再描绘文本
  2586.       contents.clear
  2587.       reset_font_settings
  2588.       if text.escaped?
  2589.         if align == 0
  2590.           draw_text_ex(4, 0, text)
  2591.         else
  2592.           width = calc_text_width(convert_escape_characters(text))
  2593.           if align == 1
  2594.             draw_text_ex((contents.width - width) >> 1, 0, text)
  2595.           else
  2596.             draw_text_ex((contents.width - width - 4), 0, text)
  2597.           end
  2598.         end
  2599.       else
  2600.         draw_text(4, 0, contents.width - 8, line_height, text, align)
  2601.       end
  2602.       @text = text
  2603.       @align = align
  2604.       @actor = nil
  2605.     end
  2606.     self.visible = true
  2607.   end
  2608.   #--------------------------------------------------------------------------
  2609.   # ● 设置敌人
  2610.   #     enemy : 要显示名字和状态的敌人
  2611.   #--------------------------------------------------------------------------
  2612.   def set_enemy(enemy)
  2613.     text = enemy.name
  2614.     state_width = contents.width - text_size(text + "  ").width
  2615.     state_text = make_battler_state_text(enemy, state_width, false)
  2616.     if state_text != ""
  2617.       text += "  " + state_text
  2618.     end
  2619.     set_text(text, 1)
  2620.   end
  2621. end

  2622. #==============================================================================
  2623. # ■ Window_Gold
  2624. #==============================================================================
  2625. class Window_Gold
  2626.   #--------------------------------------------------------------------------
  2627.   # ● 初始化窗口
  2628.   #--------------------------------------------------------------------------
  2629.   def initialize
  2630.     super(0, 0, 160, window_h)
  2631.     create_contents
  2632.     refresh
  2633.   end
  2634.   #--------------------------------------------------------------------------
  2635.   # ● 刷新
  2636.   #--------------------------------------------------------------------------
  2637.   def refresh
  2638.     contents.clear
  2639.     draw_currency_value($game_party.gold, Vocab.gold, 4, 0, 120)
  2640.   end
  2641. end

  2642. #==============================================================================
  2643. # ■ Window_PlayTime
  2644. #==============================================================================
  2645. class Window_PlayTime
  2646.   #--------------------------------------------------------------------------
  2647.   # ● 初始化对像
  2648.   #--------------------------------------------------------------------------
  2649.   def initialize
  2650.     super(0, 0, 160, window_h(2))
  2651.     create_contents
  2652.     refresh
  2653.   end
  2654.   #--------------------------------------------------------------------------
  2655.   # ● 刷新
  2656.   #--------------------------------------------------------------------------
  2657.   def refresh
  2658.     return unless open?
  2659.     contents.clear
  2660.     change_color(system_color)
  2661.     draw_text(4, 0, 120, line_height, Vocab.playtime)
  2662.     @total_sec = Graphics.frame_count / Graphics.frame_rate
  2663.     hour = @total_sec / 60 / 60
  2664.     min = @total_sec / 60 % 60
  2665.     sec = @total_sec % 60
  2666.     text = sprintf("%02d:%02d:%02d", hour, min, sec)
  2667.     change_color(normal_color)
  2668.     draw_text(4, line_height, 120, line_height, text, 2)
  2669.   end
  2670. end

  2671. #==============================================================================
  2672. # ■ Window_Steps
  2673. #==============================================================================
  2674. class Window_Steps
  2675.   #--------------------------------------------------------------------------
  2676.   # ● 初始化对像
  2677.   #--------------------------------------------------------------------------
  2678.   def initialize
  2679.     super(0, 0, 160, window_h(2))
  2680.     create_contents
  2681.     refresh
  2682.   end
  2683.   #--------------------------------------------------------------------------
  2684.   # ● 刷新
  2685.   #--------------------------------------------------------------------------
  2686.   def refresh
  2687.     contents.clear
  2688.     change_color(system_color)
  2689.     draw_text(4, 0, 120, line_height, Vocab.steps)
  2690.     change_color(normal_color)
  2691.     draw_text(4, line_height, 120, line_height, $game_party.steps, 2)
  2692.   end
  2693. end

  2694. #==============================================================================
  2695. # ■ Window_SkillStatus
  2696. #==============================================================================
  2697. class Window_SkillStatus
  2698.   #--------------------------------------------------------------------------
  2699.   # ● 初始化对像
  2700.   #     actor : 角色
  2701.   #--------------------------------------------------------------------------
  2702.   def initialize(actor)
  2703.     super(0, window_h, 0, window_h)
  2704.     create_contents
  2705.     @actor = actor
  2706.     refresh
  2707.   end
  2708. end

  2709. #==============================================================================
  2710. # ■ Window_EquipLeft
  2711. #==============================================================================
  2712. class Window_EquipLeft < Window_Base
  2713.   #--------------------------------------------------------------------------
  2714.   # ● 初始化对像
  2715.   #     actor : 角色
  2716.   #--------------------------------------------------------------------------
  2717.   def initialize(actor)
  2718.     width = [368, SCREEN_W >> 1].max
  2719.     super(0, window_h, -width, window_h(5))
  2720.     create_contents
  2721.     @actor = actor
  2722.     refresh
  2723.   end
  2724.   #--------------------------------------------------------------------------
  2725.   # ● 刷新
  2726.   #--------------------------------------------------------------------------
  2727.   def refresh
  2728.     self.contents.clear
  2729.     draw_actor_name(@actor, 4, 0)
  2730.     draw_actor_level(@actor, 4, line_height)
  2731.     draw_actor_parameter(@actor, 4, line_height(2), 0)
  2732.     draw_actor_parameter(@actor, 4, line_height(3), 1)
  2733.     draw_actor_parameter(@actor, 4, line_height(4), 2)
  2734.     [:atk, :pdef, :mdef].each_with_index do |sym, i|
  2735.       value = instance_variable_get("@new_#{sym}")
  2736.       next if value == nil
  2737.       change_color(system_color)
  2738.       draw_text(160, line_height(i + 2), 40, line_height, "→", 1)
  2739.       change_color(param_change_color(value - @actor.send(sym)))
  2740.       draw_text(200, line_height(i + 2), 36, line_height, value, 2)
  2741.     end
  2742.   end
  2743. end

  2744. #==============================================================================
  2745. # ■ Window_Status
  2746. #==============================================================================
  2747. class Window_Status
  2748.   #--------------------------------------------------------------------------
  2749.   # ● 初始化对像
  2750.   #     actor : 角色
  2751.   #--------------------------------------------------------------------------
  2752.   def initialize(actor)
  2753.     super(0, 0, 0, 0)
  2754.     create_contents
  2755.     @actor = actor
  2756.     refresh
  2757.   end
  2758.   #--------------------------------------------------------------------------
  2759.   # ● 刷新
  2760.   #--------------------------------------------------------------------------
  2761.   def refresh
  2762.     self.contents.clear
  2763.     half = SCREEN_W >> 1
  2764.     draw_actor_graphic(@actor, 40, 112)
  2765.     draw_actor_name(@actor, 4, 0)
  2766.     draw_actor_class(@actor, 148, 0)
  2767.     draw_actor_level(@actor, 96, line_height)
  2768.     draw_actor_state(@actor, 96, line_height(2))
  2769.     draw_actor_hp(@actor, 96, line_height(3.5), 172)
  2770.     draw_actor_sp(@actor, 96, line_height(4.5), 172)
  2771.     for i in 0..6
  2772.       draw_actor_parameter(@actor, 96, line_height(i + (i>2 ? 6.5 : 6)), i)
  2773.     end
  2774.     change_color(system_color)
  2775.     draw_text(half, line_height(1.5), 80, line_height, Vocab.exp)
  2776.     draw_text(half, line_height(2.5), 80, line_height, Vocab.next_level)
  2777.     change_color(normal_color)
  2778.     draw_text(half + 80, line_height(1.5), 84, line_height, @actor.exp_s, 2)
  2779.     draw_text(half + 80, line_height(2.5), 84, line_height,
  2780.       @actor.next_rest_exp_s, 2)
  2781.     change_color(system_color)
  2782.     draw_text(half, line_height(5), 96, line_height, Vocab.equip)
  2783.     draw_item_name(@actor.weapon, half + 16, line_height(6.5))
  2784.     @actor.all_armors.each_with_index do |armor, i|
  2785.       draw_item_name(armor, half + 16, line_height(8 + i * 1.5))
  2786.     end
  2787.   end
  2788. end

  2789. #==============================================================================
  2790. # ■ Window_SaveFile
  2791. #==============================================================================
  2792. class Window_SaveFile
  2793.   #--------------------------------------------------------------------------
  2794.   # ● 初始化对像
  2795.   #     file_index : 存档文件的索引 (0~3)
  2796.   #     filename   : 文件名
  2797.   #--------------------------------------------------------------------------
  2798.   def initialize(file_index, filename)
  2799.     height = (SCREEN_H - window_h) >> 2
  2800.     super(0, window_h + (file_index & 3) * height, 0, height)
  2801.     create_contents
  2802.     @file_index = file_index
  2803.     read_save_file
  2804.     refresh
  2805.     @selected = false
  2806.   end
  2807.   #--------------------------------------------------------------------------
  2808.   # ● 读取存档
  2809.   #--------------------------------------------------------------------------
  2810.   def read_save_file
  2811.     @filename = "Save#{@file_index + 1}.rxdata"
  2812.     @time_stamp = Time.at(0)
  2813.     @file_exist = FileTest.exist?(@filename)
  2814.     if @file_exist
  2815.       file = File.open(@filename, "r")
  2816.       @time_stamp = file.mtime
  2817.       @characters = Marshal.load(file)
  2818.       @frame_count = Marshal.load(file)
  2819.       @game_system = Marshal.load(file)
  2820.       @game_switches = Marshal.load(file)
  2821.       @game_variables = Marshal.load(file)
  2822.       @total_sec = @frame_count / Graphics.frame_rate
  2823.       file.close
  2824.     end
  2825.   end
  2826.   #--------------------------------------------------------------------------
  2827.   # ● 刷新
  2828.   #--------------------------------------------------------------------------
  2829.   def refresh
  2830.     contents.clear
  2831.     # 描绘文件编号
  2832.     change_color(normal_color)
  2833.     name = "#{Vocab.file} #{@file_index + 1}"
  2834.     draw_text(4, 0, SCREEN_W - 40, line_height, name)
  2835.     @name_width = contents.text_size(name).width
  2836.     # 存档文件存在的情况下
  2837.     if @file_exist
  2838.       # 描绘角色
  2839.       for i in 0...@characters.size
  2840.         bitmap = RPG::Cache.character(@characters[i][0], @characters[i][1])
  2841.         cw = bitmap.rect.width >> 2
  2842.         ch = bitmap.rect.height >> 2
  2843.         src_rect = Rect.new(0, 0, cw, ch)
  2844.         x = 300 - (@characters.size << 5) + (i << 6) - (cw >> 1)
  2845.         contents.blt(x, 68 - ch, bitmap, src_rect)
  2846.       end
  2847.       # 描绘游戏时间
  2848.       hour = @total_sec / 60 / 60
  2849.       min = @total_sec / 60 % 60
  2850.       sec = @total_sec % 60
  2851.       time_string = sprintf("%02d:%02d:%02d", hour, min, sec)
  2852.       draw_text(4, 8, SCREEN_W - 40, line_height, time_string, 2)
  2853.       # 描绘时间标记
  2854.       time_string = @time_stamp.strftime("%Y/%m/%d %H:%M")
  2855.       draw_text(4, 40, SCREEN_W - 40, line_height, time_string, 2)
  2856.     end
  2857.   end
  2858.   #--------------------------------------------------------------------------
  2859.   # ● 刷新光标矩形
  2860.   #--------------------------------------------------------------------------
  2861.   def update_cursor_rect
  2862.     if @selected
  2863.       cursor_rect.set(0, 0, @name_width + 8, line_height)
  2864.     else
  2865.       cursor_rect.empty
  2866.     end
  2867.   end
  2868. end

  2869. #==============================================================================
  2870. # ■ Window_Numeric
  2871. #------------------------------------------------------------------------------
  2872. #  处理数值输入的窗口。
  2873. #==============================================================================
  2874. class Window_Numeric < Window_Base
  2875.   include Window_Handler
  2876.   #--------------------------------------------------------------------------
  2877.   # ● 定义实例变量
  2878.   #--------------------------------------------------------------------------
  2879.   attr_reader   :number                   # 当前数字值
  2880.   attr_reader   :magnitude                # 输入数字的进制
  2881.   #--------------------------------------------------------------------------
  2882.   # ● 初始化对像
  2883.   #--------------------------------------------------------------------------
  2884.   def initialize(x, y, width, height)
  2885.     super(x, y, width, height)
  2886.     create_contents
  2887.     @handler = {}
  2888.     @min = 0
  2889.     @max = 0
  2890.     @magnitude = 10
  2891.     @number = 0
  2892.     @index = 0
  2893.     @digits_max = 0
  2894.   end
  2895.   #--------------------------------------------------------------------------
  2896.   # ● 是否按位数分开输入
  2897.   #--------------------------------------------------------------------------
  2898.   def digit_split
  2899.     @min >= 0 and @digits_max > 0
  2900.   end
  2901.   #--------------------------------------------------------------------------
  2902.   # ● 最大位数
  2903.   #--------------------------------------------------------------------------
  2904.   def digits_max
  2905.     return @digits_max if digit_split
  2906.     return contents.width / (contents.font.size >> 1) if !@max
  2907.     @max.to_s(@magnitude).size + (@min < 0 ? 1 : 0)
  2908.   end
  2909.   #--------------------------------------------------------------------------
  2910.   # ● 刷新画面
  2911.   #--------------------------------------------------------------------------
  2912.   def update
  2913.     super
  2914.     update_keypress if self.active
  2915.   end
  2916.   #--------------------------------------------------------------------------
  2917.   # ● 设置数字值
  2918.   #     number : 新值
  2919.   #--------------------------------------------------------------------------
  2920.   def number=(number)
  2921.     @number = number.limit(@min, @max)
  2922.     refresh
  2923.   end
  2924.   #--------------------------------------------------------------------------
  2925.   # ● 数字的字串
  2926.   #--------------------------------------------------------------------------
  2927.   def number_s
  2928.     value = @number.to_s(@magnitude)
  2929.     value = "0" + value while value.size < @digits_max
  2930.     return value
  2931.   end
  2932.   #--------------------------------------------------------------------------
  2933.   # ● 设置进制
  2934.   #     magnitude : 新进制
  2935.   #--------------------------------------------------------------------------
  2936.   def magnitude=(magnitude)
  2937.     @magnitude = magnitude.limit(2, 36)
  2938.     refresh
  2939.   end
  2940.   #--------------------------------------------------------------------------
  2941.   # ● 光标有效判定
  2942.   #--------------------------------------------------------------------------
  2943.   def cursor_respond?
  2944.     @min != @max or (@min.nil? and @max.nil?)
  2945.   end
  2946.   #--------------------------------------------------------------------------
  2947.   # ● 描绘数字
  2948.   #--------------------------------------------------------------------------
  2949.   def draw_number(x, y, width = nil)
  2950.     change_color(normal_color)
  2951.     if digit_split
  2952.       width ||= (contents.font.size >> 1) + 8
  2953.       number_s.scan(/./).each_with_index do |char, i|
  2954.         draw_text(x + i * width, y, width, line_height, char, 1)
  2955.       end
  2956.       @cursor_width = width
  2957.       @rect = Rect.new(x, y, @cursor_width * @digits_max, line_height)
  2958.     else
  2959.       max_width = contents.font.size * digits_max >> 1
  2960.       width ||= max_width
  2961.       ox = width - max_width
  2962.       draw_text(x, y, width, line_height, number_s, 2)
  2963.       @rect = Rect.new(x + ox, y, max_width, line_height).inflate(4, 0)
  2964.     end
  2965.   end
  2966.   #--------------------------------------------------------------------------
  2967.   # ● 更新光标矩形
  2968.   #--------------------------------------------------------------------------
  2969.   def update_cursor_rect
  2970.     if digit_split
  2971.       width = @cursor_width
  2972.       cursor_rect.set(@rect.x + @index * width , @rect.y, width, @rect.height)
  2973.     else
  2974.       self.cursor_rect = @rect
  2975.     end
  2976.   end
  2977.   #--------------------------------------------------------------------------
  2978.   # ● 更新光标矩形
  2979.   #--------------------------------------------------------------------------
  2980.   def move_index(index)
  2981.     @index = (index + digits_max) % digits_max
  2982.     # 演奏光标 SE
  2983.     $game_system.se_play($data_system.cursor_se)
  2984.     update_cursor_rect
  2985.   end
  2986.   #--------------------------------------------------------------------------
  2987.   # ● 光标键处理
  2988.   #--------------------------------------------------------------------------
  2989.   def update_up(force);     update_value(+2);                             end
  2990.   def update_down(force);   update_value(-2);                             end
  2991.   def update_left(force);   update_value(-1);                             end
  2992.   def update_right(force);  update_value(+1);                             end
  2993.   def update_pageup;        update_value(-3);                             end
  2994.   def update_pagedown;      update_value(+3);                             end
  2995.   #--------------------------------------------------------------------------
  2996.   # ● 更新输入数值
  2997.   #--------------------------------------------------------------------------
  2998.   def update_value(value)
  2999.     # 记忆原来的数值
  3000.     last_number = number = @number
  3001.     # 更新位是99的情况下
  3002.     if value.abs == 99
  3003.       # 直接设为最大/最小值
  3004.       number = value == 99 ? @max.to_i : @min.to_i
  3005.     # 更新位是0的情况下
  3006.     elsif value == 0
  3007.       # 清零
  3008.       number = 0.limit(@min, @max)
  3009.     # 更新位是其他的情况下
  3010.     else
  3011.       # 如果是分位输入
  3012.       if digit_split
  3013.         case value
  3014.         # 按下左右键的情况下
  3015.         when 1, -1
  3016.           return move_index(@index + value)
  3017.         # 按下上下键的情况下
  3018.         when 2, -2
  3019.           change = Integer(@magnitude ** (digits_max - @index - 1))
  3020.           place = (number / change) % @magnitude
  3021.           number -= place * change
  3022.           number += (place + (value >> 1) + @magnitude) % @magnitude * change
  3023.           number = number.limit(@min, @max)
  3024.         # 按下L/R键的情况下
  3025.         when 3, -3
  3026.           return move_index(value == 3 ? digits_max - 1 : 0)
  3027.         end
  3028.       # 如果不是分位输入
  3029.       else
  3030.         # 增减变化值
  3031.         key = 0
  3032.         key += 3 if Input.press?(NUM_KI)
  3033.         key += 6 if Input.press?(NUM_MI)
  3034.         key += 9 if Input.press?(NUM_BI)
  3035.         change = (value <=> 0) * Integer(@magnitude ** (value.abs + key - 1))
  3036.         number = (number + change).limit(@min, @max)
  3037.       end
  3038.     end
  3039.     # 数值无变化的情况下
  3040.     if number == last_number
  3041.       # 演奏冻结 SE
  3042.       $game_system.se_play($data_system.buzzer_se)
  3043.     else
  3044.       # 演奏光标 SE
  3045.       $game_system.se_play($data_system.cursor_se)
  3046.       self.number = number
  3047.     end
  3048.   end
  3049. end

  3050. #==============================================================================
  3051. # ■ Window_ShopNumber
  3052. #==============================================================================
  3053. class Window_ShopNumber < Window_Numeric
  3054.   #--------------------------------------------------------------------------
  3055.   # ● 初始化对像
  3056.   #--------------------------------------------------------------------------
  3057.   def initialize
  3058.     width = [368, SCREEN_W >> 1].max
  3059.     super(0, window_h << 1, width, -window_h << 1)
  3060.     @item = nil
  3061.     @min = 1
  3062.     @max = 1
  3063.     @price = 0
  3064.     @number = 1
  3065.   end
  3066.   #--------------------------------------------------------------------------
  3067.   # ● 设置物品、最大个数、价格
  3068.   #--------------------------------------------------------------------------
  3069.   def set(item, max, price)
  3070.     @item = item
  3071.     @max = max
  3072.     @price = price
  3073.     @number = 1
  3074.     refresh
  3075.   end
  3076.   #--------------------------------------------------------------------------
  3077.   # ● 刷新
  3078.   #--------------------------------------------------------------------------
  3079.   def refresh
  3080.     # 计算需要显示多少行文字
  3081.     row_max = (width - 32) / line_height
  3082.     row = (row_max - (SHOW_SHOP_HINT ? 6 : 3)) >> 1
  3083.     # 清除描画区域
  3084.     contents.clear_rect(0, 0, width - 32, line_height(row + 3))
  3085.     # 描绘物品和数量
  3086.     draw_item_name(@item, 4, line_height(row), width - 128)
  3087.     change_color(normal_color)
  3088.     draw_text(width - 124, line_height(row), 32, line_height, "×")
  3089.     # 数量超过6位数的情况下在下一行描绘
  3090.     if @max.nil? or digits_max > 6
  3091.       draw_number(4, line_height(row + 1), width - 40)
  3092.     else
  3093.       draw_number(4, line_height(row), width - 40)
  3094.     end
  3095.     update_cursor_rect
  3096.     # 描绘合计价格和货币单位
  3097.     total = @price * @number
  3098.     draw_currency_value(total, Vocab.gold, 4, line_height(row + 2), width - 40)
  3099.     # 描绘提示
  3100.     if SHOW_SHOP_HINT and @hint_text != make_hint_text
  3101.       contents.clear_rect(0, line_height(row + 3), width - 32, line_height(4))
  3102.       draw_text_ex(4, line_height(row + 3), @hint_text = make_hint_text)
  3103.     end
  3104.   end
  3105.   #--------------------------------------------------------------------------
  3106.   # ● 刷新
  3107.   #--------------------------------------------------------------------------
  3108.   def make_hint_text
  3109.     str = Vocab.num_hints[10..(@max ? -1 : -2)].join
  3110.     max = Vocab.num_hints[0...[digits_max, 10].min]
  3111.     max[9] = sprintf(max[9], Input.key_name(NUM_BI)) if max.size == 10
  3112.     max[6] = sprintf(max[6], Input.key_name(NUM_MI)) if max.size >= 7
  3113.     max[3] = sprintf(max[3], Input.key_name(NUM_KI)) if max.size >= 4
  3114.     str += max.join
  3115.   end
  3116. end

  3117. #==============================================================================
  3118. # ■ Window_ShopStatus
  3119. #==============================================================================
  3120. class Window_ShopStatus
  3121.   #--------------------------------------------------------------------------
  3122.   # ● 初始化对像
  3123.   #--------------------------------------------------------------------------
  3124.   def initialize
  3125.     x = [368, SCREEN_W >> 1].max
  3126.     super(x, window_h << 1, -x, -window_h << 1)
  3127.     create_contents
  3128.     @item = nil
  3129.     refresh
  3130.   end
  3131.   #--------------------------------------------------------------------------
  3132.   # ● 刷新
  3133.   #--------------------------------------------------------------------------
  3134.   def refresh
  3135.     contents.clear
  3136.     return if @item == nil
  3137.     number = $game_party.any_number(@item)
  3138.     draw_key_value_pair(4, 0, Vocab.hold_number, number, number, width - 40)
  3139.     return if @item.is_a?(RPG::Item)
  3140.     # 添加装备品信息
  3141.     for i in 0...$game_party.actors.size
  3142.       # 获取角色
  3143.       actor = $game_party.actors[i]
  3144.       # 可以装备为普通文字颜色、不能装备设置为无效文字颜色
  3145.       change_color(actor.equippable?(@item) ? normal_color : disabled_color)
  3146.       # 描绘角色名字
  3147.       draw_actor_name(actor, 4, line_height(i * 2 + 2))
  3148.       # 可以装备的情况
  3149.       if actor.equippable?(@item)
  3150.         item1 = mirror_item(actor)
  3151.         # 武器的情况
  3152.         if @item.is_a?(RPG::Weapon)
  3153.           atk1 = item1 != nil ? item1.atk : 0
  3154.           atk2 = @item != nil ? @item.atk : 0
  3155.           change = atk2 - atk1
  3156.         end
  3157.         # 防具的情况
  3158.         if @item.is_a?(RPG::Armor)
  3159.           pdef1 = item1 != nil ? item1.pdef : 0
  3160.           mdef1 = item1 != nil ? item1.mdef : 0
  3161.           pdef2 = @item != nil ? @item.pdef : 0
  3162.           mdef2 = @item != nil ? @item.mdef : 0
  3163.           change = pdef2 - pdef1 + mdef2 - mdef1
  3164.         end
  3165.         # 描绘能力值变化
  3166.         draw_text(124, line_height(i * 2 + 2), 112, line_height,
  3167.           sprintf("%+d", change), 2)
  3168.       end
  3169.       # 描绘物品
  3170.       if item1 != nil
  3171.         draw_item_name(item1, 4, line_height(i * 2 + 3),
  3172.           actor.equippable?(@item))
  3173.       end
  3174.     end
  3175.   end
  3176.   #--------------------------------------------------------------------------
  3177.   # ● 获取与当前售卖品对应的角色装备
  3178.   #     actor : 角色
  3179.   #--------------------------------------------------------------------------
  3180.   def mirror_item(actor)
  3181.     # 获取与当前售卖品对应的装备品
  3182.     if @item.is_a?(RPG::Weapon)
  3183.       item1 = actor.weapon
  3184.     else
  3185.       item1 = actor.all_armors[@item.kind]
  3186.     end
  3187.   end
  3188. end

  3189. #==============================================================================
  3190. # ■ Window_NameEdit
  3191. #==============================================================================
  3192. class Window_NameEdit
  3193.   #--------------------------------------------------------------------------
  3194.   # ● 初始化对像
  3195.   #     actor    : 角色
  3196.   #     max_char : 最大字数
  3197.   #--------------------------------------------------------------------------
  3198.   def initialize(actor, max_char)
  3199.     super(0, 0, 0, window_h(3))
  3200.     create_contents
  3201.     @actor = actor
  3202.     @name = actor.name
  3203.     @max_char = max_char
  3204.     # 控制名字在最大字数以内
  3205.     name_array = @name.split(//)[0...@max_char]
  3206.     @name = name_array.join
  3207.     @default_name = @name
  3208.     @index = name_array.size
  3209.     refresh
  3210.     update_cursor_rect
  3211.   end
  3212.   #--------------------------------------------------------------------------
  3213.   # ● 刷新
  3214.   #--------------------------------------------------------------------------
  3215.   def refresh
  3216.     contents.clear
  3217.     # 描绘名称
  3218.     name_array = @name.split(//)
  3219.     half = SCREEN_W >> 1
  3220.     for i in 0...@max_char
  3221.       c = name_array[i]
  3222.       if c == nil
  3223.         c = "_"
  3224.       end
  3225.       x = half - @max_char * 14 + i * 28
  3226.       draw_text(x, line_height, 28, line_height, c, 1)
  3227.     end
  3228.     # 描绘图形
  3229.     draw_actor_graphic(@actor, half - @max_char * 14 - 40, line_height(2.5))
  3230.   end
  3231.   #--------------------------------------------------------------------------
  3232.   # ● 刷新光标矩形
  3233.   #--------------------------------------------------------------------------
  3234.   def update_cursor_rect
  3235.     x = (SCREEN_W >> 1) - @max_char * 14 + @index * 28
  3236.     cursor_rect.set(x, line_height, 28, line_height)
  3237.   end
  3238. end

  3239. #==============================================================================
  3240. # ■ Window_NameInput
  3241. #==============================================================================
  3242. class Window_NameInput
  3243.   include Window_Handler
  3244.   #--------------------------------------------------------------------------
  3245.   # ● 常量
  3246.   #--------------------------------------------------------------------------
  3247.   CHARACTER_TABLE_NORMAL =
  3248.   [
  3249.     "Esc","1","2","3","4","5","6","7","8","9","0","-","=","<-Bksp",
  3250.     "`","q","w","e","r","t","y","u","i","o","p","[","]","\",
  3251.     "CAPS","a","s","d","f","g","h","j","k","l",";","'","Enter",
  3252.     "Shift","z","x","c","v","b","n","m",",",".","/","Shift", " "
  3253.   ]
  3254.   CHARACTER_TABLE_CAPS =
  3255.   [
  3256.     "Esc","1","2","3","4","5","6","7","8","9","0","-","=","<-Bksp",
  3257.     "`","Q","W","E","R","T","Y","U","I","O","P","[","]","\",
  3258.     "caps","A","S","D","F","G","H","J","K","L",";","'","Enter",
  3259.     "Shift","Z","X","C","V","B","N","M",",",".","/","Shift", " "
  3260.   ]
  3261.   CHARACTER_TABLE_SHIFT =
  3262.   [
  3263.     "Esc","!","@","#","$","%","^","&","*","(",")","_","+","<-Bksp",
  3264.     "~","Q","W","E","R","T","Y","U","I","O","P","{","}","|",
  3265.     "CAPS","A","S","D","F","G","H","J","K","L",":",""","Enter",
  3266.     "[Shift]","Z","X","C","V","B","N","M","<",">","?","[Shift]", " "
  3267.   ]
  3268.   CHARACTER_TABLE_CAPS_SHIFT =
  3269.   [
  3270.     "Esc","!","@","#","$","%","^","&","*","(",")","_","+","<-Bksp",
  3271.     "~","q","w","e","r","t","y","u","i","o","p","{","}","|",
  3272.     "caps","a","s","d","f","g","h","j","k","l",":",""","Enter",
  3273.     "[Shift]","z","x","c","v","b","n","m","<",">","?","[Shift]", " "
  3274.   ]
  3275.   #--------------------------------------------------------------------------
  3276.   # ● 定义实例变量
  3277.   #--------------------------------------------------------------------------
  3278.   attr_reader     :caps               # 是否大写锁定
  3279.   attr_reader     :shift              # 是否上档
  3280.   #--------------------------------------------------------------------------
  3281.   # ● 初始化对像
  3282.   #--------------------------------------------------------------------------
  3283.   def initialize
  3284.     super(0, window_h(3), 0, -window_h(3))
  3285.     create_contents
  3286.     @index = 0
  3287.     @caps = false
  3288.     @shift = false
  3289.     @last_index = 0
  3290.     @handler = {SHIFT => method(:update_shift)}
  3291.     activate
  3292.     refresh
  3293.   end
  3294.   #--------------------------------------------------------------------------
  3295.   # ● 获取文字
  3296.   #--------------------------------------------------------------------------
  3297.   def character(id = -1)
  3298.     id = @index if id == -1
  3299.     if @caps
  3300.       return @shift ? CHARACTER_TABLE_CAPS_SHIFT[id] : CHARACTER_TABLE_CAPS[id]
  3301.     else
  3302.       return @shift ? CHARACTER_TABLE_SHIFT[id] : CHARACTER_TABLE_NORMAL[id]
  3303.     end
  3304.   end
  3305.   #--------------------------------------------------------------------------
  3306.   # ● 设置上档
  3307.   #--------------------------------------------------------------------------
  3308.   def shift=(shift)
  3309.     if @shift != shift
  3310.       @shift = shift
  3311.       refresh
  3312.     end
  3313.   end
  3314.   #--------------------------------------------------------------------------
  3315.   # ● 设置大写锁定
  3316.   #--------------------------------------------------------------------------
  3317.   def caps=(caps)
  3318.     if @caps != caps
  3319.       @caps = caps
  3320.       refresh
  3321.     end
  3322.   end
  3323.   #--------------------------------------------------------------------------
  3324.   # ● 获取按钮位置
  3325.   #--------------------------------------------------------------------------
  3326.   def key_pos(id)
  3327.     x = y = w = 0
  3328.     case id
  3329.     when 0..12 # Esc 1 ... =
  3330.       x, y, w = 4 + id * 40, line_height(1.5), 40
  3331.     when 13 # 退格
  3332.       x, y, w = 524, line_height(1.5), 80
  3333.     when 14..27 # ` Q W ... \
  3334.       x, y, w = 24 + (id - 14) * 40, line_height(2.5), 40
  3335.     when 28 # 大写
  3336.       x, y, w = 4, line_height(3.5), 80
  3337.     when 29..39 # A S ... '
  3338.       x, y, w = 84 + (id - 29) * 40, line_height(3.5), 40
  3339.     when 40 # 回车
  3340.       x, y, w = 524, line_height(3.5), 80
  3341.     when 41 # LShift
  3342.       x, y, w = 4, line_height(4.5), 100
  3343.     when 42..51 # Z X ... /
  3344.       x, y, w = 104 + (id - 42) * 40, line_height(4.5), 40
  3345.     when 52 # RShift
  3346.       x, y, w = 504, line_height(4.5), 100
  3347.     when 53 # 空格
  3348.       x, y, w = 184, line_height(5.5), 280
  3349.     end
  3350.     return [x, y, w, line_height]
  3351.   end
  3352.   #--------------------------------------------------------------------------
  3353.   # ● 刷新
  3354.   #--------------------------------------------------------------------------
  3355.   def refresh
  3356.     contents.clear
  3357.     for i in 0..53
  3358.       pos = key_pos(i)
  3359.       self.contents.draw_text(pos[0], pos[1], pos[2], pos[3], character(i), 1)
  3360.     end
  3361.   end
  3362.   #--------------------------------------------------------------------------
  3363.   # ● 刷新光标矩形
  3364.   #--------------------------------------------------------------------------
  3365.   def update_cursor_rect
  3366.     pos = key_pos(@index)
  3367.     self.cursor_rect.set(pos[0], pos[1], pos[2], pos[3])
  3368.   end
  3369.   #--------------------------------------------------------------------------
  3370.   # ● 光标有效判定
  3371.   #--------------------------------------------------------------------------
  3372.   def cursor_respond?
  3373.     true
  3374.   end
  3375.   #--------------------------------------------------------------------------
  3376.   # ● 刷新画面
  3377.   #--------------------------------------------------------------------------
  3378.   def update
  3379.     super
  3380.     update_cursor_rect
  3381.     update_keypress if self.active
  3382.   end
  3383.   #--------------------------------------------------------------------------
  3384.   # ● 上键处理
  3385.   #--------------------------------------------------------------------------
  3386.   def update_up(force)
  3387.     case @index
  3388.     when 0..13
  3389.       $game_system.se_play($data_system.buzzer_se)
  3390.     when 14..40
  3391.       @index -= 14
  3392.     when 41..52
  3393.       @index -= 13
  3394.     when 53
  3395.       @index = @last_index
  3396.     end   
  3397.     $game_system.se_play($data_system.cursor_se) unless @index < 14
  3398.   end
  3399.   #--------------------------------------------------------------------------
  3400.   # ● 下键处理
  3401.   #--------------------------------------------------------------------------
  3402.   def update_down(force)
  3403.     case @index
  3404.     when 0..27
  3405.       @index += 14
  3406.       @index = [@index, 40].min
  3407.     when 28..40
  3408.       @index += 13
  3409.       @index = [@index, 52].min
  3410.     when 41..52
  3411.       @last_index = @index
  3412.       @index = 53
  3413.     when 53
  3414.       $game_system.se_play($data_system.buzzer_se)
  3415.     end   
  3416.     $game_system.se_play($data_system.cursor_se) unless @index == 53
  3417.   end
  3418.   #--------------------------------------------------------------------------
  3419.   # ● 左键处理
  3420.   #--------------------------------------------------------------------------
  3421.   def update_left(force)
  3422.     case @index
  3423.     when 0, 14, 28, 41, 53
  3424.       $game_system.se_play($data_system.buzzer_se)
  3425.     else
  3426.       $game_system.se_play($data_system.cursor_se)
  3427.       @index -= 1
  3428.     end
  3429.   end
  3430.   #--------------------------------------------------------------------------
  3431.   # ● 右键处理
  3432.   #--------------------------------------------------------------------------
  3433.   def update_right(force)
  3434.     case @index
  3435.     when 13, 27, 40, 52, 53
  3436.       $game_system.se_play($data_system.buzzer_se)
  3437.     else
  3438.       $game_system.se_play($data_system.cursor_se)
  3439.       @index += 1
  3440.     end
  3441.   end
  3442.   #--------------------------------------------------------------------------
  3443.   # ● 上页处理
  3444.   #--------------------------------------------------------------------------
  3445.   def update_pageup
  3446.     $game_system.se_play($data_system.cursor_se)
  3447.     self.caps = !caps
  3448.   end
  3449.   #--------------------------------------------------------------------------
  3450.   # ● 下页处理
  3451.   #--------------------------------------------------------------------------
  3452.   def update_pagedown
  3453.     update_pageup
  3454.   end
  3455.   #--------------------------------------------------------------------------
  3456.   # ● SHIFT键处理
  3457.   #--------------------------------------------------------------------------
  3458.   def update_shift
  3459.     $game_system.se_play($data_system.cursor_se)
  3460.     self.shift = !shift
  3461.   end
  3462. end

  3463. #==============================================================================
  3464. # ■ Window_InputNumber
  3465. #==============================================================================
  3466. class Window_InputNumber < Window_Numeric
  3467.   #--------------------------------------------------------------------------
  3468.   # ● 初始化对像
  3469.   #     digits_max : 位数
  3470.   #--------------------------------------------------------------------------
  3471.   def initialize(digits_max)
  3472.     # 从数字的幅度计算(假定与 0~9 等幅)光标的幅度
  3473.     width = ((Font.default_size >> 1) + 8) * digits_max + 40
  3474.     super(0, 0, width, window_h)
  3475.     @digits_max = digits_max
  3476.     self.z += 9999
  3477.     self.opacity = 0
  3478.     @max = @magnitude ** @digits_max - 1
  3479.     refresh
  3480.     update_cursor_rect
  3481.   end
  3482.   #--------------------------------------------------------------------------
  3483.   # ● 刷新
  3484.   #--------------------------------------------------------------------------
  3485.   def refresh
  3486.     contents.clear
  3487.     change_color(normal_color)
  3488.     draw_number(4, 0)
  3489.   end
  3490. end

  3491. #==============================================================================
  3492. # ■ Window_BattleStatus
  3493. #==============================================================================
  3494. class Window_BattleStatus
  3495.   #--------------------------------------------------------------------------
  3496.   # ● 初始化对像
  3497.   #--------------------------------------------------------------------------
  3498.   def initialize
  3499.     super(0, SCREEN_H - window_h(4), 0, window_h(4))
  3500.     self.contents = Bitmap.new(width - 32, height - 32)
  3501.     @level_up_flags = [false, false, false, false]
  3502.     refresh
  3503.   end
  3504.   #--------------------------------------------------------------------------
  3505.   # ● 刷新
  3506.   #--------------------------------------------------------------------------
  3507.   def refresh
  3508.     contents.clear
  3509.     @item_max = $game_party.actors.size
  3510.     $game_party.actors.each_with_index do |actor, i|
  3511.       actor_x = i * 160 + 4
  3512.       draw_actor_name(actor, actor_x, 0)
  3513.       draw_actor_hp(actor, actor_x, line_height(1), 120)
  3514.       draw_actor_sp(actor, actor_x, line_height(2), 120)
  3515.       if @level_up_flags[i]
  3516.         change_color(normal_color)
  3517.         draw_text(actor_x, line_height(3), 120, line_height, Vocab.level_up)
  3518.       else
  3519.         draw_actor_state(actor, actor_x, line_height(3))
  3520.       end
  3521.     end
  3522.   end
  3523. end

  3524. #==============================================================================
  3525. # ■ Window_BattleResult
  3526. #==============================================================================
  3527. class Window_BattleResult
  3528.   #--------------------------------------------------------------------------
  3529.   # ● 初始化对像
  3530.   #     exp       : EXP
  3531.   #     gold      : 金钱
  3532.   #     treasures : 宝物
  3533.   #--------------------------------------------------------------------------
  3534.   def initialize(exp, gold, treasures)
  3535.     @exp = exp
  3536.     @gold = gold
  3537.     @treasures = treasures
  3538.     super(SCREEN_W >> 2, 0, SCREEN_W >> 1, window_h(@treasures.size + 1))
  3539.     create_contents
  3540.     self.y = SCREEN_H - window_h(4) - height >> 1
  3541.     self.back_opacity = 160
  3542.     self.visible = false
  3543.     refresh
  3544.   end
  3545.   #--------------------------------------------------------------------------
  3546.   # ● 刷新
  3547.   #--------------------------------------------------------------------------
  3548.   def refresh
  3549.     contents.clear
  3550.     cx = text_size(@exp).width + text_size(Vocab.exp).width + 2
  3551.     draw_currency_value(@exp, Vocab.exp, 4, 0, cx)
  3552.     cg = text_size(@gold).width + text_size(Vocab.gold).width + 2
  3553.     draw_currency_value(@gold, Vocab.gold, 20 + cx, 0, cg)
  3554.     @treasures.each_with_index do |item, i|
  3555.       draw_item_name(item, 4, line_height(i + 1))
  3556.     end
  3557.   end
  3558. end

  3559. #==============================================================================
  3560. # ■ Window_System
  3561. #------------------------------------------------------------------------------
  3562. #   显示系统文字的窗口,该窗口会被自定义界面类调用。
  3563. #==============================================================================
  3564. class Window_System < Window_Base
  3565.   #--------------------------------------------------------------------------
  3566.   # ● 初始化对像
  3567.   #     x     : 窗口的 X 坐标
  3568.   #     y     : 窗口的 Y 坐标
  3569.   #     width : 窗口的宽度
  3570.   #     text  : 窗口的初始文字
  3571.   #--------------------------------------------------------------------------
  3572.   def initialize(x, y, width, text)
  3573.     super(x, y, width, window_h)
  3574.     set_text(text)
  3575.   end
  3576.   #--------------------------------------------------------------------------
  3577.   # ● 设置文字
  3578.   #     text  : 窗口的初始文字
  3579.   #--------------------------------------------------------------------------
  3580.   def set_text(text)
  3581.     # 如果新文字和当前文字一样就返回
  3582.     return if @text == text
  3583.     @text = text
  3584.     create_contents
  3585.     # 以系统颜色居中绘制文字
  3586.     change_color(system_color)
  3587.     draw_text(0, 0, contents.width, contents.height, text, 1)
  3588.   end
  3589. end

  3590. #==============================================================================
  3591. # ■ Scene_Base
  3592. #==============================================================================
  3593. module Scene_Base
  3594.   #--------------------------------------------------------------------------
  3595.   # ● 绑定按键事件(设置场景扩展方法8000)
  3596.   #--------------------------------------------------------------------------
  3597.   def post_create_8000
  3598.     ivar = instance_variables.map {|i| [i, instance_variable_get(i)]}
  3599.     # 自动绑定只限以下13个按键,不包括方向键和Ctrl/Alt/Shift修饰键
  3600.     keys = [:A, :B, :C, :X, :Y, :Z, :L, :R, :F5, :F6, :F7, :F8, :F9]
  3601.     ivar.each do |i|
  3602.       if i[1].is_a?(Window_Handler) or (i[1].is_a?(Array) and
  3603.         i[1][0].is_a?(Window_Handler))
  3604.         method_prefix = i[0][1...i[0].size]
  3605.         keys.each do |k|
  3606.           name = "#{method_prefix}_#{k.to_s.downcase}"
  3607.           if respond_to?(name)
  3608.             i[1].to_a.each do |window|
  3609.               window && window.set_handler(Input.const_get(k), method(name))
  3610.             end
  3611.           end
  3612.         end
  3613.       end
  3614.     end
  3615.   end
  3616. end

  3617. #==============================================================================
  3618. # ■ Scene_Title
  3619. #==============================================================================
  3620. class Scene_Title
  3621.   #--------------------------------------------------------------------------
  3622.   # ● 设置场景扩展方法处理 2000
  3623.   #--------------------------------------------------------------------------
  3624.   def post_create_2000
  3625.     @command_window.center(Rect.new(0, SCREEN_H >> 1, SCREEN_W, SCREEN_H >> 1))
  3626.     @command_window.openness = 0
  3627.     @command_window.open
  3628.   end
  3629.   #--------------------------------------------------------------------------
  3630.   # ● 终止场景扩展方法处理 2000
  3631.   #--------------------------------------------------------------------------
  3632.   def pre_terminate_2000
  3633.     Graphics.transition(0)
  3634.     @command_window.close
  3635.     until @command_window.close? do
  3636.       Graphics.update
  3637.       @command_window.update
  3638.     end
  3639.     Graphics.freeze
  3640.   end
  3641. end

  3642. #==============================================================================
  3643. # ■ Scene_Menu
  3644. #==============================================================================
  3645. class Scene_Menu
  3646.   #--------------------------------------------------------------------------
  3647.   # ● 设置场景扩展方法处理 2000
  3648.   #--------------------------------------------------------------------------
  3649.   def post_create_2000
  3650.     @command_window.align(7)
  3651.     @status_window.align(6)
  3652.     @gold_window.align(1)
  3653.     @steps_window.dock(@gold_window, 2, 1)
  3654.     @playtime_window.dock(@steps_window, 2, 1)
  3655.   end
  3656. end

  3657. #==============================================================================
  3658. # ■ Scene_End
  3659. #==============================================================================
  3660. class Scene_End
  3661.   #--------------------------------------------------------------------------
  3662.   # ● 设置场景扩展方法处理 2000
  3663.   #--------------------------------------------------------------------------
  3664.   def post_create_2000
  3665.     @command_window.center
  3666.     @command_window.openness = 0
  3667.     @command_window.open
  3668.   end
  3669.   #--------------------------------------------------------------------------
  3670.   # ● 终止场景扩展方法处理 2000
  3671.   #--------------------------------------------------------------------------
  3672.   def pre_terminate_2000
  3673.     Graphics.transition(0)
  3674.     @command_window.close
  3675.     until @command_window.close? do
  3676.       Graphics.update
  3677.       @command_window.update
  3678.     end
  3679.     Graphics.freeze
  3680.   end
  3681. end

  3682. #==============================================================================
  3683. # ■ Scene_Shop
  3684. #==============================================================================
  3685. class Scene_Shop
  3686.   #--------------------------------------------------------------------------
  3687.   # ● 设置场景扩展方法处理 2000
  3688.   #--------------------------------------------------------------------------
  3689.   def post_create_2000
  3690.     @gold_window.dock(@command_window, 4)
  3691.     start_y = @command_window.y + @command_window.height
  3692.     @dummy_window.move(0, start_y, SCREEN_W, SCREEN_H - start_y)
  3693.   end
  3694. end

  3695. #==============================================================================
  3696. # ■ Scene_Name
  3697. #==============================================================================
  3698. class Scene_Name
  3699.   #--------------------------------------------------------------------------
  3700.   # ● 刷新画面
  3701.   #--------------------------------------------------------------------------
  3702.   def update
  3703.     update_all_windows
  3704.   end
  3705.   #--------------------------------------------------------------------------
  3706.   # ● 输入A键处理
  3707.   #--------------------------------------------------------------------------
  3708.   def input_window_a
  3709.     # 名称为空的情况下
  3710.     if @edit_window.name == ""
  3711.       # 还原为默认名称
  3712.       @edit_window.restore_default
  3713.       # 名称仍然为空的情况下
  3714.       if @edit_window.name == ""
  3715.         # 演奏冻结 SE
  3716.         $game_system.se_play($data_system.buzzer_se)
  3717.         return
  3718.       end
  3719.       # 演奏确定 SE
  3720.       $game_system.se_play($data_system.decision_se)
  3721.       return
  3722.     end
  3723.     # 更改角色名称
  3724.     @actor.name = @edit_window.name
  3725.     # 演奏确定 SE
  3726.     $game_system.se_play($data_system.decision_se)
  3727.     # 切换到地图画面
  3728.     $scene = Scene_Map.new
  3729.   end
  3730.   #--------------------------------------------------------------------------
  3731.   # ● 输入B键处理
  3732.   #--------------------------------------------------------------------------
  3733.   def input_window_b
  3734.     # 有可以删除字符的情况下
  3735.     if @edit_window.index > 0
  3736.       # 演奏取消 SE
  3737.       $game_system.se_play($data_system.cancel_se)
  3738.       # 删除字符
  3739.       @edit_window.back
  3740.     end
  3741.   end
  3742.   #--------------------------------------------------------------------------
  3743.   # ● 输入C键处理
  3744.   #--------------------------------------------------------------------------
  3745.   def input_window_c
  3746.     # 取得光标位置
  3747.     case @input_window.character
  3748.     # 光标位置为 [取消] 的情况下
  3749.     when "Esc"
  3750.       # 还原为默认名称
  3751.       @edit_window.restore_default
  3752.     # 光标位置为 [回车] 的情况下
  3753.     when "Enter"
  3754.       input_window_a
  3755.     # 光标位置为 [退格] 的情况下
  3756.     when "<-Bksp"
  3757.       input_window_b
  3758.     # 光标位置为 [大写] 的情况下
  3759.     when "CAPS", "caps"
  3760.       # 演奏光标 SE
  3761.       $game_system.se_play($data_system.cursor_se)
  3762.       @input_window.caps = !@input_window.caps
  3763.       return
  3764.     # 光标位置为 [上档] 的情况下
  3765.     when "Shift", "[Shift]"
  3766.       # 演奏光标 SE
  3767.       $game_system.se_play($data_system.cursor_se)
  3768.       @input_window.shift = !@input_window.shift
  3769.       return
  3770.     # 其他情况下
  3771.     else
  3772.       # 光标位置为最大的情况下
  3773.       if @edit_window.index == $game_temp.name_max_char
  3774.         # 演奏冻结 SE
  3775.         $game_system.se_play($data_system.buzzer_se)
  3776.         return
  3777.       end
  3778.       # 文字为空的情况下
  3779.       if @input_window.character == ""
  3780.         # 演奏冻结 SE
  3781.         $game_system.se_play($data_system.buzzer_se)
  3782.         return
  3783.       end
  3784.       # 演奏确定 SE
  3785.       $game_system.se_play($data_system.decision_se)
  3786.       # 添加文字
  3787.       @edit_window.add(@input_window.character)
  3788.       # 取消上档
  3789.       @input_window.shift = false if @input_window.shift
  3790.     end
  3791.   end
  3792. end

  3793. #==============================================================================
  3794. # ■ Scene_Debug
  3795. #==============================================================================
  3796. class Scene_Debug
  3797.   #--------------------------------------------------------------------------
  3798.   # ● 设置场景扩展方法处理 2000
  3799.   #--------------------------------------------------------------------------
  3800.   def post_create_2000
  3801.     @help_window.height = @help_window.window_h(3)
  3802.     @help_window.align(3)
  3803.     @help_window.create_contents
  3804.   end
  3805.   #--------------------------------------------------------------------------
  3806.   # ● 更新场景
  3807.   #--------------------------------------------------------------------------
  3808.   def update
  3809.     @right_window.mode = @left_window.mode
  3810.     @right_window.top_id = @left_window.top_id
  3811.     update_all_windows
  3812.     $game_temp.debug_top_row = @left_window.top_row
  3813.     $game_temp.debug_index = @left_window.index
  3814.   end
  3815.   #--------------------------------------------------------------------------
  3816.   # ● 左侧窗口B键处理
  3817.   #--------------------------------------------------------------------------
  3818.   def left_window_b
  3819.     # 演奏取消 SE
  3820.     $game_system.se_play($data_system.cancel_se)
  3821.     # 切换到地图画面
  3822.     $scene = Scene_Map.new
  3823.   end
  3824.   #--------------------------------------------------------------------------
  3825.   # ● 左侧窗口C键处理
  3826.   #--------------------------------------------------------------------------
  3827.   def left_window_c
  3828.     # 演奏确定 SE
  3829.     $game_system.se_play($data_system.decision_se)
  3830.     # 显示帮助
  3831.     line_height = @help_window.line_height
  3832.     if @left_window.mode == 0
  3833.       text1 = "C (Enter) : ON / OFF"
  3834.       @help_window.draw_text(4, 0, 406, line_height, text1)
  3835.     else
  3836.       text1 = "← : -1   → : +1"
  3837.       text2 = "L (PageUp) : -10  R (PageDown) : +10"
  3838.       text3 = "Shift : 100x  Ctrl : 10Kx  Alt : 100Mx"
  3839.       @help_window.draw_text(4, 0, 406, line_height, text1)
  3840.       @help_window.draw_text(4, line_height, 406, line_height, text2)
  3841.       @help_window.draw_text(4, line_height << 1, 406, line_height, text3)
  3842.     end
  3843.     # 激活右侧窗口
  3844.     @left_window.deactivate
  3845.     @right_window.activate.index = 0
  3846.   end
  3847.   #--------------------------------------------------------------------------
  3848.   # ● 右侧窗口B键处理
  3849.   #--------------------------------------------------------------------------
  3850.   def right_window_b
  3851.     # 演奏取消 SE
  3852.     $game_system.se_play($data_system.cancel_se)
  3853.     # 激活左侧窗口
  3854.     @left_window.activate
  3855.     @right_window.deactivate.index = -1
  3856.     # 删除帮助
  3857.     @help_window.contents.clear
  3858.   end
  3859.   #--------------------------------------------------------------------------
  3860.   # ● 右侧窗口C键处理
  3861.   #--------------------------------------------------------------------------
  3862.   def right_window_c
  3863.     # 开关的情况下
  3864.     if @right_window.mode == 0
  3865.       # 获取被选择的开关 / 变量的 ID
  3866.       current_id = @right_window.top_id + @right_window.index
  3867.       # 演奏确定 SE
  3868.       $game_system.se_play($data_system.decision_se)
  3869.       # 逆转 ON / OFF 状态
  3870.       $game_switches[current_id] = (not $game_switches[current_id])
  3871.       @right_window.refresh
  3872.     end
  3873.   end
  3874. end
复制代码


范例工程已上传,欢迎测试。
WindowCore.zip (253.29 KB, 下载次数: 270)

评分

参与人数 2星屑 +200 赞 +2 收起 理由
cc610523 + 1 精品文章
RyanBern + 200 + 1 精品文章

查看全部评分

SailCat (小猫子·要开心一点) 共上站 24 次,发表过 11 篇文章 上 次 在: [2006年01月28日11:41:18 星期六] 从 [162.105.120.91] 到本站一游。
梦石
0
星屑
2724
在线时间
227 小时
注册时间
2016-3-27
回帖
557
发表于 2017-12-3 11:10:28 | 显示全部楼层
默默点了收藏...感觉UI要全统一才比较好吧,不然好违和

点评

这...选怪物还有很多方法吧  发表于 2017-12-3 12:40
删掉了你还怎么打仗……  发表于 2017-12-3 12:26
不能删掉吗...或者说素材处理掉  发表于 2017-12-3 12:16
当然统一更好,不过之所以允许个别设定是因为XP有个肉疼的东西叫做Arrow....这个在windowskin里面  发表于 2017-12-3 11:29
现在还能改名吗qwq
回复

使用道具 举报

梦石
0
星屑
8498
在线时间
775 小时
注册时间
2017-11-10
回帖
1074
发表于 2017-12-3 15:40:09 | 显示全部楼层
只是窗口外观和光标发生了变化吗?
使用VA的规格windowskin,原XP的规格就不能用了对吗?

点评

双边兼容的……你想用哪个规格都可以,我这正在更新对MV规格的支持……  发表于 2017-12-3 15:54
一个只会简单事件的Rm新人,脚本完全不懂。只求做个简单的游戏完成自己的游戏之梦而已。
第一个游戏已经完成,等待各素材的完成和测试。
回复

使用道具 举报

遠航の猫咪

梦石
3
星屑
27057
在线时间
2428 小时
注册时间
2005-10-15
回帖
989

开拓者

 楼主| 发表于 2017-12-18 17:49:34 | 显示全部楼层
本帖最后由 SailCat 于 2017-12-18 21:28 编辑

更新完整版插件 v1.2并范例

发布的版本中将所有设置项都写成了RGSS1的默认值,也就是说,连血条阴影啥的都没有……你自己打开设置项就行了
SailCat (小猫子·要开心一点) 共上站 24 次,发表过 11 篇文章 上 次 在: [2006年01月28日11:41:18 星期六] 从 [162.105.120.91] 到本站一游。
回复

使用道具 举报

梦石
0
星屑
35258
在线时间
4171 小时
注册时间
2007-12-15
回帖
9490
发表于 2017-12-28 21:47:10 | 显示全部楼层
本帖最后由 89444640 于 2017-12-30 09:56 编辑

提个问题,这个应该在哪里改?
01.png
我查了一下,可能是SEP 插件公共核心
1894行开始
def draw_actor_exp(actor, x, y)
    contents.font.color = system_color
    contents.draw_text(x, y, 24, 32, Vocab.exp_a)
    contents.font.color = normal_color
    contents.draw_text(x + 24, y, 84, 32, actor.exp_s, 2)
    contents.draw_text(x + 108, y, 12, 32, "/", 1)
    contents.draw_text(x + 120, y, 84, 32, actor.next_exp_s)
  end
end
这段
我这里没有脚本以前,是Window_Base 220行开始改成了
def draw_actor_exp(actor, x, y)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 64, 32, "Exp:")
    txt = "#{actor.now_exp}/#{actor.next_exp}"
    cx = contents.text_size(txt).width
    self.contents.draw_text(x+64, y, cx, 32, txt)
  end
删除了SEP 插件公共核心后
显示是这样的
02.png

因为只有这段有exp描述,推测可能是这里出问题了,但是我直接把这段复制到sep核心插件会出问题,应该是#闹得,如果弄过来,让exp如图正常显示,应该怎么描述呢?
我不懂程序语法,只能慢慢蒙着实验看看怎么弄能正常显示,还请帮忙看一下。
菜单主界面底下的exp也不给描绘……
Scripts.rar (265.83 KB, 下载次数: 71)

我改了很多次都没变化,因为眼中菜单冲突,范例中脚本3~5都没法用。

全局搜索,替换所有脚本中出现的两个词组为后面的,
01.jpg
然后毅然只能显示成XXX/XXXX
前面的数字只能显示后三位,第四位无法显示。
真的不知道该怎么弄了。

刚才看了game actor,发现行数与默认不一样,于是挨个找
发现这里
02.png
与默认脚本不一样
01.png
应该是什么时候动过,我试着改一下看看。

改了以后还是不行,然后接着一行一行的对着看哪里动过。
发现windows status动过,而且还没少动。行数查了好多。
于是一行一行的找,发现了这里应该是描述exp的地方了。
03.png
于是对着默认脚本看把最有可能的脚本复制过来。
终于成功了T T
04.png

真是得多谢楼主,辛苦了。

点评

确实windows status问题,改回默认的描述后终于正常了,上面的图像就是正常后的显示。  发表于 2017-12-30 22:13
看起来并不是这里的问题,你需要查一下Window_Status里面关于描绘这里的部分。  发表于 2017-12-30 21:56
对着默认脚本挨个找,发现Window_Status也有人动过没注明,我一般动过的脚本都注明(改),可能是这里造成的?我试着弄一下。  发表于 2017-12-30 09:43
Game_Actor 里面也有一处 345 355 def next_exp_s return @exp_list[@level+1] > 0 ? @exp_list[@level+1].to_s : "-------"  发表于 2017-12-30 09:17
最后一处 sep 1900 contents.draw_text(x + 120, y, 84, 32, actor.next_exp_s)  发表于 2017-12-30 09:16
回复

使用道具 举报

梦石
0
星屑
504
在线时间
43 小时
注册时间
2018-2-19
回帖
60
发表于 2018-3-10 03:08:51 | 显示全部楼层
真好用,感谢楼主分享。
梦想是谁创造的,梦想是自己创造的。站起来吧。
                      梦想由我们自己来创造。
  无论未来有多么困难,在下都会尽全力走下去。
回复

使用道具 举报

遠航の猫咪

梦石
3
星屑
27057
在线时间
2428 小时
注册时间
2005-10-15
回帖
989

开拓者

 楼主| 发表于 2018-8-26 22:52:47 | 显示全部楼层
更新v1.6 update
回复

使用道具 举报

梦石
0
星屑
4643
在线时间
488 小时
注册时间
2017-7-7
回帖
134

R考场第七期纪念奖

发表于 2018-9-6 23:27:36 | 显示全部楼层
本帖最后由 Six_Fish 于 2018-9-6 23:38 编辑

报告猫姐,v1.6版本的核心使用对话增强疯狂报错
-
经排查是使用\[人名框]功能后出错

点评

686和687行的@back_opacity改为self.back_opacity,我忽略了,上面都做了定义,这里要按照属性来取,以免子类重定义的时候出问题。  发表于 2018-9-7 00:10
贴错误信息  发表于 2018-9-6 23:48
回复

使用道具 举报

遠航の猫咪

梦石
3
星屑
27057
在线时间
2428 小时
注册时间
2005-10-15
回帖
989

开拓者

 楼主| 发表于 2018-9-7 01:10:43 | 显示全部楼层
更新v1.7 修正了一个兼容性bug
感谢@Six_Fish 测试汇报
SailCat (小猫子·要开心一点) 共上站 24 次,发表过 11 篇文章 上 次 在: [2006年01月28日11:41:18 星期六] 从 [162.105.120.91] 到本站一游。
回复

使用道具 举报

梦石
0
星屑
35258
在线时间
4171 小时
注册时间
2007-12-15
回帖
9490
发表于 2020-8-3 16:54:10 | 显示全部楼层
猫大,窗口增强-对话窗口v1.1 刷新画面:按键跳过 部分发现一个bug
01.png
在按B 取消键跳过对话的时候,如果我对话中有显示选项,并且是取消无效的情况,就会直接跳出,而不是默认的无法关闭对话框并且播放无效的音效,
请问怎么修正?
回复

使用道具 举报

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

本版积分规则

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

在本版发帖返回顶部