You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1516 lines
50 KiB
JavaScript

3 years ago
//=============================================================================
// Yanfly Engine Plugins - Save Core
// YEP_SaveCore.js
//=============================================================================
var Imported = Imported || {};
Imported.YEP_SaveCore = true;
var Yanfly = Yanfly || {};
Yanfly.Save = Yanfly.Save || {};
Yanfly.Save.version = 1.06;
//=============================================================================
/*:
3 years ago
* @plugindesc v1.06 存档核心
* @author Yanfly Engine Plugins
*
* @param ---General---
* @text ---全局---
* @default
*
* @param Max Files
* @text 最大存档数
* @parent ---General---
* @type number
* @min 1
* @desc The maximum number of files for your game.
* Default: 20
* @default 24
*
* @param Saved Icon
* @text 保存的图标
* @parent ---General---
* @type number
* @min 0
* @desc Icon ID used for a file slot with a save.
* @default 231
*
* @param Empty Icon
* @text 空文件图标
* @parent ---General---
* @type number
* @min 0
* @desc Icon ID used for an empty file slot.
* @default 230
*
* @param Return After Saving
* @text 保存后返回
* @parent ---General---
* @type boolean
* @on YES
* @off NO
* @desc Return to the previous scene after saving?
* NO - false YES - true Default: true
* @default false
*
3 years ago
* @param Auto New Index
* @text 自动新建索引
* @parent ---General---
* @type boolean
* @on YES
* @off NO
* @desc For new games, automatically decide the save slot?
* NO - false YES - true Default: true
* @default true
*
* @param ---Action Window---
* @text ---动作窗口---
* @default
*
* @param Load Command
* @text 加载命令
* @parent ---Action Window---
* @desc Text for the load command in the action window.
* @default 加载
*
* @param Save Command
* @text 保存命令
* @parent ---Action Window---
* @desc Text for the save command in the action window.
* @default 保存
*
* @param Delete Command
* @text 删除命令
* @parent ---Action Window---
* @desc Text for the delete command in the action window.
* @default 删除
*
* @param ---Help Window---
* @text ---帮助窗口---
* @default
*
* @param Select Help
* @text 选择帮助
* @parent ---Help Window---
* @desc Help text displayed when selecting a slot.
* @default 请选择一个文件槽
*
* @param Load Help
* @text 加载帮助
* @parent ---Help Window---
* @desc Help text displayed when selecting load option.
* @default 加载当前进度
*
* @param Save Help
* @text 保存帮助
* @parent ---Help Window---
* @desc Help text displayed when selecting save option.
* @default 保存当前进度
*
* @param Delete Help
* @text 删除帮助
* @parent ---Help Window---
* @desc Help text displayed when selecting delete option.
* @default 删除当前进度
*
* @param ---Delete---
* @text ---删除---
* @default
*
* @param Delete Filename
* @text 删除文件名
* @parent ---Delete---
* @type file
* @dir audio/se/
* @require 1
* @desc Used for the delete sound from the /audio/se/ folder.
* Do NOT include the file extension.
* @default Damage2
*
* @param Delete Volume
* @parent ---Delete---
* @desc Volume used for the delete sound.
* @default 100
*
* @param Delete Pitch
* @parent ---Delete---
* @desc Pitch used for the delete sound.
* @default 150
*
* @param Delete Pan
* @parent ---Delete---
* @desc Pan used for the delete sound.
* @default 0
*
* @param ---Info Window---
* @text ---信息窗口---
* @default
*
* @param Show Game Title
* @text 显示游戏标题
* @parent ---Info Window---
* @type boolean
* @on Show
* @off Hide
* @desc Display the game title in the save file?
* NO - false YES - true
* @default true
*
* @param Invalid Game Text
* @text 无效的游戏文本
* @parent ---Info Window---
* @desc Text used when the save is for a different game.
* @default 这是另一个游戏的保存
*
* @param Empty Game Text
* @text 空游戏文本
* @parent ---Info Window---
* @desc Text used when the save is empty.
* @default Empty
*
* @param Map Display Name
* @text 地图显示名称
* @parent ---Info Window---
* @type boolean
* @on Show
* @off Hide
* @desc Use the display name for the saved map instead?
* NO - false YES - true
* @default true
*
* @param Party Display
* @text 队伍展示
* @parent ---Info Window---
* @type select
* @option None
* @value 0
* @option Characters
* @value 1
* @option Faces
* @value 2
* @option SV Actors
* @value 3
* @desc The display type used for the party.
* 0 - None; 1 - Characters; 2 - Faces; 3 - SV Actors
* @default 2
*
* @param Party Y Position
* @text 队伍Y位置
* @parent ---Info Window---
* @desc This is the base Y position for the party display.
* Formulas can be used.
* @default this.lineHeight() + Window_Base._faceHeight
*
* @param Show Actor Names
* @text 显示角色名称
* @parent ---Info Window---
* @type boolean
* @on Show
* @off Hide
* @desc Display the names of the actors?
* NO - false YES - true
* @default true
*
* @param Name Font Size
* @text 名称字体大小
* @parent ---Info Window---
* @type number
* @min 1
* @desc Font size used for names if names are displayed.
* Default: 28
* @default 20
*
* @param Show Actor Level
* @text 显示角色等级
* @parent ---Info Window---
* @type boolean
* @on Show
* @off Hide
* @desc Display the levels of the actors?
* NO - false YES - true
* @default true
*
* @param Level Font Size
* @text 等级字体大小
* @parent ---Info Window---
* @type number
* @min 1
* @desc Font size used for levels if levels are displayed.
* Default: 28
* @default 20
*
* @param Level Format
* @text 等级格式
* @parent ---Info Window---
* @desc The text format used to display levels.
* %1 - Lv (Abbr) %2 - Lv (Full) %3 - Value
* @default \c[16]%1 \c[0]%3
*
* @param Data Font Size
* @text 数据字体大小
* @parent ---Info Window---
* @type number
* @min 1
* @desc Font size used for displaying data.
* Default: 28
* @default 20
*
* @param Data Column 1
* @text 数据列1
* @parent ---Info Window---
* @desc The data to be displayed in data column 1. Refer to help
* file for data entries. Separate each entry with commas.
* @default empty, playtime, save count, gold count
*
* @param Data Column 2
* @text 数据列2
* @parent ---Info Window---
* @desc The data to be displayed in data column 2. Refer to help
* file for data entries. Separate each entry with commas.
* @default location, variable 1, variable 2, variable 3
*
* @param Data Column 3
* @text 数据列3
* @parent ---Info Window---
* @desc The data to be displayed in data column 2. Refer to help
* file for data entries. Separate each entry with commas.
* @default empty, variable 4, variable 5, variable 6
*
* @param Data Column 4
* @text 数据列4
* @parent ---Info Window---
* @desc The data to be displayed in data column 2. Refer to help
* file for data entries. Separate each entry with commas.
* @default
*
* @param ---Vocabulary---
* @text ---词汇---
* @default
*
* @param Map Location
* @text 地图位置
* @parent ---Vocabulary---
* @desc Text used to categorize 'Map Location'.
* Leave empty to not use this category and center the data.
* @default
*
* @param Playtime
* @text 游戏时间
* @parent ---Vocabulary---
* @desc Text used to categorize 'Playtime'.
* Leave empty to not use this category and center the data.
* @default 游戏时间:
*
* @param Save Count
* @text 保存次数
* @parent ---Vocabulary---
* @desc Text used to categorize 'Save Count'.
* Leave empty to not use this category and center the data.
* @default 保存次数:
*
* @param Gold Count
* @text 金币数量
* @parent ---Vocabulary---
* @desc Text used to categorize 'Gold Count'.
* Leave empty to not use this category and center the data.
* @default %1:
*
* @param ---Technical---
* @text ---技术---
* @default
*
* @param Save Mode
* @text 保存模式
* @parent ---Technical---
* @type combo
* @option local
* @option web
* @option auto
* @desc How the save system should work for your game:
* local web auto
* @default auto
*
* @param Local Config
* @text 本地配置
* @parent ---Technical---
* @desc Filename for config when working with local saves.
* Default: config.rpgsave
* @default config.rpgsave
*
* @param Local Global
* @text 本地全局
* @parent ---Technical---
* @desc Filename for global when working with local saves.
* Default: global.rpgsave
* @default global.rpgsave
*
* @param Local Save
* @text 本地保存
* @parent ---Technical---
* @desc Filename for game saves when working with local saves.
* %1 - File Slot. Default: config.rpgsave
* @default file%1.rpgsave
*
* @param Web Config
* @text Web配置
* @parent ---Technical---
* @desc Filename for config when working with web saves.
* %1 - Game Name. Default: RPG Config
* @default RPG %1 Config
*
* @param Web Global
* @text Web全局
* @parent ---Technical---
* @desc Filename for global when working with web saves.
* %1 - Game Name. Default: RPG Global
* @default RPG %1 Global
*
* @param Web Save
* @text Web保存
* @parent ---Technical---
* @desc Filename for game saves when working with web saves.
* %1 - Game Name. %2 - File Slot. Default: RPG File%1
* @default RPG %1 File%2
*
* @param ---Confirmation---
* @text ---确认---
* @default
*
* @param Load Confirmation
* @text 加载确认
* @parent ---Confirmation---
* @type boolean
* @on YES
* @off NO
* @desc Show the load confirmation window when loading a
* save file? NO - false YES - true
* @default true
*
* @param Load Text
* @text 加载文本
* @parent ---Confirmation---
* @desc Text displayed when loading a save file.
* @default 是否要加载此保存文件
*
* @param Save Confirmation
* @text 保存确认
* @parent ---Confirmation---
* @type boolean
* @on YES
* @off NO
* @desc Show the save confirmation window when overwriting a
* save file? NO - false YES - true
* @default true
*
* @param Save Text
* @text 保存文本
* @parent ---Confirmation---
* @desc Text displayed when overwriting a save file.
* @default 是否覆盖此保存文件
*
* @param Delete Confirmation
* @text 删除确认
* @parent ---Confirmation---
* @type boolean
* @on YES
* @off NO
* @desc Show the save confirmation window when deleting a
* save file? NO - false YES - true
* @default true
*
* @param Delete Text
* @text 删除文本
* @parent ---Confirmation---
* @desc Text displayed when deleting a save file.
* @default 是否删除此保存文件
*
* @param Confirm Yes
* @text 确认是
* @parent ---Confirmation---
* @desc Text used for the 'Yes' confirm command
* @default
*
* @param Confirm No
* @text 确认否
* @parent ---Confirmation---
* @desc Text used for the 'No' confirm command
* @default
*
* @help
* ============================================================================
* Introduction
* ============================================================================
*
* 注意这个插件只支持1.1.0以上的版本
* 这个插件提供了一个新的存档界面通过这个新的界面玩家可以直接从菜单
* 载入或者删除存档这也将导致存档命令一直显示在之菜单但是我们可以
* 关闭或者开启存档选项从这个界面玩家可以获得存档的各类信息
* 例如位置金钱树或者任何你想展示的变量
*
* ============================================================================
* Instructions - Data Columns
* ============================================================================
*
* 对于那些想在每个存档显示额外信息的人你可以添加插件参数里面的Data
3 years ago
* Columns用逗号隔开你可以使用下面的标签
*
* Data Column Categories:
*
* Empty
* - 显示一个空位置但是没有外框
*
* Null
* - 显示一个空位置但是有外框
*
* Location
* - 地图坐标
*
* Playtime
* - 游戏时间
*
* Save Count
* - 存档数
*
* Gold Count
* - 金钱数
*
* Variable x
* -显示变量的名字和值你可以使用文本代码任何在<< >>里面的都不会
* 被显示如果没有变量名变量的值就会居中
*
* text: stuff
* left text: stuff
* center text: stuff
* right text: stuff
* -这将显示自定义文本可以设置显示位置默认是居左对齐
*
* ============================================================================
* Technical - Save Modes
* ============================================================================
*
* 对于想要在网上发布游戏的开发者你可以看一看Technical里的参数你可以
* 设置游戏模式本地还是网站默认你可以设置为自动
* 如果是为了测试目的你可以在本地运行时设置web模式
* 如果游戏运行在网站上你不可以使用本地模式
*
* ============================================================================
* Technical - Save Files
* ============================================================================
*
* 如果你有经验你可以根据喜好设置'Local Config', 'Local Global', 'Local
* Save'的名字
*
* ---
*
* 如果你正在做网站包括移动端的游戏我建议你看下'Web Config', 'Web Global'
* 'Web Save'的参数所以运行在网站上的游戏都会使用相同的设置
*
* This plugin's default settings will solve this sharing issue by making the
* web save named accordingly to your game's name provided that you keep the
* current plugin settings as is or adjust it accordingly. Now, your game will
* have its own individual identity, use its own configuration, global, and
* save files without clashing with any other RPG Maker MV games players may
* have played.这个插件默认设置解决了网站游戏存档奔溃的一些问题
*
* ============================================================================
* Changelog
* ============================================================================
*
* Version 1.06:
* - Updated for RPG Maker MV version 1.5.0.
*
* Version 1.05:
* - Added anti-crash measure for nonexistent $dataMapInfos entries.
*
* Version 1.04:
* - Added 'Map Display Name' plugin parameter. Enabling this option will now
* display the display name for the map instead of the editor name.
*
* Version 1.03:
* - Fixed a bug that caused web saving to not work properly.
*
* Version 1.02:
* - Fixed a bug that caused the actor's default name to appear in the save
* screen instead of the actor's current name (if it was changed.)
*
* Version 1.01:
* - Added a wait time update for save info data to load when moving across the
* various save files.
*
* Version 1.00:
* - Finished Plugin!
*/
//=============================================================================
//=============================================================================
// Parameter Variables
//=============================================================================
Yanfly.Parameters = PluginManager.parameters("YEP_SaveCore");
3 years ago
Yanfly.Param = Yanfly.Param || {};
Yanfly.Param.SaveMaxFiles = Number(Yanfly.Parameters["Max Files"]);
Yanfly.Param.SaveIconSaved = Number(Yanfly.Parameters["Saved Icon"]);
Yanfly.Param.SaveIconEmpty = Number(Yanfly.Parameters["Empty Icon"]);
Yanfly.Param.SavePop = eval(String(Yanfly.Parameters["Return After Saving"]));
Yanfly.Param.SaveAutoIndex = eval(String(Yanfly.Parameters["Auto New Index"]));
3 years ago
Yanfly.Param.SaveCmdLoad = String(Yanfly.Parameters["Load Command"]);
Yanfly.Param.SaveCmdSave = String(Yanfly.Parameters["Save Command"]);
Yanfly.Param.SaveCmdDelete = String(Yanfly.Parameters["Delete Command"]);
3 years ago
Yanfly.Param.SaveHelpSelect = String(Yanfly.Parameters["Select Help"]);
Yanfly.Param.SaveLoadSelect = String(Yanfly.Parameters["Load Help"]);
Yanfly.Param.SaveSaveSelect = String(Yanfly.Parameters["Save Help"]);
Yanfly.Param.SaveDeleteSelect = String(Yanfly.Parameters["Delete Help"]);
3 years ago
Yanfly.Param.SaveDeleteSound = {
name: String(Yanfly.Parameters["Delete Filename"]),
volume: Number(Yanfly.Parameters["Delete Volume"]),
pitch: Number(Yanfly.Parameters["Delete Pitch"]),
pan: Number(Yanfly.Parameters["Delete Pan"]),
3 years ago
};
Yanfly.Param.SaveInfoTitle = String(Yanfly.Parameters["Show Game Title"]);
3 years ago
Yanfly.Param.SaveInfoTitle = eval(Yanfly.Param.SaveInfoTitle);
Yanfly.Param.SaveInfoInvalid = String(Yanfly.Parameters["Invalid Game Text"]);
Yanfly.Param.SaveInfoEmpty = String(Yanfly.Parameters["Empty Game Text"]);
Yanfly.Param.SaveMapDisplayName = String(Yanfly.Parameters["Map Display Name"]);
3 years ago
Yanfly.Param.SaveMapDisplayName = eval(Yanfly.Param.SaveMapDisplayName);
Yanfly.Param.SaveInfoPartyType = Number(Yanfly.Parameters["Party Display"]);
3 years ago
Yanfly.Param.SaveInfoPartyType = Yanfly.Param.SaveInfoPartyType.clamp(0, 3);
Yanfly.Param.SaveInfoPartyY = String(Yanfly.Parameters["Party Y Position"]);
Yanfly.Param.SaveInfoActorName = String(Yanfly.Parameters["Show Actor Names"]);
3 years ago
Yanfly.Param.SaveInfoActorName = eval(Yanfly.Param.SaveInfoActorName);
Yanfly.Param.SaveInfoActorNameSz = Number(Yanfly.Parameters["Name Font Size"]);
Yanfly.Param.SaveInfoActorLv = String(Yanfly.Parameters["Show Actor Level"]);
3 years ago
Yanfly.Param.SaveInfoActorLv = eval(Yanfly.Param.SaveInfoActorLv);
Yanfly.Param.SaveInfoActorLvSz = Number(Yanfly.Parameters["Level Font Size"]);
Yanfly.Param.SaveInfoActorLvFmt = String(Yanfly.Parameters["Level Format"]);
Yanfly.Param.SaveInfoDataSz = Number(Yanfly.Parameters["Data Font Size"]);
Yanfly.Param.SaveInfoDataCol1 = String(Yanfly.Parameters["Data Column 1"]);
Yanfly.Param.SaveInfoDataCol1 = Yanfly.Param.SaveInfoDataCol1.split(",");
Yanfly.Param.SaveInfoDataCol2 = String(Yanfly.Parameters["Data Column 2"]);
Yanfly.Param.SaveInfoDataCol2 = Yanfly.Param.SaveInfoDataCol2.split(",");
Yanfly.Param.SaveInfoDataCol3 = String(Yanfly.Parameters["Data Column 3"]);
Yanfly.Param.SaveInfoDataCol3 = Yanfly.Param.SaveInfoDataCol3.split(",");
Yanfly.Param.SaveInfoDataCol4 = String(Yanfly.Parameters["Data Column 4"]);
Yanfly.Param.SaveInfoDataCol4 = Yanfly.Param.SaveInfoDataCol4.split(",");
Yanfly.trimSaveDataColumns = function (array) {
var length = array.length;
for (var i = 0; i < length; ++i) {
array[i] = array[i].trim();
}
if (length === 1 && array[0] === "") array.splice(0);
3 years ago
};
Yanfly.trimSaveDataColumns(Yanfly.Param.SaveInfoDataCol1);
Yanfly.trimSaveDataColumns(Yanfly.Param.SaveInfoDataCol2);
Yanfly.trimSaveDataColumns(Yanfly.Param.SaveInfoDataCol3);
Yanfly.trimSaveDataColumns(Yanfly.Param.SaveInfoDataCol4);
Yanfly.Param.SaveVocabLocation = String(Yanfly.Parameters["Map Location"]);
Yanfly.Param.SaveVocabPlaytime = String(Yanfly.Parameters["Playtime"]);
Yanfly.Param.SaveVocabSaveCount = String(Yanfly.Parameters["Save Count"]);
Yanfly.Param.SaveVocabGoldCount = String(Yanfly.Parameters["Gold Count"]);
3 years ago
Yanfly.Param.SaveTechSaveMode = String(Yanfly.Parameters["Save Mode"]).trim();
3 years ago
Yanfly.Param.SaveTechSaveMode = Yanfly.Param.SaveTechSaveMode.toLowerCase();
Yanfly.Param.SaveTechLocalConfig = String(Yanfly.Parameters["Local Config"]);
Yanfly.Param.SaveTechLocalGlobal = String(Yanfly.Parameters["Local Global"]);
Yanfly.Param.SaveTechLocalSave = String(Yanfly.Parameters["Local Save"]);
Yanfly.Param.SaveTechWebConfig = String(Yanfly.Parameters["Web Config"]);
Yanfly.Param.SaveTechWebGlobal = String(Yanfly.Parameters["Web Global"]);
Yanfly.Param.SaveTechWebSave = String(Yanfly.Parameters["Web Save"]);
Yanfly.Param.SaveConfirmLoad = String(Yanfly.Parameters["Load Confirmation"]);
3 years ago
Yanfly.Param.SaveConfirmLoad = eval(Yanfly.Param.SaveConfirmLoad);
Yanfly.Param.SaveConfirmLoadTx = String(Yanfly.Parameters["Load Text"]);
Yanfly.Param.SaveConfirmSave = String(Yanfly.Parameters["Save Confirmation"]);
3 years ago
Yanfly.Param.SaveConfirmSave = eval(Yanfly.Param.SaveConfirmSave);
Yanfly.Param.SaveConfirmSaveTx = String(Yanfly.Parameters["Save Text"]);
Yanfly.Param.SaveConfirmDel = String(Yanfly.Parameters["Delete Confirmation"]);
3 years ago
Yanfly.Param.SaveConfirmDel = eval(Yanfly.Param.SaveConfirmDel);
Yanfly.Param.SaveConfirmDelTx = String(Yanfly.Parameters["Delete Text"]);
Yanfly.Param.SaveConfirmYes = String(Yanfly.Parameters["Confirm Yes"]);
Yanfly.Param.SaveConfirmNo = String(Yanfly.Parameters["Confirm No"]);
3 years ago
//=============================================================================
// DataManager
//=============================================================================
DataManager.maxSavefiles = function () {
3 years ago
return Yanfly.Param.SaveMaxFiles;
};
Yanfly.Save.DataManager_selectSavefileForNewGame = DataManager.selectSavefileForNewGame;
DataManager.selectSavefileForNewGame = function () {
3 years ago
Yanfly.Save.DataManager_selectSavefileForNewGame.call(this);
if (Yanfly.Param.SaveAutoIndex) return;
this._lastAccessedId = 1;
};
Yanfly.Save.DataManager_makeSaveContents = DataManager.makeSaveContents;
DataManager.makeSaveContents = function () {
var contents = Yanfly.Save.DataManager_makeSaveContents.call(this);
contents.map.locationDisplayName = $dataMap.displayName;
return contents;
3 years ago
};
//=============================================================================
// StorageManager
//=============================================================================
Yanfly.Save.StorageManager_isLocalMode = StorageManager.isLocalMode;
StorageManager.isLocalMode = function () {
if (Yanfly.Param.SaveTechSaveMode === "local") {
if (!Utils.isNwjs()) return false;
return true;
} else if (Yanfly.Param.SaveTechSaveMode === "web") {
return false;
} else {
return Yanfly.Save.StorageManager_isLocalMode.call(this);
}
3 years ago
};
StorageManager.localFilePath = function (savefileId) {
var name;
if (savefileId < 0) {
name = Yanfly.Param.SaveTechLocalConfig;
} else if (savefileId === 0) {
name = Yanfly.Param.SaveTechLocalGlobal;
} else {
name = Yanfly.Param.SaveTechLocalSave.format(savefileId);
}
return this.localFileDirectoryPath() + name;
3 years ago
};
Yanfly.Save.StorageManager_webStorageKey = StorageManager.webStorageKey;
StorageManager.webStorageKey = function (savefileId) {
if (!$dataSystem) return Yanfly.Save.StorageManager_webStorageKey.call(this);
var title = $dataSystem.gameTitle;
this.loadConfig();
if (savefileId < 0) {
return Yanfly.Param.SaveTechWebConfig.format(title);
} else if (savefileId === 0) {
return Yanfly.Param.SaveTechWebGlobal.format(title);
} else {
return Yanfly.Param.SaveTechWebSave.format(title, savefileId);
}
3 years ago
};
StorageManager.loadConfig = function () {
if (this._configLoaded) return;
this._configLoaded = true;
ConfigManager.load();
3 years ago
};
//=============================================================================
// BattleManager
//=============================================================================
Yanfly.Save.BattleManager_setBattleTest = BattleManager.setBattleTest;
BattleManager.setBattleTest = function (battleTest) {
3 years ago
Yanfly.Save.BattleManager_setBattleTest.call(this, battleTest);
if (battleTest) StorageManager.loadConfig();
};
//=============================================================================
// Window_Base
//=============================================================================
Window_Base.prototype.drawSvActor = function (actor, x, y) {
3 years ago
var filename = actor.battlerName();
var bitmap = ImageManager.loadSvActor(filename);
var pw = bitmap.width / 9;
var ph = bitmap.height / 6;
var sx = 0;
var sy = 0;
this.contents.blt(bitmap, sx, sy, pw, ph, x - pw / 2, y - ph);
};
Window_Base.prototype.textWidthEx = function (text) {
3 years ago
return this.drawTextEx(text, 0, this.contents.height);
};
//=============================================================================
// Window_MenuCommand
//=============================================================================
Window_MenuCommand.prototype.isSaveEnabled = function () {
3 years ago
if (DataManager.isEventTest()) return false;
return true;
};
//=============================================================================
// Window_SavefileList
//=============================================================================
Window_SavefileList.prototype.itemHeight = function () {
3 years ago
return this.lineHeight();
};
Window_SavefileList.prototype.drawItem = function (index) {
3 years ago
var id = index + 1;
var valid = DataManager.isThisGameFile(id);
var rect = this.itemRect(index);
this.resetTextColor();
//if (this._mode === 'load') this.changePaintOpacity(valid);
this.changePaintOpacity(valid);
var icon = valid ? Yanfly.Param.SaveIconSaved : Yanfly.Param.SaveIconEmpty;
this.drawIcon(icon, rect.x + 2, rect.y + 2);
this.drawFileId(id, rect.x + Window_Base._iconWidth + 4, rect.y);
};
Window_SavefileList.prototype.playOkSound = function () {
3 years ago
Window_Selectable.prototype.playOkSound.call(this);
};
//=============================================================================
// Window_SaveAction
//=============================================================================
function Window_SaveAction() {
this.initialize.apply(this, arguments);
}
Window_SaveAction.prototype = Object.create(Window_HorzCommand.prototype);
Window_SaveAction.prototype.constructor = Window_SaveAction;
Window_SaveAction.prototype.initialize = function (x, y, mode) {
3 years ago
this._width = Graphics.boxWidth - x;
this._currentFile = 0;
this._mode = mode;
Window_HorzCommand.prototype.initialize.call(this, x, y);
this.deactivate();
this.deselect();
};
Window_SaveAction.prototype.windowWidth = function () {
3 years ago
return this._width;
};
Window_SaveAction.prototype.maxCols = function () {
3 years ago
return 3;
};
Window_SaveAction.prototype.savefileId = function () {
3 years ago
return SceneManager._scene._listWindow.index() + 1;
};
Window_SaveAction.prototype.makeCommandList = function () {
3 years ago
var id = this.savefileId();
var enabled = DataManager.isThisGameFile(id);
var valid = DataManager.loadSavefileInfo(id);
this.addCommand(this.getCommandName("load"), "load", valid);
this.addCommand(this.getCommandName("save"), "save", this.isSaveEnabled());
this.addCommand(this.getCommandName("delete"), "delete", enabled);
3 years ago
};
Window_SaveAction.prototype.getCommandName = function (type) {
if (type === "load") {
return Yanfly.Param.SaveCmdLoad;
} else if (type === "save") {
return Yanfly.Param.SaveCmdSave;
3 years ago
} else {
return Yanfly.Param.SaveCmdDelete;
3 years ago
}
};
Window_SaveAction.prototype.isSaveEnabled = function () {
if (this._mode !== "save") return false;
3 years ago
return $gameSystem.isSaveEnabled();
};
Window_SaveAction.prototype.update = function () {
3 years ago
Window_HorzCommand.prototype.update.call(this);
if (this.savefileId() !== this._currentFile) this.updateIndex();
};
Window_SaveAction.prototype.updateIndex = function () {
3 years ago
this._currentFile = this.savefileId();
this.refresh();
};
Window_SaveAction.prototype.playOkSound = function () {};
3 years ago
Window_SaveAction.prototype.updateHelp = function () {
var text = "";
if (this.currentSymbol() === "load") {
text = Yanfly.Param.SaveLoadSelect;
} else if (this.currentSymbol() === "save") {
text = Yanfly.Param.SaveSaveSelect;
} else if (this.currentSymbol() === "delete") {
text = Yanfly.Param.SaveDeleteSelect;
3 years ago
}
this._helpWindow.setText(text);
};
//=============================================================================
// Window_SaveInfo
//=============================================================================
function Window_SaveInfo() {
this.initialize.apply(this, arguments);
}
Window_SaveInfo.prototype = Object.create(Window_Base.prototype);
Window_SaveInfo.prototype.constructor = Window_SaveInfo;
Window_SaveInfo.prototype.initialize = function (x, y, width, height, mode) {
this._currentFile = 0;
this._waitTime = 0;
this._mode = mode;
Window_Base.prototype.initialize.call(this, x, y, width, height);
3 years ago
};
Window_SaveInfo.prototype.resetFontSettings = function () {
Window_Base.prototype.resetFontSettings.call(this);
if (this._drawLevel) this.contents.fontSize = Yanfly.Param.SaveInfoActorLvSz;
if (this._drawData) this.contents.fontSize = Yanfly.Param.SaveInfoDataSz;
3 years ago
};
Window_SaveInfo.prototype.savefileId = function () {
return SceneManager._scene._listWindow.index() + 1;
3 years ago
};
Window_SaveInfo.prototype.drawDarkRect = function (dx, dy, dw, dh) {
var color = this.gaugeBackColor();
this.changePaintOpacity(false);
this.contents.fillRect(dx + 1, dy + 1, dw - 2, dh - 2, color);
this.changePaintOpacity(true);
3 years ago
};
Window_SaveInfo.prototype.update = function () {
Window_Base.prototype.update.call(this);
if (this.savefileId() !== this._currentFile) this.updateIndex();
if (this._waitTime > 0) this.updateTimer();
3 years ago
};
Window_SaveInfo.prototype.systemColorEx = function () {
3 years ago
if (Imported.YEP_CoreEngine) {
return "\\c[" + Yanfly.Param.ColorSystem + "]";
} else {
return "\\c[16]";
}
};
Window_SaveInfo.prototype.updateIndex = function () {
var id = this.savefileId();
this._currentFile = id;
this._waitTime = 30;
this.contents.clear();
};
Window_SaveInfo.prototype.updateTimer = function () {
this._waitTime -= 1;
if (this._waitTime > 0) return;
var id = this.savefileId();
this._valid = DataManager.isThisGameFile(id);
this._info = DataManager.loadSavefileInfo(id);
this.refresh();
};
Window_SaveInfo.prototype.refresh = function () {
this.contents.clear();
this.resetFontSettings();
var dy = 0;
dy = this.drawGameTitle(dy);
if (!this._valid) return this.drawInvalidText(dy);
this._saveContents = StorageManager.load(this.savefileId());
this.drawContents(dy);
};
Window_SaveInfo.prototype.drawGameTitle = function (dy) {
if (!Yanfly.Param.SaveInfoTitle) return dy;
if (!this._info) return dy;
if (!this._info.title) return dy;
this.resetFontSettings();
var text = this._info.title;
this.drawText(text, 0, dy, this.contents.width, "center");
return dy + this.lineHeight();
};
Window_SaveInfo.prototype.drawInvalidText = function (dy) {
this.drawDarkRect(0, dy, this.contents.width, this.contents.height - dy);
dy = (this.contents.height - dy - this.lineHeight()) / 2;
if (this._info) {
var text = Yanfly.Param.SaveInfoInvalid;
3 years ago
} else {
var text = Yanfly.Param.SaveInfoEmpty;
3 years ago
}
this.changeTextColor(this.systemColor());
this.drawText(text, 0, dy, this.contents.width, "center");
3 years ago
};
Window_SaveInfo.prototype.drawContents = function (dy) {
if (!this._saveContents) {
return setTimeout(this.drawContents.bind(this, dy), 50);
}
this._saveContents = JsonEx.parse(this._saveContents);
dy = this.drawPartyGraphics(dy);
dy = this.drawPartyNames(dy);
dy = this.drawPartyLevels(dy);
this.drawColumnData(dy);
};
Window_SaveInfo.prototype.drawPartyGraphics = function (dy) {
if (Yanfly.Param.SaveInfoPartyType === 0) return dy;
dy = eval(Yanfly.Param.SaveInfoPartyY);
var length = this._saveContents.party.maxBattleMembers();
var dw = this.contents.width / length;
dw = Math.floor(dw);
var dx = Math.floor(dw / 2);
for (var i = 0; i < length; ++i) {
var actorId = this._saveContents.party._actors[i];
var member = this._saveContents.actors._data[actorId];
if (member) {
if (Yanfly.Param.SaveInfoPartyType === 1) {
var name = member.characterName();
var index = member.characterIndex();
this.drawCharacter(name, index, dx, dy);
} else if (Yanfly.Param.SaveInfoPartyType === 2) {
var fh = Window_Base._faceHeight;
var fw = Window_Base._faceWidth;
var fx = dx - Math.floor(Math.min(fh, dw) / 2);
var dif = Math.floor(Math.max(0, dw - fw) / 2);
var name = member.faceName();
var index = member.faceIndex();
this.drawFace(name, index, fx - dif, dy - fh, dw, fh);
} else if (Yanfly.Param.SaveInfoPartyType === 3) {
this.drawSvActor(member, dx, dy);
}
}
dx += dw;
3 years ago
}
return dy;
3 years ago
};
Window_SaveInfo.prototype.drawCharacter = function (name, index, x, y) {
3 years ago
var bitmap = ImageManager.loadCharacter(name);
if (bitmap.width <= 0) {
return setTimeout(this.drawCharacter.bind(this, name, index, x, y), 50);
3 years ago
}
Window_Base.prototype.drawCharacter.call(this, name, index, x, y);
};
Window_SaveInfo.prototype.drawFace = function (name, index, x, y, w, h) {
3 years ago
var bitmap = ImageManager.loadFace(name);
if (bitmap.width <= 0) {
return setTimeout(this.drawFace.bind(this, name, index, x, y, w, h), 50);
3 years ago
}
Window_Base.prototype.drawFace.call(this, name, index, x, y, w, h);
};
Window_SaveInfo.prototype.drawSvActor = function (actor, x, y) {
3 years ago
var filename = actor.battlerName();
var bitmap = ImageManager.loadSvActor(filename);
if (bitmap.width <= 0) {
return setTimeout(this.drawSvActor.bind(this, actor, x, y), 50);
3 years ago
}
Window_Base.prototype.drawSvActor.call(this, actor, x, y);
};
Window_SaveInfo.prototype.drawPartyNames = function (dy) {
if (!Yanfly.Param.SaveInfoActorName) return dy;
this.resetFontSettings();
this.contents.fontSize = Yanfly.Param.SaveInfoActorNameSz;
var length = this._saveContents.party.maxBattleMembers();
var dw = this.contents.width / length;
dw = Math.floor(dw);
var dx = 0;
for (var i = 0; i < length; ++i) {
var actorId = this._saveContents.party._actors[i];
var member = this._saveContents.actors._data[actorId];
if (member) {
var name = member._name;
this.drawText(name, dx, dy, dw, "center");
}
dx += dw;
3 years ago
}
return (dy += this.lineHeight());
};
Window_SaveInfo.prototype.drawPartyLevels = function (dy) {
if (!Yanfly.Param.SaveInfoActorLv) return dy;
this._drawLevel = true;
var length = this._saveContents.party.maxBattleMembers();
var dw = this.contents.width / length;
dw = Math.floor(dw);
var dx = 0;
var fmt = Yanfly.Param.SaveInfoActorLvFmt;
for (var i = 0; i < length; ++i) {
var actorId = this._saveContents.party._actors[i];
var member = this._saveContents.actors._data[actorId];
if (member) {
var lv = Yanfly.Util.toGroup(member.level);
var text = fmt.format(TextManager.levelA, TextManager.level, lv);
var tw = this.textWidthEx(text);
var dif = Math.floor(Math.max(0, dw - tw) / 2);
this.drawTextEx(text, dx + dif, dy);
}
dx += dw;
3 years ago
}
this._drawLevel = false;
return (dy += this.lineHeight());
3 years ago
};
Window_SaveInfo.prototype.drawColumnData = function (dy) {
3 years ago
var totalColumns = 0;
var drawnArrays = [];
if (Yanfly.Param.SaveInfoDataCol1.length > 0) {
totalColumns += 1;
drawnArrays.push(Yanfly.Param.SaveInfoDataCol1);
3 years ago
}
if (Yanfly.Param.SaveInfoDataCol2.length > 0) {
totalColumns += 1;
drawnArrays.push(Yanfly.Param.SaveInfoDataCol2);
3 years ago
}
if (Yanfly.Param.SaveInfoDataCol3.length > 0) {
totalColumns += 1;
drawnArrays.push(Yanfly.Param.SaveInfoDataCol3);
3 years ago
}
if (Yanfly.Param.SaveInfoDataCol4.length > 0) {
totalColumns += 1;
drawnArrays.push(Yanfly.Param.SaveInfoDataCol4);
3 years ago
}
if (totalColumns <= 0) return;
var dw = Math.floor(this.contents.width / totalColumns);
var dif = totalColumns > 1 ? this.textPadding() : 0;
for (var i = 0; i < totalColumns; ++i) {
var column = drawnArrays[i];
var dx = i * dw;
this.drawColumn(column, dx, dy, dw - dif);
3 years ago
}
};
Window_SaveInfo.prototype.drawColumn = function (column, dx, dy, dw) {
3 years ago
var length = column.length;
var tp = this.textPadding();
for (var i = 0; i < length; ++i) {
this.resetFontSettings();
this.contents.fontSize = Yanfly.Param.SaveInfoDataSz;
var data = column[i];
if (data.toUpperCase().trim() !== "EMPTY") {
this.drawDarkRect(dx, dy, dw, this.lineHeight());
this.drawData(data, dx + tp, dy, dw - tp * 2);
}
dy += this.lineHeight();
}
};
Window_SaveInfo.prototype.drawData = function (data, dx, dy, dw) {
if (data.toUpperCase().trim() === "NULL") {
return;
} else if (data.toUpperCase().trim() === "LOCATION") {
this.drawLocation(dx, dy, dw);
} else if (data.toUpperCase().trim() === "PLAYTIME") {
this.drawPlaytime(dx, dy, dw);
} else if (data.toUpperCase().trim() === "SAVE COUNT") {
this.drawSaveCount(dx, dy, dw);
} else if (data.toUpperCase().trim() === "GOLD COUNT") {
this.drawGoldCount(dx, dy, dw);
} else if (data.match(/VARIABLE[ ](\d+)/i)) {
this.drawVariable(parseInt(RegExp.$1), dx, dy, dw);
} else if (data.match(/(.*)[ ]TEXT:(.*)/i)) {
this.drawDataText(String(RegExp.$1), String(RegExp.$2), dx, dy, dw);
} else if (data.match(/TEXT:(.*)/i)) {
this.drawDataText("left", String(RegExp.$1), dx, dy, dw);
3 years ago
}
};
Window_SaveInfo.prototype.drawLocation = function (dx, dy, dw) {
3 years ago
var id = this._saveContents.map._mapId;
if (Yanfly.Param.SaveMapDisplayName) {
var text = this._saveContents.map.locationDisplayName || "";
if (text.length <= 0 && $dataMapInfos[id]) text = $dataMapInfos[id].name;
3 years ago
} else if ($dataMapInfos[id]) {
var text = $dataMapInfos[id].name;
3 years ago
} else {
var text = "";
3 years ago
}
if (Yanfly.Param.SaveVocabLocation.length > 0) {
this.changeTextColor(this.systemColor());
this.drawText(Yanfly.Param.SaveVocabLocation, dx, dy, dw, "left");
this.changeTextColor(this.normalColor());
this.drawText(text, dx, dy, dw, "right");
3 years ago
} else {
this.drawText(text, dx, dy, dw, "center");
3 years ago
}
};
Window_SaveInfo.prototype.drawPlaytime = function (dx, dy, dw) {
3 years ago
if (!this._info.playtime) return;
var text = this._info.playtime;
if (Yanfly.Param.SaveVocabPlaytime.length > 0) {
this.changeTextColor(this.systemColor());
this.drawText(Yanfly.Param.SaveVocabPlaytime, dx, dy, dw, "left");
this.changeTextColor(this.normalColor());
this.drawText(text, dx, dy, dw, "right");
3 years ago
} else {
this.drawText(text, dx, dy, dw, "center");
3 years ago
}
};
Window_SaveInfo.prototype.drawSaveCount = function (dx, dy, dw) {
3 years ago
var text = Yanfly.Util.toGroup(this._saveContents.system._saveCount);
if (Yanfly.Param.SaveVocabSaveCount.length > 0) {
this.changeTextColor(this.systemColor());
this.drawText(Yanfly.Param.SaveVocabSaveCount, dx, dy, dw, "left");
this.changeTextColor(this.normalColor());
this.drawText(text, dx, dy, dw, "right");
3 years ago
} else {
this.drawText(text, dx, dy, dw, "center");
3 years ago
}
};
Window_SaveInfo.prototype.drawGoldCount = function (dx, dy, dw) {
3 years ago
var text = Yanfly.Util.toGroup(this._saveContents.party._gold);
if (Yanfly.Param.SaveVocabGoldCount.length > 0) {
this.changeTextColor(this.systemColor());
var fmt = Yanfly.Param.SaveVocabGoldCount;
this.drawText(fmt.format(TextManager.currencyUnit), dx, dy, dw, "left");
this.changeTextColor(this.normalColor());
this.drawText(text, dx, dy, dw, "right");
3 years ago
} else {
var fmt = "\\c[0]%1" + this.systemColorEx() + "%2";
var ftext = fmt.format(text, TextManager.currencyUnit);
this._drawData = true;
var fw = this.textWidthEx(ftext);
dx += Math.max(0, Math.floor((dw - fw) / 2));
this.drawTextEx(ftext, dx, dy);
this._drawData = false;
3 years ago
}
};
Window_SaveInfo.prototype.drawVariable = function (id, dx, dy, dw) {
3 years ago
var varName = $dataSystem.variables[id];
varName = varName.replace(/<<(.*?)>>/i, "");
3 years ago
var text = Yanfly.Util.toGroup(this._saveContents.variables.value(id));
var diff = Math.max(0, (this.standardFontSize() - this.contents.fontSize) / 2);
3 years ago
if (varName.length > 0) {
this._drawData = true;
this.changeTextColor(this.systemColor());
dy += diff;
this.drawTextEx(this.systemColorEx() + varName, dx, dy, dw, "left");
dy -= diff;
this.changeTextColor(this.normalColor());
this._drawData = false;
this.drawText(text, dx, dy, dw, "right");
3 years ago
} else {
this.drawText(text, dx, dy, dw, "center");
3 years ago
}
};
Window_SaveInfo.prototype.drawDataText = function (align, text, dx, dy, dw) {
3 years ago
this._drawData = true;
dy += Math.max(0, (this.standardFontSize() - this.contents.fontSize) / 2);
var align = align.toLowerCase().trim();
var text = text.trim();
if (align === "left") {
this.drawTextEx(text, dx, dy);
} else if (align === "right") {
var tw = this.textWidthEx(text);
this.drawTextEx(text, dx + dw - tw, dy);
3 years ago
} else {
var tw = this.textWidthEx(text);
this.drawTextEx(text, dx + (dw - tw) / 2, dy);
3 years ago
}
this._drawData = false;
};
//=============================================================================
// Window_SaveConfirm
//=============================================================================
function Window_SaveConfirm() {
this.initialize.apply(this, arguments);
}
Window_SaveConfirm.prototype = Object.create(Window_Command.prototype);
Window_SaveConfirm.prototype.constructor = Window_SaveConfirm;
Window_SaveConfirm.prototype.initialize = function () {
3 years ago
Window_Command.prototype.initialize.call(this, 0, 0);
this.openness = 0;
};
Window_SaveConfirm.prototype.makeCommandList = function () {
this.addCommand(Yanfly.Param.SaveConfirmYes, "confirm");
this.addCommand(Yanfly.Param.SaveConfirmNo, "cancel");
3 years ago
};
Window_SaveConfirm.prototype.setData = function (text) {
3 years ago
this._text = text;
var ww = this.textWidthEx(this._text) + this.standardPadding() * 2;
ww += this.textPadding() * 2;
this.width = ww;
this.refresh();
this.x = (Graphics.boxWidth - this.width) / 2;
this.y = (Graphics.boxHeight - this.height) / 2;
this.drawTextEx(this._text, this.textPadding(), 0);
};
Window_SaveConfirm.prototype.itemTextAlign = function () {
return "center";
3 years ago
};
Window_SaveConfirm.prototype.windowHeight = function () {
3 years ago
return this.fittingHeight(3);
};
Window_SaveConfirm.prototype.itemRect = function (index) {
3 years ago
var rect = Window_Selectable.prototype.itemRect.call(this, index);
rect.y += this.lineHeight();
return rect;
};
//=============================================================================
// Scene_File
//=============================================================================
Scene_File.prototype.terminate = function () {
3 years ago
Scene_MenuBase.prototype.terminate.call(this);
if (this._loadSuccess) $gameSystem.onAfterLoad();
};
Scene_Load.prototype.terminate = function () {
3 years ago
Scene_File.prototype.terminate.call(this);
};
Scene_File.prototype.create = function () {
3 years ago
Scene_MenuBase.prototype.create.call(this);
DataManager.loadAllSavefileImages();
this.createHelpWindow();
this.createListWindow();
this.createActionWindow();
this.createInfoWindow();
this.createConfirmWindow();
};
Scene_File.prototype.createHelpWindow = function () {
3 years ago
this._helpWindow = new Window_Help(2);
this._helpWindow.setText(Yanfly.Param.SaveHelpSelect);
this.addWindow(this._helpWindow);
};
Scene_File.prototype.createListWindow = function () {
3 years ago
var x = 0;
var y = this._helpWindow.height;
var width = 240;
var height = Graphics.boxHeight - y;
this._listWindow = new Window_SavefileList(x, y, width, height);
this.addWindow(this._listWindow);
this._listWindow.setHandler("ok", this.onSavefileOk.bind(this));
this._listWindow.setHandler("cancel", this.popScene.bind(this));
3 years ago
this._listWindow.select(this.firstSavefileIndex());
this._listWindow.setTopRow(this.firstSavefileIndex() - 2);
this._listWindow.setMode(this.mode());
this._listWindow.refresh();
};
Scene_File.prototype.createActionWindow = function () {
3 years ago
var x = this._listWindow.width;
var y = this._listWindow.y;
this._actionWindow = new Window_SaveAction(x, y, this.mode());
this.addWindow(this._actionWindow);
this._actionWindow.setHelpWindow(this._helpWindow);
this._actionWindow.setHandler("load", this.onActionLoad.bind(this));
this._actionWindow.setHandler("save", this.onActionSave.bind(this));
this._actionWindow.setHandler("delete", this.onActionDelete.bind(this));
this._actionWindow.setHandler("cancel", this.onActionCancel.bind(this));
3 years ago
};
Scene_File.prototype.createInfoWindow = function () {
3 years ago
var x = this._actionWindow.x;
var y = this._actionWindow.y + this._actionWindow.height;
var width = Graphics.boxWidth - x;
var height = Graphics.boxHeight - y;
this._infoWindow = new Window_SaveInfo(x, y, width, height, this.mode());
this.addWindow(this._infoWindow);
};
Scene_File.prototype.createConfirmWindow = function () {
3 years ago
this._confirmWindow = new Window_SaveConfirm();
var win = this._confirmWindow;
win.setHandler("confirm", this.onConfirmOk.bind(this));
win.setHandler("cancel", this.onConfirmCancel.bind(this));
3 years ago
this.addWindow(this._confirmWindow);
};
Scene_File.prototype.onSavefileOk = function () {
3 years ago
this._actionWindow.activate();
if (this.mode() === "load") {
this._actionWindow.select(0);
} else if (this.mode() === "save") {
this._actionWindow.select(1);
3 years ago
}
};
Scene_Save.prototype.onSavefileOk = function () {
3 years ago
Scene_File.prototype.onSavefileOk.call(this);
};
Scene_Load.prototype.onSavefileOk = function () {
3 years ago
Scene_File.prototype.onSavefileOk.call(this);
};
Scene_File.prototype.onActionLoad = function () {
3 years ago
if (Yanfly.Param.SaveConfirmLoad) {
this.startConfirmWindow(Yanfly.Param.SaveConfirmLoadTx);
3 years ago
} else {
this.performActionLoad();
3 years ago
}
};
Scene_File.prototype.performActionLoad = function () {
3 years ago
if (DataManager.loadGame(this.savefileId())) {
this.onLoadSuccess();
} else {
this.onLoadFailure();
}
};
Scene_File.prototype.onLoadSuccess = function () {
3 years ago
SoundManager.playLoad();
this.fadeOutAll();
this.reloadMapIfUpdated();
SceneManager.goto(Scene_Map);
this._loadSuccess = true;
};
Scene_Load.prototype.onLoadSuccess = function () {
3 years ago
Scene_File.prototype.onLoadSuccess.call(this);
};
Scene_File.prototype.onLoadFailure = function () {
3 years ago
SoundManager.playBuzzer();
this.onActionCancel();
};
Scene_Load.prototype.onLoadFailure = function () {
3 years ago
Scene_File.prototype.onLoadFailure.call(this);
};
Scene_File.prototype.reloadMapIfUpdated = function () {
if ($gameSystem.versionId() === $dataSystem.versionId) return;
$gamePlayer.reserveTransfer($gameMap.mapId(), $gamePlayer.x, $gamePlayer.y);
$gamePlayer.requestMapReload();
3 years ago
};
Scene_File.prototype.onActionSave = function () {
var id = this.savefileId();
if (Yanfly.Param.SaveConfirmSave && StorageManager.exists(id)) {
this.startConfirmWindow(Yanfly.Param.SaveConfirmSaveTx);
} else {
this.performActionSave();
}
3 years ago
};
Scene_File.prototype.performActionSave = function () {
3 years ago
$gameSystem.onBeforeSave();
if (DataManager.saveGame(this.savefileId())) {
this.onSaveSuccess();
3 years ago
} else {
this.onSaveFailure();
3 years ago
}
};
Scene_File.prototype.onSaveSuccess = function () {
3 years ago
SoundManager.playSave();
StorageManager.cleanBackup(this.savefileId());
if (Yanfly.Param.SavePop) {
this.popScene();
3 years ago
} else {
this._listWindow.refresh();
this._actionWindow._currentFile = this.savefileId() - 1;
this._infoWindow._currentFile = this.savefileId() - 1;
this.onActionCancel();
3 years ago
}
};
Scene_Save.prototype.onSaveSuccess = function () {
3 years ago
Scene_File.prototype.onSaveSuccess.call(this);
};
Scene_File.prototype.onSaveFailure = function () {
3 years ago
SoundManager.playBuzzer();
this.onActionCancel();
};
Scene_Save.prototype.onSaveFailure = function () {
3 years ago
Scene_File.prototype.onSaveFailure.call(this);
};
Scene_File.prototype.onActionDelete = function () {
3 years ago
if (Yanfly.Param.SaveConfirmDel) {
this.startConfirmWindow(Yanfly.Param.SaveConfirmDelTx);
3 years ago
} else {
this.performActionDelete();
3 years ago
}
};
Scene_File.prototype.performActionDelete = function () {
3 years ago
AudioManager.playSe(Yanfly.Param.SaveDeleteSound);
StorageManager.remove(this.savefileId());
this.onActionCancel();
this._listWindow.refresh();
this._actionWindow._currentFile = this.savefileId() - 1;
this._infoWindow._currentFile = this.savefileId() - 1;
};
Scene_File.prototype.onActionCancel = function () {
3 years ago
this._actionWindow.deselect();
this._listWindow.activate();
this._helpWindow.setText(Yanfly.Param.SaveHelpSelect);
};
Scene_File.prototype.startConfirmWindow = function (text) {
3 years ago
SoundManager.playOk();
this._confirmWindow.setData(text);
this._confirmWindow.open();
this._confirmWindow.activate();
this._confirmWindow.select(0);
};
Scene_File.prototype.onConfirmOk = function () {
3 years ago
this._confirmWindow.deactivate();
this._confirmWindow.close();
if (this._actionWindow.currentSymbol() === "load") {
setTimeout(this.performActionLoad.bind(this), 200);
} else if (this._actionWindow.currentSymbol() === "save") {
setTimeout(this.performActionSave.bind(this), 200);
} else if (this._actionWindow.currentSymbol() === "delete") {
setTimeout(this.performActionDelete.bind(this), 200);
3 years ago
} else {
this.onConfirmCancel();
3 years ago
}
};
Scene_File.prototype.onConfirmCancel = function () {
3 years ago
var index = this._actionWindow.index();
this._confirmWindow.deactivate();
this._confirmWindow.close();
this.onSavefileOk();
this._actionWindow.select(index);
};
//=============================================================================
// Utilities
//=============================================================================
Yanfly.Util = Yanfly.Util || {};
if (!Yanfly.Util.toGroup) {
Yanfly.Util.toGroup = function (inVal) {
3 years ago
return inVal;
};
}
3 years ago
//=============================================================================
// End of File
//=============================================================================