-
Notifications
You must be signed in to change notification settings - Fork 0
/
MPP_FastForwardAnimation.js
368 lines (325 loc) · 12 KB
/
MPP_FastForwardAnimation.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
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
//=============================================================================
// MPP_FastForwardAnimation.js
//=============================================================================
// Copyright (c) 2020 Mokusei Penguin
// Released under the MIT license
// http://opensource.org/licenses/mit-license.php
//=============================================================================
/*:
* @target MZ
* @plugindesc Allows you to accelerate animations in battle.
* @author Mokusei Penguin
* @url
*
* @help [version 1.0]
* This plugin is for RPG Maker MZ.
*
* ▼ Fast Forward Type
* 〇 long press
* - Press and hold the Ok or Shift button, or press and hold the screen to
* accelerate.
* - The button is the same as accelerating the battle log.
* - With this setting, the button will not be displayed on the screen.
* 〇 toggle
* - Press the corresponding button or the button displayed on the screen to
* enable / disable acceleration.
* - When enabled, battle log acceleration will also be enabled.
* - If you want to use the button image, put it in the img / system folder.
*
* ================================
* Mail : wood_penguin@yahoo.co.jp (@ is half-width)
* Blog : http://woodpenguin.blog.fc2.com/
* License : MIT license
*
* @param Fast Forward Type
* @desc
* @type select
* @option long press
* @option toggle
* @default long press
*
* @param Toggle Button
* @desc
* @type select
* @option shift
* @option pageup
* @option pagedown
* @default shift
*
* @param Button File Name
* @desc If it is not set, it will be automatically generated.
* @type file
* @require 1
* @dir img/system/
* @default
*
*/
/*:ja
* @target MZ
* @plugindesc 戦闘中のアニメーションを加速出来るようにします。
* @author 木星ペンギン
* @url
*
* @help [version 1.0]
* このプラグインはRPGツクールMZ用です。
*
* ▼ 加速タイプ
* 〇 長押し
* - 決定またはシフトボタンの長押し、もしくは画面を長押しタッチで加速します。
* - ボタンは戦闘ログの加速と同じです。
* - こちらの設定ではボタンは画面に表示されません。
* 〇 切り替え
* - 対応するボタンを押すか、画面に表示されるボタンを押すと加速の有効無効が
* 切り替わります。
* - 有効にすると戦闘ログの加速も有効となります。
* - ボタンの画像を使用する場合は、img/system フォルダに入れてください。
*
* ================================
* Mail : wood_penguin@yahoo.co.jp (@は半角)
* Blog : http://woodpenguin.blog.fc2.com/
* License : MIT license
*
* @param Fast Forward Type
* @text 加速タイプ
* @desc
* @type select
* @option 長押し
* @value long press
* @option 切り替え
* @value toggle
* @default long press
*
* @param Toggle Button
* @text 切り替えボタン
* @desc
* @type select
* @option shift
* @option pageup
* @option pagedown
* @default shift
*
* @param Button File Name
* @text ボタン画像ファイル名
* @desc 未設定の場合は自動生成されます。
* @type file
* @require 1
* @dir img/system/
* @default
*
*/
(() => {
'use strict';
const pluginName = 'MPP_FastForwardAnimation';
// Plugin Parameters
const parameters = PluginManager.parameters(pluginName);
const param_FastForwardType = parameters['Fast Forward Type'];
const param_ToggleButton = parameters['Toggle Button'];
const param_ButtonFileName = parameters['Button File Name'];
//-------------------------------------------------------------------------
// Game_Temp
const _Game_Temp_initialize = Game_Temp.prototype.initialize;
Game_Temp.prototype.initialize = function() {
_Game_Temp_initialize.apply(this, arguments);
this._battleFastForward = false;
};
Game_Temp.prototype.isBattleFastForward = function() {
return this._battleFastForward;
};
Game_Temp.prototype.enableBattleFastForward = function() {
this._battleFastForward = true;
};
Game_Temp.prototype.disableBattleFastForward = function() {
this._battleFastForward = false;
};
Game_Temp.prototype.switchBattleFastForward = function() {
this._battleFastForward = !this._battleFastForward;
};
//-------------------------------------------------------------------------
// Sprite_Animation
const _Sprite_Animation_updateEffectGeometry = Sprite_Animation.prototype.updateEffectGeometry;
Sprite_Animation.prototype.updateEffectGeometry = function() {
_Sprite_Animation_updateEffectGeometry.apply(this, arguments);
if (this._handle && this.isFastForward()) {
this._handle.setSpeed(this._animation.speed / 100 * 2);
}
};
const _Sprite_Animation_updateMain = Sprite_Animation.prototype.updateMain;
Sprite_Animation.prototype.updateMain = function() {
_Sprite_Animation_updateMain.apply(this, arguments);
if (this._playing && this.isFastForward()) {
_Sprite_Animation_updateMain.apply(this, arguments);
}
};
Sprite_Animation.prototype.isFastForward = function() {
return $gameParty.inBattle() && $gameTemp.isBattleFastForward();
};
//-------------------------------------------------------------------------
// Sprite_FastForwardButton
function Sprite_FastForwardButton() {
this.initialize(...arguments);
}
Sprite_FastForwardButton.prototype = Object.create(Sprite_Button.prototype);
Sprite_FastForwardButton.prototype.constructor = Sprite_FastForwardButton;
Sprite_FastForwardButton.prototype.initialize = function(bottomY) {
Sprite_Button.prototype.initialize.call(this);
this._bottomY = bottomY;
this._bitmapLoaded = false;
this.loadButtonImage();
this.checkBitmap();
};
Sprite_FastForwardButton.prototype.setupFrames = function() {
if (this.bitmap) {
const width = this.bitmap.width;
const height = this.bitmap.height / 2;
this.setColdFrame(0, 0, width, height);
this.setHotFrame(0, height, width, height);
this.updateFrame();
this.updateOpacity();
this.updatePosition();
}
};
Sprite_FastForwardButton.prototype.loadButtonImage = function() {
if (param_ButtonFileName !== '') {
this.bitmap = ImageManager.loadSystem(param_ButtonFileName);
} else {
this.bitmap = this.createBitmap();
}
};
Sprite_FastForwardButton.prototype.createBitmap = function() {
const bitmap = new Bitmap(96, 96);
bitmap.paintOpacity = 160;
this.drawBack(bitmap, 0,0,96,48, 'rgb(52,52,52)','rgb(0,0,0)');
bitmap.paintOpacity = 204;
this.drawTriangle(bitmap, 38, 24);
this.resetFontSettings(bitmap);
//this.drawText(bitmap, 'Animation', 12);
bitmap.paintOpacity = 245;
this.drawBack(bitmap, 0,48,96,48, 'rgb(66,156,149)','rgb(14,104,96)');
bitmap.paintOpacity = 255;
this.drawTriangle(bitmap, 28, 72);
this.drawTriangle(bitmap, 48, 72);
//this.drawText(bitmap, 'Animation', 60);
return bitmap;
};
Sprite_FastForwardButton.prototype.drawBack = function(
bitmap, x, y, width, height, color1, color2
) {
const context = bitmap.context;
context.save();
context.beginPath();
context.moveTo(x + 8, y);
context.arcTo(x + width, y, x + width, y + height, 8);
context.arcTo(x + width, y + height, x, y + height, 8);
context.arcTo(x, y + height, x, y, 8);
context.arcTo(x, y, x + width, y, 8);
context.closePath();
const gradient = context.createLinearGradient(x, y, x, y + height);
gradient.addColorStop(0, color1);
gradient.addColorStop(1, color2);
context.fillStyle = gradient;
context.fill();
context.restore();
};
Sprite_FastForwardButton.prototype.drawTriangle = function(bitmap, x, y) {
const height = 24;
const context = bitmap.context;
context.save();
context.beginPath();
context.moveTo(x, y - height / 2);
context.lineTo(x, y + height / 2);
context.lineTo(x + 20, y);
context.closePath();
context.fillStyle = 'white';
context.fill();
context.restore();
};
Sprite_FastForwardButton.prototype.resetFontSettings = function(bitmap) {
bitmap.fontFace = $gameSystem.mainFontFace();
bitmap.fontSize = 16;
bitmap.textColor = ColorManager.normalColor();
bitmap.outlineColor = ColorManager.outlineColor();
};
Sprite_FastForwardButton.prototype.drawText = function(bitmap, text, y) {
const width = bitmap.width;
const height = 20;
bitmap.drawText(text, 0, y, width, height, 'center');
};
Sprite_FastForwardButton.prototype.checkBitmap = function() {
if (!this._bitmapLoaded && this.bitmap.isReady()) {
this._bitmapLoaded = true;
this.setupFrames();
}
};
Sprite_FastForwardButton.prototype.isPressed = function() {
return $gameTemp.isBattleFastForward();
};
Sprite_FastForwardButton.prototype.isClickEnabled = function() {
return this.visible;
};
Sprite_FastForwardButton.prototype.updatePosition = function() {
this.x = Graphics.boxWidth - this.width - 4;
this.y = this._bottomY - this.height - 4;
};
Sprite_FastForwardButton.prototype.onClick = function() {
$gameTemp.switchBattleFastForward();
};
//-------------------------------------------------------------------------
// Window_BattleLog
const _Window_BattleLog_isFastForward = Window_BattleLog.prototype.isFastForward;
Window_BattleLog.prototype.isFastForward = function() {
return _Window_BattleLog_isFastForward ||
$gameTemp.isBattleFastForward();
};
//-------------------------------------------------------------------------
// Scene_Battle
const _Scene_Battle_createButtons = Scene_Battle.prototype.createButtons;
Scene_Battle.prototype.createButtons = function() {
_Scene_Battle_createButtons.apply(this, arguments);
if (param_FastForwardType === 'toggle') {
this.createFastForwardButton();
}
};
Scene_Battle.prototype.createFastForwardButton = function() {
this._fastForwardButton = new Sprite_FastForwardButton(this.buttonY());
this.addWindow(this._fastForwardButton);
};
const _Scene_Battle_update = Scene_Battle.prototype.update;
Scene_Battle.prototype.update = function() {
_Scene_Battle_update.apply(this, arguments);
this.updateFastForward();
};
Scene_Battle.prototype.updateFastForward = function() {
if (this._fastForwardButton) {
if (this._fastForwardButton.visible &&
Input.isTriggered(param_ToggleButton)) {
$gameTemp.switchBattleFastForward();
}
} else {
if (this.isFastForward()) {
$gameTemp.enableBattleFastForward();
} else {
$gameTemp.disableBattleFastForward();
}
}
};
Scene_Battle.prototype.isFastForward = function() {
return (
Input.isLongPressed('ok') ||
Input.isPressed('shift') ||
TouchInput.isLongPressed()
);
};
const _Scene_Battle_updateVisibility = Scene_Battle.prototype.updateVisibility;
Scene_Battle.prototype.updateVisibility = function() {
_Scene_Battle_updateVisibility.apply(this, arguments);
this.updateFastForwardVisibility();
};
Scene_Battle.prototype.updateFastForwardVisibility = function() {
if (this._fastForwardButton) {
this._fastForwardButton.visible =
!this._helpWindow.visible &&
this._messageWindow.isClosed() &&
BattleManager._phase !== '';
}
};
})();