主要功能
可以在
命令上显示图标可以将命令字符设置为左对齐,居中对齐和右对齐,
还可以为命令字符指定颜色。
 
RUBY 代码 - /*:-----------------------------------------------------------------------------------
- * NUUN_CommandIcon.js
- *
- * Copyright (C)2020 NUUN
- * This software is released under the MIT License.
- *[url]http://opensource.org/licenses/mit-license.php[/url]
- * -------------------------------------------------------------------------------------
- */
- /*:
- * @target MZ
- * @plugindesc 自定义命令插件
- * @author NUUN 翻译:我想我是兔
- *
- * @help
- * RMmv/mz 素材、插件分享小站 [url]www.rpgtuzi.com[/url]
- *
- * 您可以在命令菜单中显示图标,并更改命令名称的文本颜色。。
- * 您可以从左对齐,居中对齐和右对齐中选择命令名称的位置。
- *
- * 利用規約
- * 该插件是根据MIT许可分发的。
- *
- * 更新履歴
- * 2020/11/19 Ver 1.0.0
- * 初版
- *
- * 2020/11/20 Ver 1.0.1
- * プラグインパラメータのCommadIconが空白だった場合、エラーが出る問題を修正。
- *
- * 2020/11/20 Ver 1.0.2
- * 多言語対応ではなかったため修正。
- *
- * 2020/11/21 Ver 1.1.0
- * コマンド名に色を付ける機能を追加。
- *
- * 2020/11/22 Ver 1.1.1
- * 追加从左对齐、中间对齐、右对齐中选择命令名的功能。
- *
- * @param CommadIcon
- * @text 命令图标设置
- * @desc 设置要在命令中显示的图标。
- * @default[]
- * @type struct[]
- *
- * @param CommandPosition
- * @text 纵向命令的命令名称显示位置
- * @desc 指定纵向命令的命令名称的显示位置。 (菜单屏幕等)
- * @typeselect
- * @option 左对齐
- * @value0
- * @option 中间对齐
- * @value1
- * @option 右对齐
- * @value2
- * @default1
- *
- * @param HorzCommandPosition
- * @text 水平命令的命令名称显示位置
- * @desc 指定水平命令的命令名称的显示位置。 (项目栏等)
- * @typeselect
- * @option 左对齐
- * @value0
- * @option 中间对齐
- * @value1
- * @option 右对齐
- * @value2
- * @default1
- *
- */
- /*~struct~CommadIconList:
- *
- * @param CommadName
- * @text 指令名称
- * @desc 命令名称以显示图标(请使用与要显示的命令名称相同的名称)
- * @typestring
- *
- * @param CommadNameColor
- * @text 命令名称颜色
- * @desc 命令名称颜色索引号。
- * @type number
- * @default0
- * @min0
- *
- * @param iconId
- * @text 图标索引号
- * @desc 对应图标的ID号。
- * @type number
- * @default0
- * @min0
- *
- */
- /*:ja
- * @target MZ
- * @plugindesc 自定义命令插件
- * @author NUUN 翻译:我想我是兔
- *
- * @help
- * RMmv/mz 素材、插件分享小站 [url]www.rpgtuzi.com[/url]
- *
- * 您可以在命令菜单中显示图标,并更改命令名称的文本颜色。。
- * 您可以从左对齐,居中对齐和右对齐中选择命令名称的位置。
- *
- * 利用規約
- * 该插件是根据MIT许可分发的。
- *
- * 更新履歴
- * 2020/11/19 Ver 1.0.0
- * 初版
- *
- * 2020/11/20 Ver 1.0.1
- * プラグインパラメータのCommadIconが空白だった場合、エラーが出る問題を修正。
- *
- * 2020/11/20 Ver 1.0.2
- * 多言語対応ではなかったため修正。
- *
- * 2020/11/21 Ver 1.1.0
- * コマンド名に色を付ける機能を追加。
- *
- * 2020/11/22 Ver 1.1.1
- * 追加从左对齐、中间对齐、右对齐中选择命令名的功能。
- *
- * @param CommadIcon
- * @text 命令图标设置
- * @desc 设置要在命令中显示的图标。
- * @default[]
- * @type struct[]
- *
- * @param CommandPosition
- * @text 纵向命令的命令名称显示位置
- * @desc 指定纵向命令的命令名称的显示位置。 (菜单屏幕等)
- * @typeselect
- * @option 左对齐
- * @value0
- * @option 中间对齐
- * @value1
- * @option 右对齐
- * @value2
- * @default1
- *
- * @param HorzCommandPosition
- * @text 水平命令的命令名称显示位置
- * @desc 指定水平命令的命令名称的显示位置。 (项目栏等)
- * @typeselect
- * @option 左对齐
- * @value0
- * @option 中间对齐
- * @value1
- * @option 右对齐
- * @value2
- * @default1
- *
- */
- /*~struct~CommadIconList:ja
- *
- * @param CommadName
- * @text 指令名称
- * @desc 命令名称以显示图标(请使用与要显示的命令名称相同的名称)
- * @typestring
- *
- * @param CommadNameColor
- * @text 命令名称颜色
- * @desc 命令名称颜色索引号。
- * @type number
- * @default0
- * @min0
- *
- * @param iconId
- * @text 图标索引号
- * @desc 对应图标的ID号。
- * @type number
- * @default0
- * @min0
- *
- */
- var Imported = Imported || {};
- Imported.NUUN_CommandIcon = true;
- (() => {
- const parameters = PluginManager.parameters('NUUN_CommandIcon');
- const param = JSON.parse(JSON.stringify(parameters, function(key, value){
- try {
- return JSON.parse(value);
- }catch(e){
- try {
- returneval(value);
- }catch(e){
- return value;
- }
- }
- }));
- const _Window_Command_itemTextAlign = Window_Command.prototype.itemTextAlign;
- Window_Command.prototype.itemTextAlign = function(){
- switch (param.CommandPosition){
- case0:
- return"left";
- case1:
- return _Window_Command_itemTextAlign.call(this);
- case2:
- return"right";
- }
- };
- const _Window_HorzCommand_itemTextAlign = Window_HorzCommand.prototype.itemTextAlign;
- Window_HorzCommand.prototype.itemTextAlign = function(){
- switch (param.HorzCommandPosition){
- case0:
- return"left";
- case1:
- return _Window_HorzCommand_itemTextAlign.call(this);
- case2:
- return"right";
- }
- };
- const _Window_Command_drawItem = Window_Command.prototype.drawItem;
- Window_Command.prototype.drawItem = function(index){
- const commadName = this.commandName(index);
- const foundIndex = param.CommadIcon ? param.CommadIcon.findIndex(Commad => (Commad.CommadName === commadName)) : null;
- if(foundIndex >= 0){
- const commadData = param.CommadIcon[foundIndex];
- const rect = this.itemLineRect(index);
- const align = this.itemTextAlign();
- const iconY = rect.y + (this.lineHeight() - ImageManager.iconHeight) / 2;
- const textMargin = commadData.iconId > 0 ? ImageManager.iconWidth + 4 : 0;
- const textWidth = this.textWidth(commadName);
- const itemWidth = Math.max(0, rect.width - textMargin);
- const width = Math.min(itemWidth, textWidth);
- const color = commadData.CommadNameColor ? commadData.CommadNameColor : 0;
- this.changeTextColor(ColorManager.textColor(color));
- this.changePaintOpacity(this.isCommandEnabled(index));
- if(commadData.iconId > 0){
- if(align === 'center'){
- this.drawIcon(commadData.iconId, rect.x + (rect.width / 2 - width / 2) - textMargin / 2, iconY);
- }elseif(align === 'left'){
- this.drawIcon(commadData.iconId, rect.x, iconY);
- }else{
- this.drawIcon(commadData.iconId, rect.x + itemWidth - width, iconY);
- }
- }
- this.drawText(commadName, rect.x + textMargin, rect.y, itemWidth, align);
- this.resetTextColor();
- }else{
- _Window_Command_drawItem.call(this, index);
- }
- };
- })();
复制代码
本帖来自P1论坛作者我想我是兔,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址: https://rpg.blue/forum.php?mod=viewthread&tid=484386 若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。 |