【汉化】r88自定义按键
本帖最后由 烁灵 于 2024-6-20 17:43 编辑可自定义按键、禁用鼠标控制、按键触发公共事件
原地址:Custom Controls (RMMZ Plugin) by reflector88 (itch.io)
汉化脚本:命名为 r88_CustomControls.js
/*:
@target MZ
@plugindesc 提供更多控制方法
汉化 by 烁灵 更多插件请访问 www.hknmtt.com
@author reflector88
@url https://reflector88.itch.io/
@help
"Custom Controls 1.3"
本插件提供更多可配置的控制方法(RPG MAKER 原版应该有这些功能,但是并没有)
同时提供一些快捷键,用于打开菜单、调用公共事件
Update
-V1.1 Improved compatibility
-V1.2 Gamepad buttons can be mapped to common events
-V1.3 (5/31) Refactored code. Added support for Left and Right Triggers and
Start and Select buttons. Gamepad names are less misleading.
___________________________________________________________________________
配置:
1. 双击参数打开列表窗口、你可以设置任意数量的按键
2. 在文本框中键入按建名. 多功能键和小键盘使用如下文本:
● alt ● backspace ● num0 - num9
● arrowdown ● capslock ● shift
● arrowleft ● ctrl ● space
● arrowright ● enter ● tab
● arrowup ● esc
摇杆比较复杂. 摇杆按键各不相同,对如下按键名,你可以多试几次来确定对应的按键:
● gpadup ● gpad0 ● gpad4 ● gpad8
● gpaddown ● gpad1 ● gpad5 ● gpad9
● gpadleft ● gpad2 ● gpad6 ● gpad10
● gpadright ● gpad3 ● gpad7 ● gpad11
gpad0-3 通常为方向键
gpad4-7 通常为触发键
gpad8-11 通常为开始、选择、其他按键
3. "禁用鼠标控制" 禁用鼠标和触摸,同时去掉右上角菜单键
___________________________________________________________________________
TERMS OF USE
This plugin is free to use in both commercial and non-commercial projects,
though please credit me.
@param Up
@text 上
@type string[]
@default ["arrowup", "gpadup"]
@param Down
@text 下
@type string[]
@default ["arrowdown", "gpaddown"]
@param Left
@text 左
@type string[]
@default ["arrowleft", "gpadleft"]
@param Right
@text 右
@type string[]
@default ["arrowright", "gpadright"]
@param Confirm
@text 确认
@type string[]
@default ["z", "gpad0"]
@param Cancel/Menu
@text 取消/菜单
@type string[]
@default ["x", "esc"]
@param Sprint
@text 跑步
@type string[]
@default ["shift", "gpad2"]
@param Noclip
@text 穿墙
@type string[]
@default ["ctrl"]
@param Cancel
@text 取消
@type string[]
@default ["gpad1"]
@param Menu Scene
@text 菜单
@type string[]
@default ["gpad3"]
@param Item Scene
@text 物品界面
@type string[]
@default []
@param Skill Scene
@text 技能界面
@type string[]
@default []
@param Equip Scene
@text 装备界面
@type string[]
@default []
@param Options Scene
@text 选项界面
@type string[]
@default []
@param Save Scene
@text 存档界面
@type string[]
@default []
@param Load Scene
@text 读档界面
@type string[]
@default []
@param Common Events
@text 调用公共事件
@type struct<CommonEventsStruct>[]
@desc 设定调用公共事件的热键
@default []
@param Disable Mouse Controls
@text 禁用鼠标控制
@type boolean
@default false
@param Disable UI Buttons
@text 禁用UI按键
@type boolean
@default false
*/
/*~struct~CommonEventsStruct:
@param Key
@text 按键
@type string
@param ID
@text 公共事件ID
@type common_event
*/
(() => {
'use strict';
const parameters = PluginManager.parameters('r88_CustomControls');
const commonEvents = JSON.parse(parameters['Common Events']);
const keyCodes = new Map([
["1", "49"], ["2", "50"], ["3", "51"], ["4", "52"], ["5", "53"], ["6", "54"], ["7", "55"], ["8", "56"],
["9", "57"], ["backspace", "8"], ["tab", "9"], ["enter", "13"], ["shift", "16"], ["ctrl", "17"], ["alt", "18"], ["capslock", "20"], ["esc", "27"],
["space", "32"], ["arrowleft", "37"], ["arrowup", "38"], ["arrowright", "39"], ["arrowdown", "40"], ["a", "65"],
["b", "66"], ["c", "67"], ["d", "68"], ["e", "69"], ["f", "70"], ["g", "71"], ["h", "72"], ["i", "73"], ["j", "74"],
["k", "75"], ["l", "76"], ["m", "77"], ["n", "78"], ["o", "79"], ["p", "80"], ["q", "81"], ["r", "82"], ["s", "83"],
["t", "84"], ["u", "85"], ["v", "86"], ["w", "87"], ["x", "88"], ["y", "89"], ["z", "90"], ["num0", "96"],
["num1", "97"], ["num2", "98"], ["num3", "99"], ["num4", "100"], ["num5", "101"], ["num6", "102"], ["num7", "103"],
["num8", "104"], ["num9", "105"], ["=", "187"], [",", "188"], ["-", "189"], [".", "190"], ["/", "191"], ["`", "192"],
["[", "219"], ["\\", "220"], ["]", "221"]
]);
const buttonCodes = new Map([
["gpad0", "0"], ["gpad1", "1"], ["gpad2", "2"], ["gpad3", "3"], ["gpad4", "4"], ["gpad5", "5"],
["gpad6", "6"], ["gpad7", "7"], ["gpad8", "8"], ["gpad9", "9"], ["gpad10", "10"],
["gpad11", "11"], ["gpadup", "12"], ["gpaddown", "13"], ["gpadleft", "14"], ["gpadright", "15"],
])
const keyMappings = new Map([
["Up", "up"], ["Left", "left"], ["Down", "down"], ["Right", "right"], ["Confirm", "ok"], ["Cancel/Menu", "escape"],
["Sprint", "shift"], ["Noclip", "control"], ["Cancel", "cancel"], ["Menu Scene", "openMenu"], ["Item Scene", "openItem"],
["Skill Scene", "openSkill"], ["Equip Scene", "openEquip"], ["Options Scene", "openOptions"], ["Save Scene", "openSave"],
["Load Scene", "openLoad"]
]);
for (const key of ) {
delete Input.keyMapper;
}
for (const key of ) {
delete Input.gamepadMapper;
}
if (JSON.parse(parameters['Disable Mouse Controls'])) {
TouchInput.initialize = function () { this.clear() };
TouchInput._onMouseDown = function (event) { };
}
if (JSON.parse(parameters['Disable UI Buttons'])) {
Scene_Map.prototype.createButtons = function () { };
Scene_Battle.prototype.createButtons = function () { };
Scene_MenuBase.prototype.createButtons = function () { };
}
for (const of keyMappings) {
const binds = JSON.parse(parameters);
for (const bind of binds) {
if (keyCodes.has(bind)) Input.keyMapper = action;
else if (buttonCodes.has(bind)) Input.gamepadMapper = action;
}
}
for (const commonEvent of commonEvents) {
const bind = JSON.parse(commonEvent)["Key"];
const ID = JSON.parse(commonEvent)["ID"];
if (keyCodes.has(bind)) Input.keyMapper = 'commonEvent' + ID;
else if (buttonCodes.has(bind)) Input.gamepadMapper = 'commonEvent' + ID;
}
const scenes = ["Menu", "Item", "Skill", "Equip", "Options", "Save", "Load"];
const Scene_Map_update = Scene_Map.prototype.update;
Scene_Map.prototype.update = function () {
Scene_Map_update.apply(this, arguments);
for (const scene of scenes) {
if (Input.isTriggered("open" + scene)) SceneManager.push(eval?.("Scene_" + scene));
}
for (const commonEvent of commonEvents) {
const ID = JSON.parse(commonEvent)["ID"];
if (Input.isTriggered('commonEvent' + ID)) {
$gameTemp.reserveCommonEvent(ID);
}
}
};
for (const scene of scenes) {
closeScene(eval?.("Scene_" + scene), "open" + scene);
}
function closeScene(sceneClass, trigger) {
const Scene_update = sceneClass.prototype.update;
sceneClass.prototype.update = function () {
Scene_update.apply(this, arguments);
if (Input.isTriggered(trigger)) {
SoundManager.playCancel();
SceneManager.pop();
}
};
}
})();
页:
[1]