/
会話ウィンドウの出現消去に演出追加.js
273 lines (239 loc) · 8.71 KB
/
会話ウィンドウの出現消去に演出追加.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
/*--------------------------------------------------------------------------
会話ウィンドウの出現消去に演出追加 ver 1.0
■作成者
キュウブ
■概要
デフォルトでは会話ウィンドウは突然現れたり、消えますが、
このスクリプトを導入すると出現、消去時に演出が入るようになります。
■注意点
イベント終了時に会話ウィンドウが残ったままだと正しく消去されない可能性があります。
必ず、イベント終了時、
・メッセージの表示コマンドによる会話ウィンドウが残っている場合
「メッセージ消去」と「ウェイト」を入れて消去演出の間を設けてください。
・スチルメッセージコマンドによる会話ウィンドウが残っている場合
「ウェイト」を入れて消去演出の間を設けてください。
※ウェイトは10フレームで十分です。
■更新履歴
ver 1.0 (2021/12/12)
初版
■対応バージョン
SRPG Studio Version:1.161
■規約
・利用はSRPG Studioを使ったゲームに限ります。
・商用・非商用問いません。フリーです。
・加工等、問題ありません。
・クレジット明記無し OK (明記する場合は"キュウブ"でお願いします)
・再配布、転載 OK (バグなどがあったら修正できる方はご自身で修正版を配布してもらっても構いません)
・wiki掲載 OK
・SRPG Studio利用規約は遵守してください。
--------------------------------------------------------------------------*/
(function(){
var MessageViewMode = {
APPEAR: 0,
SHOW: 1,
ERASE: 2,
NONE: 3
};
BaseMessageView._appearFrame = 10;
BaseMessageView._eraseFrame = 10;
BaseMessageView._appearCounter = null;
BaseMessageView._eraseCounter = null;
var _BaseMessageView_setupMessageView = BaseMessageView.setupMessageView;
BaseMessageView.setupMessageView = function(messageViewParam) {
this._appearCounter = createObject(CycleCounter);
this._appearCounter.disableGameAcceleration();
this._appearCounter.setCounterInfo(this._appearFrame);
this._eraseCounter = createObject(CycleCounter);
this._eraseCounter.disableGameAcceleration();
this._eraseCounter.setCounterInfo(this._eraseFrame);
this.changeCycleMode(MessageViewMode.APPEAR);
_BaseMessageView_setupMessageView.apply(this, arguments);
};
// メッセージテロップは演出を省略する
TeropView.setupMessageView = function(messageViewParam) {
this._appearCounter = createObject(CycleCounter);
this._appearCounter.disableGameAcceleration();
this._appearCounter.setCounterInfo(0);
this._eraseCounter = createObject(CycleCounter);
this._eraseCounter.disableGameAcceleration();
this._eraseCounter.setCounterInfo(0);
this.changeCycleMode(MessageViewMode.SHOW);
_BaseMessageView_setupMessageView.apply(this, arguments);
};
BaseMessageView.skipAppear = function() {
this.changeCycleMode(MessageViewMode.SHOW);
};
BaseMessageView.setErase = function() {
this.changeCycleMode(MessageViewMode.ERASE);
};
var _FaceView_setupMessageView = FaceView.setupMessageView;
FaceView.setupMessageView = function(messageViewParam) {
var pos = messageViewParam.pos;
if (pos === MessagePos.TOP && this._topView) {
_FaceView_setupMessageView.apply(this, arguments);
this._topView.skipAppear();
}
else if (pos === MessagePos.CENTER && this._centerView) {
_FaceView_setupMessageView.apply(this, arguments);
this._centerView.skipAppear();
}
else if (pos === MessagePos.BOTTOM && this._bottomView) {
_FaceView_setupMessageView.apply(this, arguments);
this._bottomView.skipAppear();
}
else {
_FaceView_setupMessageView.apply(this, arguments);
}
};
var _BaseMessageView_moveMessageView = BaseMessageView.moveMessageView;
BaseMessageView.moveMessageView = function() {
var mode = this.getCycleMode();
if (mode === MessageViewMode.APPEAR) {
return this._moveAppear();
}
else if (mode === MessageViewMode.ERASE) {
return this._moveErase();
}
else {
return _BaseMessageView_moveMessageView.call(this);
}
};
var _StillView_moveMessageView = StillView.moveMessageView;
StillView.moveMessageView = function() {
var mode = this.getCycleMode();
var showMoveResult;
if (mode === MessageViewMode.APPEAR) {
return this._moveAppear();
}
else if (mode === MessageViewMode.ERASE) {
return this._moveErase();
}
else {
showMoveResult = _StillView_moveMessageView.call(this);
if (showMoveResult !== MoveResult.CONTINUE) {
this.changeCycleMode(MessageViewMode.ERASE);
}
return MoveResult.CONTINUE;
}
};
var _BaseMessageView_drawMessageView = BaseMessageView.drawMessageView;
BaseMessageView.drawMessageView = function(isActive, pos) {
var mode = this.getCycleMode();
if (mode === MessageViewMode.APPEAR) {
this._drawAppear(pos);
}
else if (mode === MessageViewMode.ERASE) {
this._drawErase(pos);
}
else {
_BaseMessageView_drawMessageView.apply(this, arguments);
}
};
BaseMessageView._moveAppear = function() {
if (this._appearCounter.moveCycleCounter() !== MoveResult.CONTINUE) {
this.changeCycleMode(MessageViewMode.SHOW);
}
return MoveResult.CONTINUE;
};
BaseMessageView._moveErase = function() {
if (this._eraseCounter.moveCycleCounter() !== MoveResult.CONTINUE) {
this.changeCycleMode(MessageViewMode.NONE);
return MoveResult.END;
}
return MoveResult.CONTINUE;
};
BaseMessageView._drawAppear = function(pos) {
var textui = this._messageLayout.getWindowTextUI();
var picWindow = textui.getUIImage();
var currentFrame = this._appearCounter.getCounter();
var currentHeight = Math.floor(UIFormat.TEXTWINDOW_HEIGHT / this._appearFrame * currentFrame);
var xWindow = pos.x + this._messageLayout.getWindowX();
var yWindow = pos.y + this._messageLayout.getWindowY() + UIFormat.TEXTWINDOW_HEIGHT / 2 - Math.floor(currentHeight / 2);
if (picWindow === null || !this._isWindowDisplayable) {
return;
}
picWindow.drawStretchParts(
xWindow,
yWindow,
UIFormat.TEXTWINDOW_WIDTH,
currentHeight,
0,
0,
UIFormat.TEXTWINDOW_WIDTH,
UIFormat.TEXTWINDOW_HEIGHT
);
};
BaseMessageView._drawErase = function(pos) {
var textui = this._messageLayout.getWindowTextUI();
var picWindow = textui.getUIImage();
var currentFrame = this._eraseCounter.getCounter();
var currentHeight = Math.floor(UIFormat.TEXTWINDOW_HEIGHT / this._eraseFrame * (this._eraseFrame - currentFrame));
var xWindow = pos.x + this._messageLayout.getWindowX();
var yWindow = pos.y + this._messageLayout.getWindowY() + UIFormat.TEXTWINDOW_HEIGHT / 2 - Math.floor(currentHeight / 2);
if (picWindow === null || !this._isWindowDisplayable) {
return;
}
picWindow.drawStretchParts(
xWindow,
yWindow,
UIFormat.TEXTWINDOW_WIDTH,
currentHeight,
0,
0,
UIFormat.TEXTWINDOW_WIDTH,
UIFormat.TEXTWINDOW_HEIGHT
);
};
// 会話ウィンドウの消去演出のために、毎フレーム各会話ウィンドウのmoveMessageViewを呼び出す。
// 本来であればFaceView.moveMessageView内に入れておくのが妥当だが、
// イベント終了時など一部の状況下で
// 呼び出し元となるMessageShowEventCommand.moveEventCommandCycleが呼び出されない可能性がある。
// よって、各会話ウィンドウが存在する限り確実に毎フレーム呼び出されるFaceView.drawMessageViewを利用する。
var _FaceView_drawMessageView = FaceView.drawMessageView;
FaceView.drawMessageView = function() {
if (
this._topView &&
this._topView.getCycleMode() === MessageViewMode.ERASE &&
this._topView.moveMessageView() !== MoveResult.CONTINUE
) {
this._topView = null;
}
if (
this._centerView &&
this._centerView.getCycleMode() === MessageViewMode.ERASE &&
this._centerView.moveMessageView() !== MoveResult.CONTINUE
) {
this._centerView = null;
}
if (
this._bottomView &&
this._bottomView.getCycleMode() === MessageViewMode.ERASE &&
this._bottomView.moveMessageView() !== MoveResult.CONTINUE
) {
this._bottomView = null;
}
_FaceView_drawMessageView.call(this);
};
// 各会話ウィンドウのインスタンスを会話削除時に即座に破棄しないようにする
FaceView.eraseMessage = function(flag) {
if (flag & MessageEraseFlag.TOP) {
if (this._topView !== null) {
this._topView.setErase();
this._topView.endMessageView();
}
}
if (flag & MessageEraseFlag.CENTER) {
if (this._centerView !== null) {
this._centerView.setErase();
this._centerView.endMessageView();
}
}
if (flag & MessageEraseFlag.BOTTOM) {
if (this._bottomView !== null) {
this._bottomView.setErase();
this._bottomView.endMessageView();
}
}
this._activePos = MessagePos.NONE;
};
})();