-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbentelk_SaveSlots.js
157 lines (140 loc) · 4.94 KB
/
bentelk_SaveSlots.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*:
* @plugindesc When starting a new game, the player will choose a save slot. The game will always save to that slot. Also adds auto-save.
* @author Ben Hendel-Doying
*
* @help
* ============================================================================
* Description
* ----------------------------------------------------------------------------
*
* This plugin entirely changes up how the save system works.
*
* The default RPG Maker method is something like Skyrim, or Civilization,
* where you start a new game, and then may make as many saves for that game as
* you like.
*
* This plugin changes things to be more like the classic Zelda games: upon
* starting a new game, you will be required to choose a save slot, and all
* saves will go to that single save slot.
*
* This game also adds two auto-saves:
* 1. When the player quits, the game is automatically saved.
* 2. When the player moves from one map to another, the game is saved.
*
* Map-switch auto-saves can be disabled and enabled via a Script call (more on
* this, below). If you do not want to auto-save when the player quits, you
* will need to modify this plugin. Instructions are within.
*
* ============================================================================
* Usage
* ----------------------------------------------------------------------------
*
* To enable and disable auto-save features, make the following Script calls:
*
* DataManager.enableMapAutosave();
*
* DataManager.disableMapAutosave();
*
* Autosave is automatically enabled whenever a game is started or loaded.
*
* If for some reason you'd like to disable autosave by default, a simple
* modification can be made to this plugin to accomplish that. Open up a decent
* text editor; instructions are inside the plugin.
*
* To immediately save of the current game, make the following Script call:
*
* DataManager.saveCurrentGame();
*
* ============================================================================
* Compatibility
* ----------------------------------------------------------------------------
*
* This plugin REPLACES a couple built-in functions. For this reason, it must
* be placed BEFORE any other plugins that EXTEND these same functions.
*
* If two plugins replace the same function, they are probably incompatible.
*
* * Replaces Window_TitleCommand makeCommandList
* * Replaces Scene_Load onSavefileOk
* * Replaces Scene_Menu commandSave
* * Extends Scene_Map start
* * Extends Scene_GameEnd commandToTitle
* * Adds DataManager saveCurrentGame
* * Adds DataManager enableMapAutosave
* * Adds DataManager disableMapAutosave
*/
(function() {
Window_TitleCommand.prototype.makeCommandList = function() {
this.addCommand(TextManager.continue_, 'continue');
this.addCommand(TextManager.options, 'options');
};
Scene_Load.prototype.onSavefileOk = function() {
let savefileId = this.savefileId();
if(DataManager.isThisGameFile(savefileId))
{
if(DataManager.loadGame(savefileId))
{
this.onLoadSuccess();
DataManager.enableMapAutosave();
DataManager.currentSavefileId = savefileId;
}
else
{
this.onLoadFailure();
}
}
else
{
DataManager.setupNewGame();
DataManager.enableMapAutosave();
DataManager.currentSavefileId = savefileId;
SoundManager.playLoad();
this.fadeOutAll();
SceneManager.goto(Scene_Map);
}
};
Scene_Menu.prototype.commandSave = function() {
if(DataManager.saveCurrentGame())
{
SoundManager.playSave();
this.popScene();
}
else
{
SoundManager.playBuzzer();
this._commandWindow.activate();
}
};
// auto-save when loading a new map
let originalSceneMapStart = Scene_Map.prototype.start;
Scene_Map.prototype.start = function() {
originalSceneMapStart.call(this);
if(DataManager.autoSaveOnMapSwitch)
DataManager.saveCurrentGame();
};
// auto-save on quit; to permanently disable this feature, remove the following seven lines:
let originalSceneGameEndCommandToTitle = Scene_GameEnd.prototype.commandToTitle;
Scene_GameEnd.prototype.commandToTitle = function() {
DataManager.saveCurrentGame();
originalSceneGameEndCommandToTitle.call(this);
};
})();
DataManager.saveCurrentGame = function()
{
$gameSystem.onBeforeSave();
if(DataManager.saveGame(DataManager.currentSavefileId))
{
StorageManager.cleanBackup(DataManager.currentSavefileId);
return true;
}
else
{
return false;
}
};
DataManager.enableMapAutosave = function() {
DataManager.autoSaveOnMapSwitch = true;
};
DataManager.disableMapAutosave = function() {
DataManager.autoSaveOnMapSwitch = false;
};