查看: 103|回复: 0

[转载发布] 【汉化搬运】在命令选项上添加图标并修改选项名称颜色Ve...

[复制链接]
  • TA的每日心情
    开心
    2024-5-10 09:55
  • 签到天数: 37 天

    连续签到: 3 天

    [LV.5]常住居民I

    2028

    主题

    32

    回帖

    7260

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    0
    卡币
    5184
    OK点
    16
    积分
    7260
    发表于 同元九百九十六年十一月三日(冬) | 显示全部楼层 |阅读模式
    主要功能
    可以在
    命令上显示图标可以将命令字符设置为左对齐,居中对齐和右对齐,
    还可以为命令字符指定颜色。



    RUBY 代码
    1. /*:-----------------------------------------------------------------------------------
    2. * NUUN_CommandIcon.js
    3. *
    4. * Copyright (C)2020 NUUN
    5. * This software is released under the MIT License.
    6. *[url]http://opensource.org/licenses/mit-license.php[/url]
    7. * -------------------------------------------------------------------------------------
    8. */
    9. /*:
    10. * @target MZ
    11. * @plugindesc 自定义命令插件
    12. * @author NUUN  翻译:我想我是兔
    13. *
    14. * @help
    15. * RMmv/mz 素材、插件分享小站  [url]www.rpgtuzi.com[/url]
    16. *
    17. * 您可以在命令菜单中显示图标,并更改命令名称的文本颜色。。
    18. * 您可以从左对齐,居中对齐和右对齐中选择命令名称的位置。
    19. *
    20. * 利用規約
    21. * 该插件是根据MIT许可分发的。
    22. *
    23. * 更新履歴
    24. * 2020/11/19 Ver 1.0.0
    25. *  初版
    26. *
    27. * 2020/11/20 Ver 1.0.1
    28. *  プラグインパラメータのCommadIconが空白だった場合、エラーが出る問題を修正。
    29. *
    30. * 2020/11/20 Ver 1.0.2
    31. *  多言語対応ではなかったため修正。
    32. *
    33. * 2020/11/21 Ver 1.1.0
    34. *  コマンド名に色を付ける機能を追加。
    35. *
    36. * 2020/11/22 Ver 1.1.1
    37. *  追加从左对齐、中间对齐、右对齐中选择命令名的功能。
    38. *
    39. * @param CommadIcon
    40. * @text 命令图标设置
    41. * @desc 设置要在命令中显示的图标。
    42. * @default[]
    43. * @type struct[]
    44. *
    45. * @param CommandPosition
    46. * @text 纵向命令的命令名称显示位置
    47. * @desc 指定纵向命令的命令名称的显示位置。 (菜单屏幕等)
    48. * @typeselect
    49. * @option 左对齐
    50. * @value0
    51. * @option 中间对齐
    52. * @value1
    53. * @option 右对齐
    54. * @value2
    55. * @default1
    56. *
    57. * @param HorzCommandPosition
    58. * @text 水平命令的命令名称显示位置
    59. * @desc 指定水平命令的命令名称的显示位置。 (项目栏等)
    60. * @typeselect
    61. * @option 左对齐
    62. * @value0
    63. * @option 中间对齐
    64. * @value1
    65. * @option 右对齐
    66. * @value2
    67. * @default1
    68. *
    69. */
    70. /*~struct~CommadIconList:
    71. *
    72. * @param CommadName
    73. * @text 指令名称
    74. * @desc 命令名称以显示图标(请使用与要显示的命令名称相同的名称)
    75. * @typestring
    76. *
    77. * @param CommadNameColor
    78. * @text 命令名称颜色
    79. * @desc 命令名称颜色索引号。
    80. * @type number
    81. * @default0
    82. * @min0
    83. *
    84. * @param iconId
    85. * @text 图标索引号
    86. * @desc 对应图标的ID号。
    87. * @type number
    88. * @default0
    89. * @min0
    90. *
    91. */
    92. /*:ja
    93. * @target MZ
    94. * @plugindesc 自定义命令插件
    95. * @author NUUN  翻译:我想我是兔
    96. *
    97. * @help
    98. * RMmv/mz 素材、插件分享小站  [url]www.rpgtuzi.com[/url]
    99. *
    100. * 您可以在命令菜单中显示图标,并更改命令名称的文本颜色。。
    101. * 您可以从左对齐,居中对齐和右对齐中选择命令名称的位置。
    102. *
    103. * 利用規約
    104. * 该插件是根据MIT许可分发的。
    105. *
    106. * 更新履歴
    107. * 2020/11/19 Ver 1.0.0
    108. *  初版
    109. *
    110. * 2020/11/20 Ver 1.0.1
    111. *  プラグインパラメータのCommadIconが空白だった場合、エラーが出る問題を修正。
    112. *
    113. * 2020/11/20 Ver 1.0.2
    114. *  多言語対応ではなかったため修正。
    115. *
    116. * 2020/11/21 Ver 1.1.0
    117. *  コマンド名に色を付ける機能を追加。
    118. *
    119. * 2020/11/22 Ver 1.1.1
    120. *  追加从左对齐、中间对齐、右对齐中选择命令名的功能。
    121. *
    122. * @param CommadIcon
    123. * @text 命令图标设置
    124. * @desc 设置要在命令中显示的图标。
    125. * @default[]
    126. * @type struct[]
    127. *
    128. * @param CommandPosition
    129. * @text 纵向命令的命令名称显示位置
    130. * @desc 指定纵向命令的命令名称的显示位置。 (菜单屏幕等)
    131. * @typeselect
    132. * @option 左对齐
    133. * @value0
    134. * @option 中间对齐
    135. * @value1
    136. * @option 右对齐
    137. * @value2
    138. * @default1
    139. *
    140. * @param HorzCommandPosition
    141. * @text 水平命令的命令名称显示位置
    142. * @desc 指定水平命令的命令名称的显示位置。 (项目栏等)
    143. * @typeselect
    144. * @option 左对齐
    145. * @value0
    146. * @option 中间对齐
    147. * @value1
    148. * @option 右对齐
    149. * @value2
    150. * @default1
    151. *
    152. */
    153. /*~struct~CommadIconList:ja
    154. *
    155. * @param CommadName
    156. * @text 指令名称
    157. * @desc 命令名称以显示图标(请使用与要显示的命令名称相同的名称)
    158. * @typestring
    159. *
    160. * @param CommadNameColor
    161. * @text 命令名称颜色
    162. * @desc 命令名称颜色索引号。
    163. * @type number
    164. * @default0
    165. * @min0
    166. *
    167. * @param iconId
    168. * @text 图标索引号
    169. * @desc 对应图标的ID号。
    170. * @type number
    171. * @default0
    172. * @min0
    173. *
    174. */
    175. var Imported = Imported || {};
    176. Imported.NUUN_CommandIcon = true;
    177. (() => {
    178. const parameters = PluginManager.parameters('NUUN_CommandIcon');
    179. const param = JSON.parse(JSON.stringify(parameters, function(key, value){
    180.   try {
    181.       return JSON.parse(value);
    182.   }catch(e){
    183.       try {
    184.           returneval(value);
    185.       }catch(e){
    186.           return value;
    187.       }
    188.   }
    189. }));
    190. const _Window_Command_itemTextAlign = Window_Command.prototype.itemTextAlign;
    191. Window_Command.prototype.itemTextAlign = function(){
    192.   switch (param.CommandPosition){
    193.     case0:
    194.       return"left";
    195.     case1:
    196.       return _Window_Command_itemTextAlign.call(this);
    197.     case2:
    198.       return"right";
    199.   }
    200. };
    201. const _Window_HorzCommand_itemTextAlign = Window_HorzCommand.prototype.itemTextAlign;
    202. Window_HorzCommand.prototype.itemTextAlign = function(){
    203.   switch (param.HorzCommandPosition){
    204.     case0:
    205.       return"left";
    206.     case1:
    207.       return _Window_HorzCommand_itemTextAlign.call(this);
    208.     case2:
    209.       return"right";
    210.   }
    211. };
    212. const _Window_Command_drawItem = Window_Command.prototype.drawItem;
    213. Window_Command.prototype.drawItem = function(index){
    214.   const commadName = this.commandName(index);
    215.   const foundIndex = param.CommadIcon ? param.CommadIcon.findIndex(Commad => (Commad.CommadName === commadName)) : null;
    216.   if(foundIndex >= 0){
    217.     const commadData = param.CommadIcon[foundIndex];
    218.     const rect = this.itemLineRect(index);
    219.     const align = this.itemTextAlign();
    220.     const iconY = rect.y + (this.lineHeight() - ImageManager.iconHeight) / 2;
    221.     const textMargin = commadData.iconId > 0 ? ImageManager.iconWidth + 4 : 0;
    222.     const textWidth = this.textWidth(commadName);
    223.     const itemWidth = Math.max(0, rect.width - textMargin);
    224.     const width = Math.min(itemWidth, textWidth);
    225.     const color = commadData.CommadNameColor ? commadData.CommadNameColor : 0;
    226.     this.changeTextColor(ColorManager.textColor(color));
    227.     this.changePaintOpacity(this.isCommandEnabled(index));
    228.     if(commadData.iconId > 0){
    229.       if(align === 'center'){
    230.         this.drawIcon(commadData.iconId, rect.x + (rect.width / 2 - width / 2) - textMargin / 2, iconY);
    231.       }elseif(align === 'left'){
    232.         this.drawIcon(commadData.iconId, rect.x, iconY);
    233.       }else{
    234.         this.drawIcon(commadData.iconId, rect.x + itemWidth - width, iconY);
    235.       }
    236.     }
    237.     this.drawText(commadName, rect.x + textMargin, rect.y, itemWidth, align);
    238.     this.resetTextColor();
    239.   }else{
    240.     _Window_Command_drawItem.call(this, index);
    241.   }
    242. };
    243. })();
    复制代码

                 本帖来自P1论坛作者我想我是兔,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=484386  若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。
    天天去同能,天天有童年!
    回复 论坛版权

    使用道具 举报

    ahome_bigavatar:guest
    ahome_bigavatar:welcomelogin
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2024-5-20 16:44 , Processed in 0.046906 second(s), 41 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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