//============================================================================= // SaveFileLoadOnly.js // ---------------------------------------------------------------------------- // Copyright (c) 2015-2017 Triacontane // This software is released under the MIT License. // http://opensource.org/licenses/mit-license.php // ---------------------------------------------------------------------------- // Version // 1.0.0 2017/08/09 初版 // ---------------------------------------------------------------------------- // [Blog] : https://triacontane.blogspot.jp/ // [Twitter]: https://twitter.com/triacontane/ // [GitHub] : https://github.com/triacontane/ //============================================================================= /*: @url https://triacontane.blogspot.com/ @plugindesc A plugin dedicated to loading save files @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-MV-plugins ). Original plugin by Triacontane. Please check the latest official version at: https://triacontane.blogspot.com ----- SaveFileLoadOnly.js Makes a specific save file read-only. Specify the load-only condition as a parameter. You can use a calculation expression. Example: fileId === 1 # Makes file ID [1] read-only. fileId === \v[1] # Makes file ID [value of variable [1]] read-only. fileId >= 1 && fileId <= 3 # Makes file IDs [1-3] read-only. This plugin does not have a plugin command. Terms of Use: You may modify and redistribute this plugin without permission from the author, and there are no restrictions on its use (commercial, 18+, etc.). This plugin is now yours. @param ロード専用条件 @text Load-only conditions @desc This is a load-only target criterion. The control character \v[n] can be used. @default fileId === 1 @param ロード専用アイコンID @text Road-specific icon ID @desc The icon ID that will be drawn only for load-only files in the save file window. @type number @default 195 */ /*:ja @plugindesc セーブファイルのロード専用化プラグイン @author トリアコンタン @param ロード専用条件 @desc ロード専用対象の判定式です。制御文字\v[n]が使用できます。 @default fileId === 1 @param ロード専用アイコンID @desc セーブファイルウィンドウで、ロード専用ファイルにのみ描画されるアイコンIDです。 @default 195 @type number @help SaveFileLoadOnly.js 特定のセーブファイルを読み取り専用にできます。 パラメータでロード専用条件を指定してください。指定には計算式が使えます。 指定例: fileId === 1 # ファイルID[1]を読み取り専用にします。 fileId === \v[1] # ファイルID[変数[1]の値]を読み取り専用にします。 fileId >= 1 && fileId <= 3 # ファイルID[1-3]を読み取り専用にします。 このプラグインにはプラグインコマンドはありません。 利用規約: 作者に無断で改変、再配布が可能で、利用形態(商用、18禁利用等) についても制限はありません。 このプラグインはもうあなたのものです。 */ (function () { 'use strict'; var pluginName = 'SaveFileLoadOnly'; //============================================================================= // ローカル関数 // プラグインパラメータやプラグインコマンドパラメータの整形やチェックをします //============================================================================= var getParamString = function (paramNames) { if (!Array.isArray(paramNames)) paramNames = [paramNames]; for (var i = 0; i < paramNames.length; i++) { var name = PluginManager.parameters(pluginName)[paramNames[i]]; if (name) return name; } return ''; }; var getParamNumber = function (paramNames, min, max) { var value = getParamString(paramNames); if (arguments.length < 2) min = -Infinity; if (arguments.length < 3) max = Infinity; return (parseInt(value) || 0).clamp(min, max); }; var convertEscapeCharacters = function (text) { if (isNotAString(text)) text = ''; var windowLayer = SceneManager._scene._windowLayer; return windowLayer ? windowLayer.children[0].convertEscapeCharacters(text) : text; }; var isNotAString = function (args) { return String(args) !== args; }; //============================================================================= // パラメータの取得と整形 //============================================================================= var param = {}; param.conditionRoadOnly = getParamString(['ConditionRoadOnly', 'ロード専用条件']); param.roadOnlyIconId = getParamNumber(['RoadOnlyIconId', 'ロード専用アイコンID'], 0); //============================================================================= // Window_SavefileList // ロード専用ファイルの判定を追加定義します。 //============================================================================= var _Window_SavefileList_isCurrentItemEnabled = Window_SavefileList.prototype.isCurrentItemEnabled; Window_SavefileList.prototype.isCurrentItemEnabled = function () { return _Window_SavefileList_isCurrentItemEnabled.apply(this, arguments) && !this.isCurrentItemLoadOnly(); }; Window_SavefileList.prototype.isCurrentItemLoadOnly = function () { return this.isModeSave() && this.isLoadOnly(this._index + 1); }; Window_SavefileList.prototype.isLoadOnly = function (fileId) { var conditionFormula = convertEscapeCharacters(param.conditionRoadOnly); var result; try { result = !!eval(conditionFormula); } catch (e) { console.error(e.toString()); throw new Error('Failed To Execute Script :' + conditionFormula); } return result; }; var _Window_SavefileList_drawFileId = Window_SavefileList.prototype.drawFileId; Window_SavefileList.prototype.drawFileId = function (id, x, y) { _Window_SavefileList_drawFileId.apply(this, arguments); if (this.isLoadOnly(id) && param.roadOnlyIconId > 0) { this.drawIcon(param.roadOnlyIconId, x + 188 - Window_Base._iconWidth, y + 2); } }; Window_SavefileList.prototype.isModeSave = function () { return this._mode === 'save'; }; })();