//============================================================================= // セーブファイルを削除するコマンドを追加するプラグイン // FTKR_DeleteSavefile.js // プラグインNo : 69 // 作成者 : フトコロ // 作成日 : 2018/02/25 // 最終更新日 : 2020/05/01 // バージョン : v1.0.5 //============================================================================= var Imported = Imported || {}; Imported.FTKR_DSF = true; var FTKR = FTKR || {}; FTKR.DSF = FTKR.DSF || {}; //============================================================================= /*: @plugindesc v1.0.5 Plugin that adds a command to delete save files @author Futokoro @url https://github.com/munokura/futokoro-MV-plugins @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/futokoro-MV-plugins ). Original plugin by Futokoro. Please check the URL below for the latest version of the plugin. URL https://github.com/futokoro/RPGMaker ----- ----------------------------------------------------------------------------- Overview ----------------------------------------------------------------------------- You can delete save files from the save screen or continue screen. You can also display a confirmation screen upon deletion. The following can be configured using plugin parameters. 1. Name of the command to display 2. Sound effect upon deletion 3. Text to display upon deletion and its window settings ----------------------------------------------------------------------------- Setup Method ----------------------------------------------------------------------------- 1. Add this plugin to the "Plugin Manager." ----------------------------------------------------------------------------- License for this Plugin ----------------------------------------------------------------------------- This plugin is released under the MIT License. Copyright (c) 2018 Futokoro http://opensource.org/licenses/mit-license.php Plugin Publisher https://github.com/futokoro/RPGMaker/blob/master/README.md ----------------------------------------------------------------------------- Change History ----------------------------------------------------------------------------- v1.0.5 - 2020/05/01: Bug Fixes 1. Fixed an issue where the save data under the cursor would disappear if the Confirm key was pressed repeatedly while loading save data. (by elleonard) 2. Fixed an issue where the confirmation window frame would not appear when was disabled. 3. Fixed a method defined by an override. v1.0.4 - 2018/04/06: Specification Changes 1. Partially revised the processing when plugin parameters are left blank. v1.0.3 - April 4, 2018: Bug fixes 1. Fixed an issue where changing windowskin settings would not be Reflectioned on initial display. v1.0.2 - April 3, 2018: Traits additions 1. Added a confirmation sound effect when selecting a file for deletion. 2. Added the ability to individually configure the confirmation screen window. v1.0.1 - March 1, 2018: Specification changes 1. Changed the initial cursor position on the confirmation screen to "Don't execute." v1.0.0 - February 25, 2018: Initial version created ----------------------------------------------------------------------------- @param --コマンド名-- @text --Command Name-- @param Save Command Name @desc Save command name on the save screen @default セーブ @param Load Command Name @desc Load command name on the continue screen @default ロード @param Delete Command Name @desc The name of the command to delete the save file @default 削除 @param --セーブファイル削除SE-- @text --Save file deletion SE-- @param Delete File Se @desc Specifies the sound effect to play when deleting a save file. If not set, the "Confirm" sound will be played. @type struct @param --削除確認-- @text --Delete confirmation-- @param Enable Confirmation @desc Confirm before deleting? @default true @type boolean @on confirm @off Do not confirm @param Conf Title Format @desc Describes the confirmation content when deleting a save file. %1 - File, %2 - File ID (control characters are allowed) @default %1%2 を削除しますか? @param Confirmation Ok Format @desc Describes what will be displayed when you click "Execute" in the confirmation command. @default 実行する @param Confirmation Cancel Format @desc Describes the display content of the confirmation command "Do not execute." @default 実行しない @param Enable Conf Window Setting @desc Enables the ability to set confirmation window settings separately from the save screen window. @default false @type boolean @on valid @off invalid @param Conf Window Setting @desc Sets the confirmation window. Use this setting when is enabled. @type struct */ /*~struct~sound: @param name @desc Specifies the name of the SE. @default Decision1 @type file @require 1 @dir audio/se @param volume @desc Specifies the volume of the SE. @default 90 @type number @max 100 @param pitch @desc Specifies the pitch of the SE. @default 100 @type number @min 50 @max 150 @param pan @desc Specifies the phase of the SE. @default 0 @type number @min -100 @max 100 */ /*~struct~window: @param windowskin @desc Specify the image to use for the window skin. If left blank, the default image will be used. @default Window @type file @require 1 @dir img/system/ @param width @desc Sets the window width. @default 544 @type number @min 1 @param opacity @desc Specify the transparency of the background in the window from 0 to 255. 0 is transparent. @default 192 @type number @min 0 @max 255 @param frame @desc Specifies whether to display the window frame. @default true @type boolean @on Show @off Do not display */ /*:ja @plugindesc v1.0.5 セーブファイルを削除するコマンドを追加するプラグイン @author Futokoro @url https://github.com/munokura/futokoro-MV-plugins @license MIT License @help ----------------------------------------------------------------------------- 概要 ----------------------------------------------------------------------------- セーブ画面やコンティニュー画面から、セーブファイルを削除できます。 削除時に確認画面を表示させることもできます。 プラグインパラメータで、以下を設定できます。 1. 表示するコマンドの名前 2. 削除時のSE 3. 削除時に表示する文章と、そのウィンドウ設定 ----------------------------------------------------------------------------- 設定方法 ----------------------------------------------------------------------------- 1.「プラグインマネージャー(プラグイン管理)」に、本プラグインを追加して ください。 ----------------------------------------------------------------------------- 本プラグインのライセンスについて(License) ----------------------------------------------------------------------------- 本プラグインはMITライセンスのもとで公開しています。 This plugin is released under the MIT License. Copyright (c) 2018 Futokoro http://opensource.org/licenses/mit-license.php プラグイン公開元 https://github.com/futokoro/RPGMaker/blob/master/README.md ----------------------------------------------------------------------------- 変更来歴 ----------------------------------------------------------------------------- v1.0.5 - 2020/05/01 : 不具合修正 1. セーブデータロード時に決定キーを連打すると、カーソルを合わせていた セーブデータが消える不具合を修正。(by elleonard氏) 2. を無効にした場合に、確認用ウィンドウの ウィンドウ枠が表示されない不具合を修正。 3. オーバーライドで定義していたメソッドを修正。 v1.0.4 - 2018/04/06 : 仕様変更 1. プラグインパラメータが空欄だった場合の処理を一部見直し。 v1.0.3 - 2018/04/04 : 不具合修正 1. windowskinを変更した場合に、初回表示時に反映されない不具合を修正。 v1.0.2 - 2018/04/03 : 機能追加 1. 削除でファイルを選択した時に決定SEを鳴らすように変更。 2. 確認画面のウィンドウを個別に設定する機能を追加。 v1.0.1 - 2018/03/01 : 仕様変更 1. 確認画面でカーソルの初期位置を「実行しない」に変更。 v1.0.0 - 2018/02/25 : 初版作成 ----------------------------------------------------------------------------- @param --コマンド名-- @text --コマンド名-- @param Save Command Name @desc セーブ画面でのセーブコマンドの名前 @default セーブ @param Load Command Name @desc コンティニュー画面でのロードコマンドの名前 @default ロード @param Delete Command Name @desc セーブファイルを削除するコマンドの名前 @default 削除 @param --セーブファイル削除SE-- @text --セーブファイル削除SE-- @param Delete File Se @desc セーブファイルを削除する時に鳴らすSEを指定します。設定しない場合は、「決定」音を鳴らします。 @type struct @param --削除確認-- @text --削除確認-- @param Enable Confirmation @desc 削除時に確認するか。 @default true @type boolean @on 確認する @off 確認しない @param Conf Title Format @desc セーブファイルを削除する時の確認内容を記述します。 %1 - ファイル, %2 - ファイルID (制御文字を使用できます) @default %1%2 を削除しますか? @param Confirmation Ok Format @desc 確認コマンドの「実行する」の表示内容を記述します。 @default 実行する @param Confirmation Cancel Format @desc 確認コマンドの「実行しない」の表示内容を記述します。 @default 実行しない @param Enable Conf Window Setting @desc 確認用ウィンドウ設定を、セーブ画面ウィンドウと別に設定する機能を有効にします。 @default false @type boolean @on 有効 @off 無効 @param Conf Window Setting @desc 確認用ウィンドウを設定します。が有効の場合にこの設定を使用します。 @type struct */ /*~struct~sound:ja @param name @desc SEの名前を指定します。 @default Decision1 @type file @require 1 @dir audio/se @param volume @desc SEの音量を指定します。 @default 90 @type number @max 100 @param pitch @desc SEのピッチを指定します。 @default 100 @type number @min 50 @max 150 @param pan @desc SEの位相を指定します。 @default 0 @type number @min -100 @max 100 */ /*~struct~window:ja @param windowskin @desc ウィンドウスキンに使用する画像を指定します。空欄にした場合はデフォルト画像を使用します。 @default Window @type file @require 1 @dir img/system/ @param width @desc ウィンドウの幅を設定します。 @default 544 @type number @min 1 @param opacity @desc ウィンドウ内の背景の透明率を0~255で指定します。0 で透明です。 @default 192 @type number @min 0 @max 255 @param frame @desc ウィンドウ枠を表示するか指定します。 @default true @type boolean @on 表示する @off 表示しない */ (function () { var paramParse = function (obj) { return JSON.parse(JSON.stringify(obj, paramReplace)); }; var paramReplace = function (key, value) { try { return JSON.parse(value || null); } catch (e) { return value; } }; //============================================================================= // プラグイン パラメータ //============================================================================= var parameters = PluginManager.parameters('FTKR_DeleteSavefile'); FTKR.DSF = { save: String(parameters['Save Command Name'] || 'セーブ'), load: String(parameters['Load Command Name'] || 'ロード'), delete: String(parameters['Delete Command Name'] || '削除'), deleteSe: paramParse(parameters['Delete File Se']), conf: { enabled: paramParse(parameters['Enable Confirmation']) || false, title: String(parameters['Conf Title Format'] || ''), ok: String(parameters['Confirmation Ok Format'] || ''), cancel: String(parameters['Confirmation Cancel Format'] || ''), setting: paramParse(parameters['Conf Window Setting']) || {}, } }; FTKR.DSF.conf.setting.enabled = paramParse(parameters['Enable Conf Window Setting']) || false; //============================================================================= // SoundManager //============================================================================= SoundManager.playDeleteSavefile = function () { var sound = FTKR.DSF.deleteSe; if (sound && sound.name) { AudioManager.playStaticSe(sound); } else { this.playSystemSound(1); } }; //============================================================================= // Scene_Boot //============================================================================= var _DSF_Scene_Boot_loadSystemWindowImage = Scene_Boot.prototype.loadSystemWindowImage; Scene_Boot.prototype.loadSystemWindowImage = function () { _DSF_Scene_Boot_loadSystemWindowImage.call(this); var set = FTKR.DSF.conf.setting; if (set.enabled && set.windowskin) { if (!!ImageManager.reserveSystem) { ImageManager.reserveSystem(set.windowskin); } else { ImageManager.loadSystem(set.windowskin); } } }; //============================================================================= // Scene_File //============================================================================= var _DSF_Scene_File_create = Scene_File.prototype.create; Scene_File.prototype.create = function () { _DSF_Scene_File_create.call(this); this.createCommandWindow(); this.changePositionWindow(); if (FTKR.DSF.conf.enabled) { this.createDsdConfWindows(); } }; //atWindowで指定したウィンドウの後に、addWindowで指定したウィンドウを_windowLayerのchildに加える。 Scene_File.prototype.addWindowAtW = function (addWindow, atWindow) { this._windowLayer.children.some(function (wchild, i) { if (wchild === atWindow) { windowIndex = i; return true; } }, this); this._windowLayer.addChildAt(addWindow, windowIndex); }; Scene_File.prototype.createCommandWindow = function () { var wx = 0; var wy = this._helpWindow.height; this._commandWindow = new Window_SavefileCommand(wx, wy, this.mode()); this._commandWindow.setHandler('list', this.onListOk.bind(this)); this._commandWindow.setHandler('delete', this.onDeleteOk.bind(this)); this._commandWindow.setHandler('cancel', this.popScene.bind(this)); this.addWindowAtW(this._commandWindow, this._helpWindow); }; Scene_File.prototype.changePositionWindow = function () { this._listWindow.y = this._commandWindow.y + this._commandWindow.height; this._listWindow.height = Graphics.boxHeight - this._listWindow.y; this._listWindow.deactivate(); this._listWindow.deselect(); }; Scene_File.prototype.createDsdConfWindows = function () { this.createDsdConfTitle(); this.createDsdConfCommand(); } Scene_File.prototype.createDsdConfTitle = function () { var wx = FTKR.DSF.conf.setting.enabled && FTKR.DSF.conf.setting.width ? (Graphics.boxWidth - FTKR.DSF.conf.setting.width) / 2 : Graphics.boxWidth / 6; var wy = Graphics.boxHeight / 2 - this._helpWindow.fittingHeight(1); this._confTitleWindow = new Window_DsdConfTitle(wx, wy); this.addWindow(this._confTitleWindow); this._confTitleWindow.hide(); }; Scene_File.prototype.createDsdConfCommand = function () { var wx = this._confTitleWindow.x; var wy = this._confTitleWindow.y + this._confTitleWindow.height; this._confCommandWindow = new Window_DsdConf(wx, wy); this._confCommandWindow.setHandler('delete', this.onConfirmationOk.bind(this)); this._confCommandWindow.setHandler('cancel', this.onConfirmationCancel.bind(this)); this.addWindow(this._confCommandWindow); this._confCommandWindow.hide(); this._confCommandWindow.deactivate(); }; Scene_File.prototype.onListOk = function () { this._delete = false; this._commandWindow.deactivate(); this._listWindow.activate(); this._listWindow.select(0); } Scene_File.prototype.onDeleteOk = function () { this._delete = true; this._commandWindow.deactivate(); this._listWindow.activate(); this._listWindow.select(0); }; Scene_File.prototype.onSavefileCancel = function () { this._delete = false; this._listWindow.deselect(); this._commandWindow.activate(); }; Scene_File.prototype.deleteSavefile = function () { if (FTKR.DSF.conf.enabled) { this._confTitleWindow.setSavefileId(this.savefileId()); this._confTitleWindow.show(); this._confCommandWindow.show(); this._confCommandWindow.activate(); this._confCommandWindow.select(1); } else { SoundManager.playDeleteSavefile(); StorageManager.remove(this.savefileId()); this._listWindow.refresh(); this._listWindow.activate(); } }; Scene_File.prototype.onConfirmationOk = function () { SoundManager.playDeleteSavefile(); StorageManager.remove(this.savefileId()); this._listWindow.refresh(); this._listWindow.activate(); this._confTitleWindow.hide(); this._confCommandWindow.deactivate(); this._confCommandWindow.hide(); }; Scene_File.prototype.onConfirmationCancel = function () { this._confTitleWindow.hide(); this._confCommandWindow.deactivate(); this._confCommandWindow.hide(); this._listWindow.activate(); }; //============================================================================= // Scene_Save //============================================================================= var _DSF_Scene_Save_onSavefileOk = Scene_Save.prototype.onSavefileOk; Scene_Save.prototype.onSavefileOk = function () { if (this._delete) { if (DataManager.isThisGameFile(this.savefileId())) { SoundManager.playOk(); this.deleteSavefile(); } else { this.onSaveFailure(); } } else { _DSF_Scene_Save_onSavefileOk.call(this); } }; //============================================================================= // Scene_Load //============================================================================= var _DSF_Scene_Load_onSavefileOk = Scene_Load.prototype.onSavefileOk; Scene_Load.prototype.onSavefileOk = function () { if (this._delete) { if (DataManager.isThisGameFile(this.savefileId())) { SoundManager.playOk(); this.deleteSavefile(); } else { this.onLoadFailure(); } } else { _DSF_Scene_Load_onSavefileOk.call(this); } }; //============================================================================= // Window_SavefileCommand //============================================================================= function Window_SavefileCommand() { this.initialize.apply(this, arguments); } Window_SavefileCommand.prototype = Object.create(Window_HorzCommand.prototype); Window_SavefileCommand.prototype.constructor = Window_SavefileCommand; Window_SavefileCommand.prototype.initialize = function (x, y, mode) { this._mode = mode; Window_HorzCommand.prototype.initialize.call(this, x, y); }; Window_SavefileCommand.prototype.windowWidth = function () { return Graphics.boxWidth; }; Window_SavefileCommand.prototype.maxCols = function () { return 2; }; Window_SavefileCommand.prototype.makeCommandList = function () { var listname = this._mode === 'save' ? FTKR.DSF.save : FTKR.DSF.load; this.addCommand(listname, 'list'); this.addCommand(FTKR.DSF.delete, 'delete', this.isDeleteFileEnabled()); }; Window_SavefileCommand.prototype.isDeleteFileEnabled = function () { return DataManager.isAnySavefileExists(); }; //============================================================================= // Window_DsdConfTitle //============================================================================= function Window_DsdConfTitle() { this.initialize.apply(this, arguments); } Window_DsdConfTitle.prototype = Object.create(Window_Base.prototype); Window_DsdConfTitle.prototype.constructor = Window_DsdConfTitle; Window_DsdConfTitle.prototype.initialize = function (x, y) { var set = FTKR.DSF.conf.setting; var width = set.enabled && set.width ? set.width : Graphics.boxWidth * 2 / 3; var height = this.fittingHeight(1); Window_Base.prototype.initialize.call(this, x, y, width, height); if (set.enabled && !set.frame) this.margin = 0; this._savefileId = 0; this.refresh(); }; Window_DsdConfTitle.prototype.setSavefileId = function (savefileId) { this._savefileId = savefileId; this.refresh(); } Window_DsdConfTitle.prototype.refresh = function () { this.contents.clear(); var text = FTKR.DSF.conf.title.format(TextManager.file, this._savefileId); this.drawTextEx(text, 0, 0); }; Window_DsdConfTitle.prototype.loadWindowskin = function () { if (FTKR.DSF.conf.setting.enabled && FTKR.DSF.conf.setting.windowskin) { this.windowskin = ImageManager.loadSystem(FTKR.DSF.conf.setting.windowskin); } else { Window_Base.prototype.loadWindowskin.call(this); } }; Window_DsdConfTitle.prototype.standardBackOpacity = function () { if (FTKR.DSF.conf.setting.enabled && FTKR.DSF.conf.setting.opacity >= 0) { return Number(FTKR.DSF.conf.setting.opacity); } else { return Window_Base.prototype.standardBackOpacity.call(this); } }; Window_DsdConfTitle.prototype._refreshFrame = function () { if (FTKR.DSF.conf.setting.enabled && FTKR.DSF.conf.setting.frame || !FTKR.DSF.conf.setting.enabled) { Window.prototype._refreshFrame.call(this); } }; //============================================================================= // Window_DsdConf //============================================================================= function Window_DsdConf() { this.initialize.apply(this, arguments); } Window_DsdConf.prototype = Object.create(Window_HorzCommand.prototype); Window_DsdConf.prototype.constructor = Window_DsdConf; Window_DsdConf.prototype.initialize = function (x, y) { Window_HorzCommand.prototype.initialize.call(this, x, y); if (FTKR.DSF.conf.setting.enabled && !FTKR.DSF.conf.setting.frame) this.margin = 0; }; Window_DsdConf.prototype.windowWidth = function () { return FTKR.DSF.conf.setting.enabled && FTKR.DSF.conf.setting.width ? FTKR.DSF.conf.setting.width : Graphics.boxWidth * 2 / 3; }; Window_DsdConf.prototype.maxCols = function () { return 2; }; Window_DsdConf.prototype.makeCommandList = function () { this.addCommand(FTKR.DSF.conf.ok, 'delete'); this.addCommand(FTKR.DSF.conf.cancel, 'cancel'); }; Window_DsdConf.prototype.loadWindowskin = function () { if (FTKR.DSF.conf.setting.enabled && FTKR.DSF.conf.setting.windowskin) { this.windowskin = ImageManager.loadSystem(FTKR.DSF.conf.setting.windowskin); } else { Window_Base.prototype.loadWindowskin.call(this); } }; Window_DsdConf.prototype.standardBackOpacity = function () { if (FTKR.DSF.conf.setting.enabled && FTKR.DSF.conf.setting.opacity >= 0) { return Number(FTKR.DSF.conf.setting.opacity); } else { return Window_Base.prototype.standardBackOpacity.call(this); } }; Window_DsdConf.prototype._refreshFrame = function () { if (FTKR.DSF.conf.setting.enabled && FTKR.DSF.conf.setting.frame || !FTKR.DSF.conf.setting.enabled) { Window.prototype._refreshFrame.call(this); } }; }());//EOF