-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathMrTS_SimpleSaveLoadMenu.js
216 lines (200 loc) · 6.85 KB
/
MrTS_SimpleSaveLoadMenu.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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
//=============================================================================
// MrTS_SimpleSaveLoadMenu.js
//=============================================================================
/*:
* @plugindesc Shows faces instead of character sprites and adds 4 lines of things.
* @author Mr. Trivel
*
* @param Background Image
* @desc Background image name for saving and loading. Leave blank for default.
* Default:
* @default
*
* @param Select Text
* @desc Select savefile text.
* Default: Select Savefile
* @default Select Savelife
*
* @param Line 1
* @desc What to display in line 1? 'gold' 'time' 'variable [ID]' 'none'
* Default: time
* @default time
*
* @param Line 2
* @desc What to display in line 2? 'gold' 'time' 'variable [ID]' 'none'
* Default: gold
* @default gold
*
* @param Line 3
* @desc What to display in line 3? 'gold' 'time' 'variable [ID]' 'none'
* Default: none
* @default none
*
* @param Line 4
* @desc What to display in line 4? 'gold' 'time' 'variable [ID]' 'none'
* Default: variable 4
* @default variable 4
*
* @param Line 1 Icon
* @desc Which icon to display before Line 1?
* Default 220
* @default 220
*
* @param Line 2 Icon
* @desc Which icon to display before Line 2?
* Default: 313
* @default 313
*
* @param Line 3 Icon
* @desc Which icon to display before Line 3?
* Default: 0
* @default 0
*
* @param Line 4 Icon
* @desc Which icon to display before Line 4?
* Default: 190
* @default 190
*
* @param Max Saves
* @desc Amount of Savefiles available.
* Default: 99
* @default 99
*
* @help
* --------------------------------------------------------------------------------
* Terms of Use
* --------------------------------------------------------------------------------
* Don't remove the header or claim that you wrote this plugin.
* Credit Mr. Trivel if using this plugin in your project.
* Free for commercial and for non-commercial projects.
* --------------------------------------------------------------------------------
* Version 1.0
* --------------------------------------------------------------------------------
*
* Everything is in plugin parameters.
*
* --------------------------------------------------------------------------------
* Version History
* --------------------------------------------------------------------------------
* 1.0 - Release
*/
(function() {
var parameters = PluginManager.parameters('MrTS_SimpleSaveLoadMenu');
var paramBackgroundImage = String(parameters['Background Image'] || "");
var paramSelectText = String(parameters['Select Text'] || "Select Savefile");
var paramLine1 = String(parameters['Line 1'] || "time");
var paramLine2 = String(parameters['Line 2'] || "gold");
var paramLine3 = String(parameters['Line 3'] || "none");
var paramLine4 = String(parameters['Line 4'] || "variable 4");
var paramLine1Icon = Number(parameters['Line 1 Icon'] || 220);
var paramLine2Icon = Number(parameters['Line 2 Icon'] || 313);
var paramLine3Icon = Number(parameters['Line 3 Icon'] || 0);
var paramLine4Icon = Number(parameters['Line 4 Icon'] || 190);
var paramLineIcons = [paramLine1Icon, paramLine2Icon, paramLine3Icon, paramLine4Icon];
var paramMaxSaves = Number(parameters['Max Saves'] || 99);
DataManager.maxSavefiles = function() {
return paramMaxSaves;
};
Scene_File.prototype.createBackground = function() {
this._backgroundSprite = new Sprite();
this._backgroundSprite.bitmap = paramBackgroundImage.length > 0 ? ImageManager.loadSystem(paramBackgroundImage) : SceneManager.backgroundBitmap();
this.addChild(this._backgroundSprite);
};
var _SceneFile_createListWindow = Scene_File.prototype.createListWindow;
Scene_File.prototype.createListWindow = function() {
_SceneFile_createListWindow.call(this);
var rectH = this._listWindow.itemRect(0).height;
var y = this._helpWindow.height;
var occupiedSpace = this._listWindow.standardPadding() * 2 + y;
var possibleItems = Math.floor((Graphics.boxHeight-occupiedSpace)/rectH);
var height = possibleItems * rectH + this._listWindow.standardPadding() * 2;
var width = 816;
this._listWindow.width = width;
this._listWindow.height = height;
this._listWindow.refresh();
this._listWindow.y = y + (Graphics.boxHeight-y)/2 - height/2;
this._listWindow.x = Graphics.boxWidth/2 - width/2;
this.addWindow(this._listWindow);
this._helpWindow.width = width;
this._helpWindow.x = this._listWindow.x;
this._helpWindow.y = this._listWindow.y/2 - this._helpWindow.height/2;
};
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 (info) {
this.changePaintOpacity(valid);
this.drawContents(info, rect, valid);
this.changePaintOpacity(true);
}
};
Window_SavefileList.prototype.drawContents = function(info, rect, valid) {
var bottom = rect.y + rect.height;
if (rect.width >= 420) {
if (valid) {
this.drawPartyCharacters(info, rect.x, rect.y);
}
}
var lineHeight = this.lineHeight();
var y2 = rect.y + this.padding/2;
for (var i = 0; i < paramLineIcons.length; i++) {
this.drawLine(info, rect.x, y2, rect.width, i+1);
y2 += lineHeight;
}
};
Window_SavefileList.prototype.drawPartyCharacters = function(info, x, y) {
if (info.characters) {
for (var i = 0; i < info.faces.length; i++) {
var data = info.faces[i];
this.drawFace(data[0], data[1], x + i * Window_Base._faceWidth, y+this.padding/2);
}
}
};
Window_SavefileList.prototype.drawLine = function(info, x, y, width, line) {
var txt = info["line"+line];
this.drawText(txt, x, y, width, 'right');
this.drawIcon(paramLineIcons[line-1], x + width - this.textWidth(txt)-Window_Base._iconWidth-4, y);
};
Window_SavefileList.prototype.itemHeight = function() {
return Window_Base._faceHeight + this.padding;
};
var _DataManager_makeSavefileInfo = DataManager.makeSavefileInfo;
DataManager.makeSavefileInfo = function() {
var info = _DataManager_makeSavefileInfo();
var data = [paramLine1, paramLine2, paramLine3, paramLine4];
var parsedData = [];
for (var i = 0; i < data.length; i++) {
switch (data[i].split(' ')[0])
{
case 'gold':
{
parsedData[i] = $gameParty.gold();
} break;
case 'time':
{
parsedData[i] = $gameSystem.playtimeText();
} break;
case 'variable':
{
parsedData[i] = $gameVariables.value(Number(data[i].split(' ')[1]));
} break;
default:
{
parsedData[i] = '';
} break;
}
}
info.line1 = parsedData[0];
info.line2 = parsedData[1];
info.line3 = parsedData[2];
info.line4 = parsedData[3];
console.log(info);
return info;
};
})();