-
Notifications
You must be signed in to change notification settings - Fork 11
/
MNKR_DarkPlasma_AltWindowFrameMZ.js
432 lines (396 loc) · 13.6 KB
/
MNKR_DarkPlasma_AltWindowFrameMZ.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
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
/*
* --------------------------------------------------
* MNKR_DarkPlasma_AltWindowFrameMZ.js
* Ver.0.0.2
* Copyright (c) 2020 Munokura
* This software is released under the MIT license.
* http://opensource.org/licenses/mit-license.php
* --------------------------------------------------
*/
// DarkPlasma_AltWindowFramePatch
// Copyright (c) 2020 DarkPlasma
// This software is released under the MIT license.
// http://opensource.org/licenses/mit-license.php
/**
* 2020/04/10 1.0.0 公開
*/
/*:
* @target MZ
* @url https://raw.githubusercontent.com/munokura/MNKR-MZ-plugins/master/MNKR_DarkPlasma_AltWindowFrameMZ.js
* @plugindesc MADO作成素材を使用するためのプラグインRPGツクールMZ版
* @author DarkPlasma (改変 munokura)
* @license MIT
*
* @param Default Windowskin
* @desc 基本ウィンドウスキン
* @text 基本ウィンドウスキン
* @type select
* @option Window
* @value 0
* @option Window_Talk
* @value 1
* @option Window_Battle
* @value 2
* @option Window_Status
* @value 3
* @option Window_Other
* @value 4
* @default 0
*
* @param Custom Windowskins By Window
* @desc ウィンドウごとのスキン設定
* @text ウィンドウごとのスキン
* @type struct<CustomWindowskin>[]
* @default []
*
* @param Custom Windowskins By Scene
* @desc シーンごとのスキン設定
* @text シーンごとのスキン
* @type struct<CustomWindowskin>[]
* @default []
*
* @help
* MADO付属のAltWindowFrame.jsのRPGツクールMZ版です。
* DarkPlasma_AltWindowFramePatch.js を改変したものです。
*
* RPGツクールMZデフォルトにあるシーン名は
* プラグインパラメーターのコンボボックスで選択できます。
* ウィンドウ名は大量なので、下記からコピーして利用してください。
*
* Window_ActorCommand
* Window_BattleActor
* Window_BattleEnemy
* Window_BattleItem
* Window_BattleLog
* Window_BattleSkill
* Window_BattleStatus
* Window_ChoiceList
* Window_Command
* Window_EquipCommand
* Window_EquipItem
* Window_EquipSlot
* Window_EquipStatus
* Window_EventItem
* Window_GameEnd
* Window_Gold
* Window_Help
* Window_HorzCommand
* Window_ItemCategory
* Window_ItemList
* Window_MapName
* Window_MenuActor
* Window_MenuCommand
* Window_MenuStatus
* Window_Message
* Window_NameBox
* Window_NameEdit
* Window_NameInput
* Window_NumberInput
* Window_Options
* Window_PartyCommand
* Window_SavefileList
* Window_Scrollable
* Window_ScrollText
* Window_Selectable
* Window_ShopBuy
* Window_ShopCommand
* Window_ShopNumber
* Window_ShopSell
* Window_ShopStatus
* Window_SkillList
* Window_SkillStatus
* Window_SkillType
* Window_Status
* Window_StatusBase
* Window_StatusEquip
* Window_StatusParams
* Window_TitleCommand
*
*
* @requiredAssets img/system/Window_Talk
* @requiredAssets img/system/Window_Battle
* @requiredAssets img/system/Window_Status
* @requiredAssets img/system/Window_Other
*/
/*~struct~CustomWindowskin:
*
* @param Class Name
* @desc ウィンドウまたはシーンのクラス名(例: Window_TitleCommand, Scene_Shop)
* @text クラス名
* @type combo
* @option Scene_Battle
* @option Scene_GameEnd
* @option Scene_Gameover
* @option Scene_Item
* @option Scene_Load
* @option Scene_Map
* @option Scene_Menu
* @option Scene_Name
* @option Scene_Options
* @option Scene_Save
* @option Scene_Shop
* @option Scene_Title
* @option Window_Message
* @default
*
* @param Windowskin
* @desc ウィンドウスキン
* @text ウィンドウスキン
* @type select
* @option Window
* @value 0
* @option Window_Talk
* @value 1
* @option Window_Battle
* @value 2
* @option Window_Status
* @value 3
* @option Window_Other
* @value 4
* @default 0
*/
(function () {
'use strict';
const pluginName = document.currentScript.src.replace(/^.*\/(.*).js$/, function () {
return arguments[1];
});
const pluginParameters = PluginManager.parameters(pluginName);
const settings = {
defaultWindowskin: Number(pluginParameters['Default Windowskin'] || 0),
customWindowskinsByWindow: JsonEx.parse(pluginParameters['Custom Windowskins By Window'] || '[]').map(customSkin => {
const parsed = JsonEx.parse(customSkin);
return {
className: String(parsed['Class Name'] || ''),
windowskin: Number(parsed['Windowskin'] || 0)
};
}),
customWindowskinsByScene: JsonEx.parse(pluginParameters['Custom Windowskins By Scene'] || '[]').map(customSkin => {
const parsed = JsonEx.parse(customSkin);
return {
className: String(parsed['Class Name'] || ''),
windowskin: Number(parsed['Windowskin'] || 0)
};
})
};
const WINDOWSKIN_TYPE = {
DEFAULT: 0,
TALK: 1,
BATTLE: 2,
STATUS: 3,
OTHER: 4,
};
const WINDOWSKIN_NAME = [
'Window',
'Window_Talk',
'Window_Battle',
'Window_Status',
'Window_Other'
];
const DEFAULT_WINDOWSKINS_BY_WINDOW = [
{ className: "Window_Message", windowskin: WINDOWSKIN_TYPE.TALK },
];
const DEFAULT_WINDOWSKINS_BY_SCENE = [
{ className: "Scene_Title", windowskin: WINDOWSKIN_TYPE.OTHER },
{ className: "Scene_Menu", windowskin: WINDOWSKIN_TYPE.STATUS },
{ className: "Scene_Item", windowskin: WINDOWSKIN_TYPE.STATUS },
{ className: "Scene_Skill", windowskin: WINDOWSKIN_TYPE.STATUS },
{ className: "Scene_Equip", windowskin: WINDOWSKIN_TYPE.STATUS },
{ className: "Scene_Status", windowskin: WINDOWSKIN_TYPE.STATUS },
{ className: "Scene_Options", windowskin: WINDOWSKIN_TYPE.STATUS },
{ className: "Scene_Load", windowskin: WINDOWSKIN_TYPE.STATUS },
{ className: "Scene_Save", windowskin: WINDOWSKIN_TYPE.STATUS },
{ className: "Scene_GameEnd", windowskin: WINDOWSKIN_TYPE.STATUS },
{ className: "Scene_Battle", windowskin: WINDOWSKIN_TYPE.BATTLE }
];
const _Scene_Boot_loadSystemWindowImage = Scene_Boot.prototype.loadSystemWindowImage;
Scene_Boot.prototype.loadSystemWindowImage = function () {
_Scene_Boot_loadSystemWindowImage.call(this);
WINDOWSKIN_NAME.forEach(skin => ImageManager.reserveSystem(skin));
};
SceneManager.currentSceneCustomSkinName = function () {
if (!this._scene) {
return null;
}
const customSkin = settings.customWindowskinsByScene.find(skin => skin.className === this._scene.constructor.name);
return customSkin ? WINDOWSKIN_NAME[customSkin.windowskin] : null;
};
SceneManager.currentSceneDefaultSkinName = function () {
if (!this._scene) {
return null;
}
const skin = DEFAULT_WINDOWSKINS_BY_SCENE.find(skin => skin.className === this._scene.constructor.name);
return skin ? WINDOWSKIN_NAME[skin.windowskin] : null;
};
/**
* ウィンドウスキンの名前を取得する
* 設定の優先順位は
* ウィンドウごとのカスタムスキン
* シーンごとのカスタムスキン
* ウィンドウごとのデフォルトスキン
* シーンごとのデフォルトスキン
* デフォルトスキン
*/
Window_Base.prototype.getWindowskinName = function () {
const customSkin = settings.customWindowskinsByWindow.find(skin => skin.className === this.constructor.name);
if (customSkin) {
return WINDOWSKIN_NAME[customSkin.windowskin];
}
const sceneCustomSkinName = SceneManager.currentSceneCustomSkinName();
if (sceneCustomSkinName) {
return sceneCustomSkinName;
}
const windowDefaultSKin = DEFAULT_WINDOWSKINS_BY_WINDOW.find(skin => skin.className === this.constructor.name);
if (windowDefaultSKin) {
return WINDOWSKIN_NAME[windowDefaultSKin.windowskin];
}
const sceneDefaultSkinName = SceneManager.currentSceneDefaultSkinName();
if (sceneDefaultSkinName) {
return sceneDefaultSkinName;
}
return WINDOWSKIN_NAME[settings.defaultWindowskin];
};
Window_Base.prototype.loadWindowskin = function () {
this.windowskin = ImageManager.loadSystem(this.getWindowskinName());
};
const _Scene_Title_Create = Scene_Title.prototype.create;
Scene_Title.prototype.create = function () {
_Scene_Title_Create.call(this);
this._commandWindow.loadWindowskin();
};
const _Scene_Menu_Create = Scene_Menu.prototype.create;
Scene_Menu.prototype.create = function () {
_Scene_Menu_Create.call(this);
this._statusWindow.loadWindowskin();
this._commandWindow.loadWindowskin();
this._goldWindow.loadWindowskin();
};
const _Scene_Item_Create = Scene_Item.prototype.create;
Scene_Item.prototype.create = function () {
_Scene_Item_Create.call(this);
this._categoryWindow.loadWindowskin();
this._itemWindow.loadWindowskin();
this._helpWindow.loadWindowskin();
this._actorWindow.loadWindowskin();
}
const _Scene_Skill_Create = Scene_Skill.prototype.create;
Scene_Skill.prototype.create = function () {
_Scene_Skill_Create.call(this);
this._helpWindow.loadWindowskin();
this._skillTypeWindow.loadWindowskin();
this._statusWindow.loadWindowskin();
this._itemWindow.loadWindowskin();
this._actorWindow.loadWindowskin();
};
const _Scene_Equip_Create = Scene_Equip.prototype.create;
Scene_Equip.prototype.create = function () {
_Scene_Equip_Create.call(this);
this._helpWindow.loadWindowskin();
this._statusWindow.loadWindowskin();
this._commandWindow.loadWindowskin();
this._slotWindow.loadWindowskin();
this._itemWindow.loadWindowskin();
};
const _Scene_Status_Create = Scene_Status.prototype.create;
Scene_Status.prototype.create = function () {
_Scene_Status_Create.call(this);
this._statusWindow.loadWindowskin();
};
const _Scene_Options_Create = Scene_Options.prototype.create;
Scene_Options.prototype.create = function () {
_Scene_Options_Create.call(this);
this._optionsWindow.loadWindowskin();
};
const _Scene_File_Create = Scene_File.prototype.create;
Scene_File.prototype.create = function () {
_Scene_File_Create.call(this);
this._helpWindow.loadWindowskin();
this._listWindow.loadWindowskin();
};
const _Scene_GameEnd_Create = Scene_GameEnd.prototype.create;
Scene_GameEnd.prototype.create = function () {
_Scene_GameEnd_Create.call(this);
this._commandWindow.loadWindowskin();
};
const _Scene_Battle_Create = Scene_Battle.prototype.create;
Scene_Battle.prototype.create = function () {
_Scene_Battle_Create.call(this);
this._logWindow.loadWindowskin();
this._statusWindow.loadWindowskin();
this._partyCommandWindow.loadWindowskin();
this._actorCommandWindow.loadWindowskin();
this._helpWindow.loadWindowskin();
this._skillWindow.loadWindowskin();
this._itemWindow.loadWindowskin();
this._actorWindow.loadWindowskin();
this._enemyWindow.loadWindowskin();
this._messageWindow.loadWindowskin();
this._scrollTextWindow.loadWindowskin();
};
const _Window_Message_Initialize = Window_Message.prototype.initialize;
Window_Message.prototype.initialize = function (rect) {
_Window_Message_Initialize.call(this, rect);
this.loadWindowskin();
};
Window.prototype._refreshFrame = function () {
let w = this._width;
let h = this._height;
let m = 24;
let bitmap = new Bitmap(w, h);
this._frameSprite.bitmap = bitmap;
this._frameSprite.setFrame(0, 0, w, h);
if (w > 0 && h > 0 && this._windowskin) {
let skin = this._windowskin;
let p = 96;
let q = 96;
bitmap.blt(skin, p + 0, 0 + 0, m, m, 0, 0, m, m);
bitmap.blt(skin, p + 0, 0 + q - m, m, m, 0, h - m, m, m);
bitmap.blt(skin, p + q - m, 0 + 0, m, m, w - m, 0, m, m);
bitmap.blt(skin, p + q - m, 0 + q - m, m, m, w - m, h - m, m, m);
let frameHeight = 48;
let heightCount = Math.floor((h - frameHeight) / frameHeight);
let remainder = (h - frameHeight) % frameHeight;
for (let i = 0; i < heightCount; i++) {
bitmap.blt(skin, p + 0, 0 + m, m, p - m * 2, 0, m + frameHeight * i, m, frameHeight);
bitmap.blt(skin, p + q - m, 0 + m, m, p - m * 2, w - m, m + frameHeight * i, m, frameHeight);
}
if (remainder != 0) {
bitmap.blt(skin, p + 0, 0 + m, m, remainder, 0, m + frameHeight * heightCount, m, remainder);
bitmap.blt(skin, p + q - m, 0 + m, m, remainder, w - m, m + frameHeight * heightCount, m, remainder);
}
let frameWidth = 48;
let widthCount = Math.floor((w - frameWidth) / frameWidth);
remainder = (w - frameWidth) % frameWidth;
for (let j = 0; j < widthCount; j++) {
bitmap.blt(skin, p + m, 0 + 0, p - m * 2, m, m + frameWidth * j, 0, frameWidth, m);
bitmap.blt(skin, p + m, 0 + q - m, p - m * 2, m, m + frameWidth * j, h - m, frameWidth, m);
}
if (remainder != 0) {
bitmap.blt(skin, p + m, 0 + 0, remainder, m, m + frameWidth * widthCount, 0, remainder, m);
bitmap.blt(skin, p + m, 0 + q - m, remainder, m, m + frameWidth * widthCount, h - m, remainder, m);
}
let r = 48;
let s = 48;
bitmap.blt(skin, 0, 0 + q * 4, r, s, 0, 0, r, s);
bitmap.blt(skin, r, 0 + q * 4, r, s, w - r, 0, r, s);
bitmap.blt(skin, r * 2, 0 + q * 4, r, s, 0, h - r, r, s);
bitmap.blt(skin, r * 3, 0 + q * 4, r, s, w - r, h - r, r, s);
}
};
Window.prototype._refreshBack = function () {
let m = this._margin + 6;
let w = this._width - m * 2;
let h = this._height - m * 2;
let bitmap = new Bitmap(w, h);
this._backSprite.bitmap = bitmap;
this._backSprite.setFrame(0, 0, w, h);
this._backSprite.move(m, m);
if (w > 0 && h > 0 && this._windowskin) {
let p = 192;
for (let y = 0; y < h; y += p) {
for (let x = 0; x < w; x += p) {
bitmap.blt(this._windowskin, 0, p, p, p, x, y, p, p);
}
}
}
};
})();