//============================================================================= // EISLockSaveSlots.js //============================================================================= /*: * * @author Kino * @plugindesc Locks save slots in game so the user can't save over them. * * @param Save Slot IDs * @desc List of save IDs to lock by number. * @default 1, 2, 4 * * @help * Version 1.00 * This plugin prevents the user from using a save slot that you specify as locked. * via your entered numbers. You can select those slots, but you can't save over them. * Make sure to put a comma space after entering your first number. You can also enter * one number if you prefer. * //============================================================================= // Contact Information //============================================================================= * * Contact me via twitter: EISKino, or on the rpg maker forums. * Username on forums: Kino. * * Forum Link: http://forums.rpgmakerweb.com/index.php?/profile/75879-kino/ * Twitter Link: https://twitter.com/EISKino * * Hope this plugin helps, and enjoy! * --Kino */ var KR = KR || {}; KR.Plugins = KR.Plugins || {}; (function($) { var parameters = PluginManager.parameters("EISLockSaveSlots"); var saveSlotIDs = String(parameters['Save Slot IDs']); $.Plugins.lockSaveSlotsSetup = function () { 'use strict'; //============================================================================= // SaveSlotManager //============================================================================= function SaveSlotManager() { } SaveSlotManager.initiliaze = function() { this.disabledSaveIDList = SaveSlotIDParser.parseSaveIds(saveSlotIDs); }; SaveSlotManager.isInDisabledIDList = function(idNumber) { var list = this.disabledSaveIDList; for(var i = 0; i < list.length; i++) { if(idNumber === list[i]) return true; } return false; }; //============================================================================= // SaveSlotIDParser //============================================================================= function SaveSlotIDParser() { } SaveSlotIDParser.parseSaveIds = function(saveSlotIDList) { var parsedIDs = saveSlotIDList.split(", "); parsedIDs.forEach(function(item, index) { parsedIDs[index] = Number(item); }); return parsedIDs; }; //============================================================================= // SaveSlotManager Initialization //============================================================================= SaveSlotManager.initiliaze(); //============================================================================= // Window_SaveFileList //============================================================================= Window_SavefileList.prototype.isCurrentItemEnabled = function() { return (this.isSlotDisabledForSave(this.index())) ? false : true; }; Window_SavefileList.prototype.drawItem = function(index) { var id = index + 1; var valid = DataManager.isThisGameFile(id); var info = DataManager.loadSavefileInfo(id); var rect = this.itemRectForText(index); this.resetTextColor(); if (this._mode === 'load') { this.changePaintOpacity(valid); } if(this.isSlotDisabledForSave(index)) this.drawDisabled(id, info, rect, valid); else { this.changePaintOpacity(valid); this.drawFileId(id, rect.x, rect.y); if (info) { this.changePaintOpacity(valid); this.drawContents(info, rect, valid); this.changePaintOpacity(true); } } }; Window_SavefileList.prototype.drawDisabled = function(id, info, rect, valid) { this.changePaintOpacity(false); this.drawFileId(id, rect.x, rect.y); this.drawContents(info, rect, valid); }; Window_SavefileList.prototype.isSlotDisabledForSave = function(index) { if(this.isSaveMode() && this.slotInDisabledList(index)) { return true; } else return false; }; Window_SavefileList.prototype.slotInDisabledList = function(index) { var saveID = index + 1; if(SaveSlotManager.isInDisabledIDList(saveID)) return true; else return false; }; Window_SavefileList.prototype.isSaveMode = function() { return (this._mode === 'save') ? true : false; }; }; $.Plugins.lockSaveSlotsSetup(); })(KR);