-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathMrTS_SimpleTitleScreen.js
257 lines (235 loc) · 8.86 KB
/
MrTS_SimpleTitleScreen.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
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
//=============================================================================
// MrTS_SimpleTitleScreen.js
//=============================================================================
/*:
* @plugindesc Changes title screen commands to images and adds a cursor.
* @author Mr. Trivel
*
* @param Display Cursor
* @desc Display cursor next to the selected command?
* Default: True
* @default True
*
* @param Display Alternative
* @desc Display alternative image when command is selected?
* Default: True
* @default True
*
* @param Display Behind
* @desc Display image behind selected command?
* Default: True
* @default True
*
* @param Display Press Start
* @desc Display and ask for Press Start?
* Default: True
* @default True
*
* @param Commands Position
* @desc X Y position on the title screen.
* Default: 561 400
* @default 561 400
*
* @param Press Start Position
* @desc X Y position on the title screen.
* Default: 561 580
* @default 561 580
*
* @param Cursor Offset
* @desc X Y offset of cursor
* Default -60 0
* @default -60 0
*
* @param Behind Offset
* @desc Behind image offset
* Default -100 0
* @default -100 0
*
* @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.1
* --------------------------------------------------------------------------------
*
* --------------------------------------------------------------------------------
* Image List
* --------------------------------------------------------------------------------
* Title screen image is selected in database per usual.
*
* Other images go into img\system:
* img\system\titleCursor.png - can be omitted if cursor is set to false
* img\system\titleBehindCommand.png - can be omitted if behind is set to false
* img\system\titlePressStart.png - can be omitted if press s tart is set to false
*
* Remaining images have dynamic names which are constructor from word 'command_'
* and handler name. Example: command_newGame, command_continue, command_options.
* Those three are in default RPG Maker MV. If you have other plugins, you might
* need to add more images.
*
* Alternative command images when selected are named in similar fashion:
* commandAlt_CommandName
* Example:
* commandAlt_newGame, commandAlt_continue, commandAlt_options
* --------------------------------------------------------------------------------
*
* --------------------------------------------------------------------------------
* Version History
* --------------------------------------------------------------------------------
* 1.1 - Compatibility fix with plugins that disable command menu when press start
* is disabled.
* 1.0 - Release
*/
(function() {
var parameters = PluginManager.parameters('MrTS_SimpleTitleScreen');
var paramDisplayCursor = (parameters['Display Cursor'] || "true").toLowerCase() === "true";
var paramDisplayAlternative = (parameters['Display Alternative'] || "true").toLowerCase() === "true";
var paramDisplayBehind = (parameters['Display Behind'] || "true").toLowerCase() === "true";
var paramDisplayPressStart = (parameters['Display Press Start'] || "true").toLowerCase() === "true";
var paramCommandsPos = String(parameters['Commands Position'] || "561 400");
var paramPressStartPos = String(parameters['Press Start Position'] || "561 580");
var paramCursorOffset = String(parameters['Cursor Offset'] || "-60 0");
var paramBehindOffset = String(parameters['Behind Offset'] || "-100 0");
var _WindowTitleCommand_initialize = Window_TitleCommand.prototype.initialize;
Window_TitleCommand.prototype.initialize = function() {
this._commandSprites = [];
this._altSprites = [];
_WindowTitleCommand_initialize.call(this);
this.openness = 255;
var pos = paramCommandsPos.split(' ');
this.x = Number(pos[0]);
this.y = Number(pos[1]);
this.opacity = 0;
};
Window_TitleCommand.prototype.setupSprites = function() {
for (var i = 0; i < this._list.length; i++) {
var rect = this.itemRect2(i);
var spr = new Sprite();
var symbol = this._list[i].symbol;
spr.bitmap = ImageManager.loadSystem("command_"+symbol);
spr.x = this.standardPadding();
spr.y = rect.y + this.standardPadding();
this._commandSprites.push(spr);
this.addChild(spr);
if (paramDisplayAlternative)
{
var spr2 = new Sprite();
spr2.bitmap = ImageManager.loadSystem("commandAlt_"+symbol);
spr2.x = this.standardPadding();
spr2.y = rect.y + this.standardPadding();
this._altSprites.push(spr2);
spr2.visible = false;
this.addChild(spr2);
}
}
this.select(this.index());
};
var _WindowTitleCommand_select = Window_TitleCommand.prototype.select
Window_TitleCommand.prototype.select = function(index) {
_WindowTitleCommand_select.call(this, index);
if (paramDisplayAlternative)
{
if (this._commandSprites[index] && this._altSprites[index])
{
for (var i = 0; i < this._commandSprites.length; i++) {
this._commandSprites[i].visible = true;
this._altSprites[i].visible = false;
}
this._commandSprites[index].visible = false;
this._altSprites[index].visible = true;
}
}
};
Window_TitleCommand.prototype.drawItem = function(index) {
};
Window_TitleCommand.prototype.updateCursor = function() {
this.setCursorRect(0, 0, 0, 0);
};
Window_TitleCommand.prototype.itemRect2 = function(index) {
var rect = new Rectangle();
var maxCols = this.maxCols();
rect.width = this.itemWidth();
rect.height = this.itemHeight();
rect.x = index % maxCols * (rect.width + this.spacing()) - this._scrollX;
rect.y = Math.floor(index / maxCols) * rect.height - this._scrollY;
return rect;
};
Window_TitleCommand.prototype.itemRect = function(index) {
if (!this._commandSprites[index]) return this.itemRect2(index);
var rect = new Rectangle();
rect.width = this._commandSprites[index].width;
rect.height = this._commandSprites[index].height
rect.x = this._commandSprites[index].x - this.standardPadding();
rect.y = this._commandSprites[index].y - this.standardPadding();
return rect;
};
Window_TitleCommand.prototype.close = function() {
};
var _SceneTitle_createCommandWindow = Scene_Title.prototype.createCommandWindow;
Scene_Title.prototype.createCommandWindow = function() {
_SceneTitle_createCommandWindow.call(this);
this._commandWindow.setupSprites();
if (paramDisplayPressStart)
{
this._commandWindow.hide();
this._commandWindow.deactivate();
}
};
var _SceneTitle_createBackground = Scene_Title.prototype.createBackground;
Scene_Title.prototype.createBackground = function() {
_SceneTitle_createBackground.call(this);
if (paramDisplayBehind)
{
this._behindPos = paramBehindOffset.split(' ');
this._behindSpr = new Sprite();
this._behindSpr.bitmap = ImageManager.loadSystem("titleBehindCommand");
this.addChild(this._behindSpr);
}
if (paramDisplayCursor)
{
this._cursorPos = paramCursorOffset.split(' ');
this._cursorSpr = new Sprite();
this._cursorSpr.bitmap = ImageManager.loadSystem("titleCursor");
this.addChild(this._cursorSpr);
}
if (paramDisplayPressStart)
{
this._pressStartSpr = new Sprite();
this._pressStartSpr.bitmap = ImageManager.loadSystem("titlePressStart");
var pos = paramPressStartPos.split(" ");
this._pressStartSpr.x = Number(pos[0]);
this._pressStartSpr.y = Number(pos[1]);
this.addChild(this._pressStartSpr);
if (paramDisplayCursor) this._cursorSpr.visible = false;
if (paramDisplayBehind) this._behindSpr.visible = false;
}
};
var _SceneTitle_update = Scene_Title.prototype.update;
Scene_Title.prototype.update = function() {
_SceneTitle_update.call(this);
if (!this._commandWindow.active && this._pressStartSpr && (Input.isTriggered('ok') || TouchInput.isTriggered()))
{
SoundManager.playOk();
this._commandWindow.show();
if (paramDisplayCursor) this._cursorSpr.visible = true;
if (paramDisplayBehind) this._behindSpr.visible = true;
this._commandWindow.active = true;
this._pressStartSpr.visible = false;
}
var rect = this._commandWindow.itemRect(this._commandWindow.index());
if (paramDisplayCursor)
{
this._cursorSpr.x = this._commandWindow.x + Number(this._cursorPos[0]) + rect.x + this._commandWindow.standardPadding();
this._cursorSpr.y = this._commandWindow.y + Number(this._cursorPos[1]) + rect.y + this._commandWindow.standardPadding();
}
if (paramDisplayBehind)
{
this._behindSpr.x = this._commandWindow.x + Number(this._behindPos[0]) + rect.x + this._commandWindow.standardPadding();
this._behindSpr.y = this._commandWindow.y + Number(this._behindPos[1]) + rect.y + this._commandWindow.standardPadding();
}
};
})();