/*=============================================================================
InputInvalidate.js
----------------------------------------------------------------------------
(C)2024 Triacontane
This software is released under the MIT License.
http://opensource.org/licenses/mit-license.php
----------------------------------------------------------------------------
Version
1.0.0 2024/11/02 初版
----------------------------------------------------------------------------
[Blog] : https://triacontane.blogspot.jp/
[X] : https://x.com/triacontane/
[GitHub] : https://github.com/triacontane/
=============================================================================*/
/*:
@target MZ
@url https://github.com/triacontane/RPGMakerMV/tree/mz_master/InputInvalidate.js
@plugindesc Button input disable plugin
@author Triacontane
@license MIT License
@help
English Help Translator: munokura
This is an unofficial English translation of the plugin help,
created to support global RPG Maker users.
Feedback is welcome to improve translation quality
(see: https://github.com/munokura/triacontane-MZ-plugins ).
Original plugin by Triacontane.
Please check the latest official version at:
https://triacontane.blogspot.com
-----
InputInvalidate.js
Disables input from the specified button when the specified switch is ON.
It does not affect touch input.
This plugin requires the base plugin "PluginCommonBase.js."
"PluginCommonBase.js" is located in the following folder under the RPG Maker
MZ installation folder:
dlc/BasicResources/plugins/official
Terms of Use:
You may modify and redistribute this plugin without permission, and there are
no restrictions on its use (commercial, 18+, etc.).
This plugin is now yours.
@param inputList
@text Input Disable Settings
@desc A list of settings to disable input. You cannot define multiple settings for buttons with the same name.
@type struct[]
@default []
*/
/*~struct~Input:
@param buttonName
@text Button Name
@desc The name of the button that disables input. If you have defined your own button name, enter the button name directly.
@type combo
@default ok
@option ok
@option cancel
@option shift
@option menu
@option pageup
@option pagedown
@option escape
@option debug
@option control
@option tab
@option left
@option up
@option right
@option down
@param switchId
@text Switch ID
@desc When ON, the specified button input will be disabled.
@type switch
@default 1
*/
/*:ja
@plugindesc ボタン入力無効化プラグイン
@target MZ
@url https://github.com/triacontane/RPGMakerMV/tree/mz_master/InputInvalidate.js
@base PluginCommonBase
@orderAfter PluginCommonBase
@author トリアコンタン
@param inputList
@text 入力無効化設定
@desc 入力を無効化する設定のリストです。同名のボタンの設定は複数定義できません。
@default []
@type struct[]
@help InputInvalidate.js
指定したスイッチがONのとき、指定したボタンの入力を無効化します。
タッチ入力には影響を与えません。
このプラグインの利用にはベースプラグイン『PluginCommonBase.js』が必要です。
『PluginCommonBase.js』は、RPGツクールMZのインストールフォルダ配下の
以下のフォルダに格納されています。
dlc/BasicResources/plugins/official
利用規約:
作者に無断で改変、再配布が可能で、利用形態(商用、18禁利用等)
についても制限はありません。
このプラグインはもうあなたのものです。
*/
/*~struct~Input:ja
@param buttonName
@text ボタン名称
@desc 入力を無効化するボタンの名称です。独自に定義している場合はボタン名を直接入力します。
@default ok
@type combo
@option ok
@option cancel
@option shift
@option menu
@option pageup
@option pagedown
@option escape
@option debug
@option control
@option tab
@option left
@option up
@option right
@option down
@param switchId
@text スイッチID
@desc ONのとき、指定したボタンの入力を無効化します。
@default 1
@type switch
*/
(() => {
'use strict';
const script = document.currentScript;
const param = PluginManagerEx.createParameter(script);
if (!param.inputList) {
return;
}
const buttonMap = new Map();
param.inputList.forEach(input => {
buttonMap.set(input.buttonName, input.switchId);
});
const _Input_isPressed = Input.isPressed;
Input.isPressed = function(keyName) {
return _Input_isPressed.apply(this, arguments) && !this.isInvalid(keyName);
};
const _Input_isTriggered = Input.isTriggered;
Input.isTriggered = function(keyName) {
return _Input_isTriggered.apply(this, arguments) && !this.isInvalid(keyName);
};
const _Input_isRepeated = Input.isRepeated;
Input.isRepeated = function(keyName) {
return _Input_isRepeated.apply(this, arguments) && !this.isInvalid(keyName);
};
const _Input_isLongPressed = Input.isLongPressed;
Input.isLongPressed = function(keyName) {
return _Input_isLongPressed.apply(this, arguments) && !this.isInvalid(keyName);
};
Input.isInvalid = function(keyName) {
return buttonMap.has(keyName) && $gameSwitches ? $gameSwitches.value(buttonMap.get(keyName)) : false;
}
})();