-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSlowMessage.js
More file actions
137 lines (128 loc) · 3.67 KB
/
SlowMessage.js
File metadata and controls
137 lines (128 loc) · 3.67 KB
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
//=============================================================================
// RPG Maker MZ - メッセージの表示をゆっくりにする
//=============================================================================
/*:en
* @target MZ
* @plugindesc Slows down message speed.
* @author MihailJP
* @url https://github.com/MihailJP/mihamzplugin/blob/master/SlowMessage.js
*
* @help SlowMessage.js
*
* Slows down the message speed.
* Still can be skipped with the button except explicit wait.
*
* Set wait with the plugin command `setMessageWait`.
*
* License: The Unlicense
*
* Changelog
* 21 Sept 2020: Fix parameter type
* 10 Sept 2020: First edition.
*
* @command setMessageWait
* @text Set message wait
* @desc Set wait for each letter [in frames].
*
* @arg wait
* @type number
* @text Wait
* @desc Each time a letter displayed, waits by the time specified here.
* @min 0
*/
/*:ja
* @target MZ
* @plugindesc メッセージの表示をゆっくりにする
* @author MihailJP
* @url https://github.com/MihailJP/mihamzplugin/blob/master/SlowMessage.js
*
* @help SlowMessage.js
*
* メッセージの表示速度をゆっくりにします。
* 明示的なウェイトがない限り、ボタンでスキップされます。
*
* プラグインコマンド setMessageWait を使用してウェイトを設定します。
*
* ライセンス: Unlicense
*
* 更新履歴
* 令和2年9月21日 パラメータの型を修正
* 令和2年9月10日 初版
*
* @command setMessageWait
* @text メッセージのウェイト設定
* @desc 文字表示ごとのウェイトをフレーム単位で設定します。
*
* @arg wait
* @type number
* @text ウェイト
* @desc 1文字表示するごとにここで指定した長さのウェイトを入れます。
* @min 0
*/
(() => {
const pluginName = "SlowMessage";
let waitPerCharacter = 0;
let tmpPos = NaN;
const orig_Window_Message_initMembers
= Window_Message.prototype.initMembers;
Window_Message.prototype.initMembers = function() {
orig_Window_Message_initMembers.call(this);
waitPerCharacter = waitPerCharacter;
};
const orig_Window_Message_clearFlags
= Window_Message.prototype.clearFlags;
Window_Message.prototype.clearFlags = function() {
orig_Window_Message_clearFlags.call(this);
this._waitSkippable = false;
};
const orig_Window_Message_updateWait
= Window_Message.prototype.updateWait;
Window_Message.prototype.updateWait = function() {
const result = orig_Window_Message_updateWait.call(this);
if (waitPerCharacter > 0) {
if (this._waitSkippable) {
try {
if (tmpPos == this._textState.x) {
this._waitCount = 0;
}
} catch (e) {
if (e instanceof TypeError) {
tmpPos = NaN;
} else {
throw e;
}
}
}
if (this._waitCount <= 0) {
this._waitSkippable = false;
}
if (this.isTriggered() && this._waitSkippable) {
this._waitSkippable = false;
this._waitCount = 0;
return false;
}
}
return result;
};
const orig_Window_Message_shouldBreakHere
= Window_Message.prototype.shouldBreakHere;
Window_Message.prototype.shouldBreakHere = function(textState) {
const result = orig_Window_Message_shouldBreakHere.call(this, textState);
if ((waitPerCharacter > 0) && result && !this._showFast && !this._lineShowFast
&& (this._waitCount <= 0))
{
this._waitCount = waitPerCharacter;
this._waitSkippable = true;
tmpPos = this._textState.x;
}
return result;
};
PluginManager.registerCommand(pluginName, "setMessageWait", args => {
const waitFrames = parseInt(args.wait);
if (waitFrames > 0) {
waitPerCharacter = waitFrames;
} else {
waitPerCharacter = 0;
}
});
})();