// DarkPlasma_TitleCommand 1.0.2 // Copyright (c) 2021 DarkPlasma // This software is released under the MIT license. // http://opensource.org/licenses/mit-license.php /** * 2024/03/17 1.0.2 TypeScript移行 * 2021/07/05 1.0.1 MZ 1.3.2に対応 * 2021/06/27 1.0.0 公開 */ /*: @target MZ @url https://github.com/elleonard/DarkPlasma-MZ-Plugins/tree/release @plugindesc Set the title command @author DarkPlasma @license MIT @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/DarkPlasma-MZ-Plugins ). Original plugin by DarkPlasma. Please check the latest official version at: https://github.com/elleonard/DarkPlasma-MZ-Plugins/tree/release ----- version: 1.0.2 Set the title command. @param additionalCommands @text Additional Commands @desc Sets the list of additional title commands. @type struct[] @default [] */ /*:ja @plugindesc タイトルコマンドを設定する @author DarkPlasma @license MIT @target MZ @url https://github.com/elleonard/DarkPlasma-MZ-Plugins/tree/release @param additionalCommands @desc 追加のタイトルコマンド一覧を設定します。 @text 追加コマンド @type struct[] @default [] @help version: 1.0.2 タイトルコマンドを設定します。 */ (() => { 'use strict'; const pluginName = document.currentScript.src.replace(/^.*\/(.*).js$/, function () { return arguments[1]; }); const pluginParametersOf = (pluginName) => PluginManager.parameters(pluginName); const pluginParameters = pluginParametersOf(pluginName); const settings = { additionalCommands: JSON.parse(pluginParameters.additionalCommands || '[]').map((e) => { return ((parameter) => { const parsed = JSON.parse(parameter); return { commandType: Number(parsed.commandType || 0), position: Number(parsed.position || 3), text: String(parsed.text || ``), symbol: String(parsed.symbol || ``), scene: String(parsed.scene || ``), }; })(e || '{}'); }), }; function selectedScene(symbol) { const command = settings.additionalCommands.find((command) => command.symbol === symbol); return command ? window[command.scene] || null : null; } const _Scene_Title_createCommandWindow = Scene_Title.prototype.createCommandWindow; Scene_Title.prototype.createCommandWindow = function () { _Scene_Title_createCommandWindow.call(this); settings.additionalCommands.forEach((command) => { const handler = command.commandType === 1 ? this.commandSceneChange.bind(this) : this.commandShutdown.bind(this); this._commandWindow.setHandler(command.symbol, handler); }); }; const _Scene_Title_commandWindowRect = Scene_Title.prototype.commandWindowRect; Scene_Title.prototype.commandWindowRect = function () { const rect = _Scene_Title_commandWindowRect.call(this); return new Rectangle( rect.x, rect.y, rect.width, this.calcWindowHeight(3 + settings.additionalCommands.length, true), ); }; Scene_Title.prototype.commandSceneChange = function () { this._commandWindow.close(); const scene = selectedScene(this._commandWindow.currentSymbol()); if (!scene) { throw `シンボル ${this._commandWindow.currentSymbol()} に無効なシーンが指定されています。`; } SceneManager.push(scene); }; Scene_Title.prototype.commandShutdown = function () { if (StorageManager.isLocalMode()) { window.close(); } else { window.open('about:blank', '_self')?.close(); } }; const _Window_TitleCommand_makeCommandList = Window_TitleCommand.prototype.makeCommandList; Window_TitleCommand.prototype.makeCommandList = function () { _Window_TitleCommand_makeCommandList.call(this); settings.additionalCommands.forEach((command) => { this.addCommandAt(command.position, command.text, command.symbol); }); }; Window_TitleCommand.prototype.addCommandAt = function (index, name, symbol, enabled = true, ext = null) { this._list.splice(index, 0, { name: name, symbol: symbol, enabled: enabled, ext: ext, }); }; })();