Skip to content

Instantly share code, notes, and snippets.

@triacontane
Last active November 7, 2023 13:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save triacontane/fe0881c2a19831f646cb4aa0d8113a8f to your computer and use it in GitHub Desktop.
Save triacontane/fe0881c2a19831f646cb4aa0d8113a8f to your computer and use it in GitHub Desktop.
アクター切り替え禁止プラグイン[PD]
/*:
* @target MZ
* @plugindesc アクター切り替え禁止プラグイン[PD]
* @author ChatGPT
*
* @param DisableSwitchID
* @text 無効化スイッチID
* @desc ページ切り替え機能を無効にするスイッチのID
* @type switch
* @default 1
*
* @help
* このプラグインはパブリックドメインで提供されています。
* どなたでも自由に使用、改変、再配布可能です。
*
* このプラグインにはプラグインコマンドはありません。
*
* このプラグインは、指定したスイッチがONのときに、
* スキル画面や装備画面でのPageUp/PageDownボタンによる
* アクター切り替え機能を無効にします。
*
* スイッチIDをプラグインパラメータで指定してください。
*/
(() => {
'use strict';
const pluginName = 'DisablePageButtons';
const parameters = PluginManager.parameters(pluginName);
const disableSwitchID = Number(parameters['DisableSwitchID']);
// スイッチによる判定を別メソッドに分離
function isPageChangeDisabled() {
return $gameSwitches.value(disableSwitchID);
}
// nextActorのメソッドをオーバーライドする
const _Scene_MenuBase_nextActor = Scene_MenuBase.prototype.nextActor;
Scene_MenuBase.prototype.nextActor = function() {
if (isPageChangeDisabled()) {
this.onActorChange();
} else {
_Scene_MenuBase_nextActor.call(this);
}
};
// previousActorのメソッドをオーバーライドする
const _Scene_MenuBase_previousActor = Scene_MenuBase.prototype.previousActor;
Scene_MenuBase.prototype.previousActor = function() {
if (isPageChangeDisabled()) {
this.onActorChange();
} else {
_Scene_MenuBase_previousActor.call(this);
}
};
// onActorChangeメソッドをオーバーライドして効果音の演奏を制御する
const _Scene_MenuBase_onActorChange = Scene_MenuBase.prototype.onActorChange;
Scene_MenuBase.prototype.onActorChange = function() {
if (!isPageChangeDisabled()) {
_Scene_MenuBase_onActorChange.call(this);
}
};
const _Scene_MenuBase_createPageButtons = Scene_MenuBase.prototype.createPageButtons;
Scene_MenuBase.prototype.createPageButtons = function() {
_Scene_MenuBase_createPageButtons.call(this);
this.updatePageButtonsVisibly();
};
// updatePageButtonsを再定義する
const _Scene_MenuBase_updatePageButtons = Scene_MenuBase.prototype.updatePageButtons;
Scene_MenuBase.prototype.updatePageButtons = function() {
_Scene_MenuBase_updatePageButtons.call(this);
this.updatePageButtonsVisibly();
};
Scene_MenuBase.prototype.updatePageButtonsVisibly = function() {
if (isPageChangeDisabled() && this._pageupButton && this._pagedownButton) {
this._pageupButton.visible = false;
this._pagedownButton.visible = false;
}
};
})();
@triacontane
Copy link
Author

triacontane commented Nov 7, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment