Source: Scene_Save.js

Scene_Save.js

//-----------------------------------------------------------------------------
// Scene_Save
//
// The scene class of the save screen.
/**
 * The scene class of the save screen.
 *
 * @class
 * @extends Scene_File
 */
function Scene_Save() {
    this.initialize(...arguments);
}

Scene_Save.prototype = Object.create(Scene_File.prototype);
Scene_Save.prototype.constructor = Scene_Save;

Scene_Save.prototype.initialize = function() {
    Scene_File.prototype.initialize.call(this);
};

/**
 * The mode of the file select scene. When called from Scene_Save, it returns "save"
 * 
 * @return {string} The mode of the scene
 * @override
 */
Scene_Save.prototype.mode = function() {
    return "save";
};

/**
 * Get the text that should appear in the help window
 *
 * @return {string} The help window text
 * @override
 */
Scene_Save.prototype.helpWindowText = function() {
    return TextManager.saveMessage;
};

/**
 * Get the first save file's id
 *
 * @return {number} The first save file's id
 * @override
 */
Scene_Save.prototype.firstSavefileId = function() {
    return $gameSystem.savefileId();
};

Scene_Save.prototype.onSavefileOk = function() {
    Scene_File.prototype.onSavefileOk.call(this);
    const savefileId = this.savefileId();
    if (this.isSavefileEnabled(savefileId)) {
        this.executeSave(savefileId);
    } else {
        this.onSaveFailure();
    }
};

/**
 * Attempts to save a given save file by id
 *
 * @param {number} savefileId - The id of the save file to save over
 */
Scene_Save.prototype.executeSave = function(savefileId) {
    $gameSystem.setSavefileId(savefileId);
    $gameSystem.onBeforeSave();
    DataManager.saveGame(savefileId)
        .then(() => this.onSaveSuccess())
        .catch(() => this.onSaveFailure());
};

/**
 * Handling when save was a success
 */
Scene_Save.prototype.onSaveSuccess = function() {
    SoundManager.playSave();
    this.popScene();
};

/**
 * Handling when save was a failure
 */
Scene_Save.prototype.onSaveFailure = function() {
    SoundManager.playBuzzer();
    this.activateListWindow();
};