//-----------------------------------------------------------------------------
// Scene_Load
//
// The scene class of the load screen.
/**
* The scene class of the load screen.
*
* @class
* @extends Scene_File
*/
function Scene_Load() {
this.initialize(...arguments);
}
Scene_Load.prototype = Object.create(Scene_File.prototype);
Scene_Load.prototype.constructor = Scene_Load;
Scene_Load.prototype.initialize = function() {
Scene_File.prototype.initialize.call(this);
this._loadSuccess = false;
};
Scene_Load.prototype.terminate = function() {
Scene_File.prototype.terminate.call(this);
if (this._loadSuccess) {
$gameSystem.onAfterLoad();
}
};
/**
* The mode of the file select scene. When called from Scene_Load, it returns "load"
*
* @return {string} The mode of the scene
* @override
*/
Scene_Load.prototype.mode = function() {
return "load";
};
/**
* Get the text that should appear in the help window
*
* @return {string} The help window text
* @override
*/
Scene_Load.prototype.helpWindowText = function() {
return TextManager.loadMessage;
};
/**
* Get the first save file's id
*
* @return {number} The first save file's id
* @override
*/
Scene_Load.prototype.firstSavefileId = function() {
return DataManager.latestSavefileId();
};
Scene_Load.prototype.onSavefileOk = function() {
Scene_File.prototype.onSavefileOk.call(this);
const savefileId = this.savefileId();
if (this.isSavefileEnabled(savefileId)) {
this.executeLoad(savefileId);
} else {
this.onLoadFailure();
}
};
/**
* Attempts to load a given save file by id
*
* @param {number} savefileId - The id of the save file to load
*/
Scene_Load.prototype.executeLoad = function(savefileId) {
DataManager.loadGame(savefileId)
.then(() => this.onLoadSuccess())
.catch(() => this.onLoadFailure());
};
/**
* Handling when load was a success
*/
Scene_Load.prototype.onLoadSuccess = function() {
SoundManager.playLoad();
this.fadeOutAll();
this.reloadMapIfUpdated();
SceneManager.goto(Scene_Map);
this._loadSuccess = true;
};
/**
* Handling when load was a failure
*/
Scene_Load.prototype.onLoadFailure = function() {
SoundManager.playBuzzer();
this.activateListWindow();
};
/**
* Reloads the game map if it was updated since last time the game was played
*/
Scene_Load.prototype.reloadMapIfUpdated = function() {
if ($gameSystem.versionId() !== $dataSystem.versionId) {
const mapId = $gameMap.mapId();
const x = $gamePlayer.x;
const y = $gamePlayer.y;
$gamePlayer.reserveTransfer(mapId, x, y);
$gamePlayer.requestMapReload();
}
};