-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBattleResultsPopupMZ.js
186 lines (167 loc) · 5.94 KB
/
BattleResultsPopupMZ.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
//=============================================================================
// BattleResultsPopupMZ.js
//=============================================================================
/*:
* @target MZ
* @plugindesc Displays a battle results window instead of text messages.
* @author Yoji Ojima(Ported for RMMZ by Tamaki Awana)
*
* @param ShowLevelUp
* @text Showing messages when leveling up
* @desc Whether to show messages when leveling up
* @type boolean
* @on Show
* @off Don't show
* @default false
*
* @help This plugin is a port to RPG Maker MZ
* that RPG Maker MV plugin "Battle Results Popup" (made by Yoji Ojima).
* This plugin displays a battle results window instead of text messages.
* And, I have added a function to switch whether to show the message
* when leveling up.
*
* This plugin does not provide plugin commands.
*
* Update History:
* ver.1.0.2 Code optimize
* Fix window positions
* ver.1.0.1 RMMZ 1.3.2 supported
* ver.1.0 Release
*
* ---
* This work is provided under the TKCM Blue License
* - https://rpgmaker.materialcommons.org/tkcm-b-summary/
* Require RPG Maker: RPG Maker MV
* Credits display:
* Original plugin: Yoji Ojima
* Ported for RPG Maker MZ: Tamaki Awana(https://razor-edge.work/)
*/
/*:ja
* @target MZ
* @plugindesc 戦闘結果の表示をポップアップ形式に変更します。
* @author Yoji Ojima(MZ移植:沫那環)
*
* @param ShowLevelUp
* @text レベルアップ時のメッセージの表示
* @desc レベルアップした時に、メッセージを表示するかどうか
* @type boolean
* @on 表示する
* @off 表示しない
* @default false
*
* @help Yoji Ojima様作のRPGツクールMV用プラグイン「BattleResultsPopup」を、
* RPGツクールMZ用に移植したものです。
* このプラグインを導入すると、戦闘結果の表示をポップアップ形式に変更します。
* さらに、レベルアップ時のメッセージを表示するかどうかを
* 切り替える機能を追加しました。
*
* このプラグインには、プラグインコマンドはありません。
*
* 【更新履歴】
* ver.1.0.2 コードを最適化
* ウィンドウの表示位置を調節
* ver.1.0.1 MZの1.3.2へ対応
* ver.1.0 公開
*
* ---
* この作品は ツクラー・コモンズ・ブルー・ライセンスの下に提供されています。
* https://tkler.materialcommons.org/tkcm-b-summary/
* ・必要ツクールシリーズ:RPGツクールMV
* ・クレジット:原版制作:Yoji Ojima
* MZ移植:沫那環(https://razor-edge.work/)
*/
(() => {
const pluginName = decodeURIComponent(document.currentScript.src).match(/([^\/]+)\.js$/)[1];
const parameters = PluginManager.parameters(pluginName);
const showlvup = String(parameters["ShowLevelUp"] || false);
let resultDisplaying = 0;
const _BattleManager_initMembers = BattleManager.initMembers;
BattleManager.initMembers = function () {
_BattleManager_initMembers.call(this);
resultDisplaying = 0;
};
const _BattleManager_update = BattleManager.update;
BattleManager.update = function (timeActive) {
_BattleManager_update.call(this, timeActive);
if (resultDisplaying > 0) {
if (++resultDisplaying >= 60) {
if (Input.isTriggered("ok") || TouchInput.isTriggered()) {
resultDisplaying = 0;
}
}
}
};
const _BattleManager_isBusy = BattleManager.isBusy;
BattleManager.isBusy = function () {
return _BattleManager_isBusy.call(this) || resultDisplaying > 0;
};
BattleManager.displayVictoryMessage = function () {};
BattleManager.displayRewards = function () {
resultDisplaying = 1;
};
Game_Actor.prototype.shouldDisplayLevelUp = function () {
if (showlvup == "true") {
return true;
} else {
return false;
}
};
const _Scene_Battle_update = Scene_Battle.prototype.update;
Scene_Battle.prototype.update = function () {
_Scene_Battle_update.call(this);
if (resultDisplaying > 30 && !this._resultWindow) {
this._resultWindow = new Window_BattleResults();
this.addWindow(this._resultWindow);
}
};
const _Scene_Battle_stop = Scene_Battle.prototype.stop;
Scene_Battle.prototype.stop = function () {
_Scene_Battle_stop.call(this);
if (this._resultWindow) {
this._resultWindow.close();
}
};
function Window_BattleResults() {
this.initialize(...arguments);
}
Window_BattleResults.prototype = Object.create(Window_Base.prototype);
Window_BattleResults.prototype.constructor = Window_BattleResults;
Window_BattleResults.prototype.initialize = function () {
const rewards = BattleManager._rewards;
const ww = 400;
let wh = this.fittingHeight(Math.min(9, rewards.items.length + 1));
const statusHeight = this.fittingHeight(4);
const wx = (Graphics.boxWidth - ww) / 2;
let wy = (Graphics.boxHeight - statusHeight - wh) / 2;
Window_Base.prototype.initialize.call(this, new Rectangle(wx, wy, ww, wh));
this.refresh();
this.openness = 0;
this.open();
};
Window_BattleResults.prototype.refresh = function () {
let x = this.itemPadding();
let y = 0;
let width = this.contents.width;
const lineHeight = this.lineHeight();
const rewards = BattleManager._rewards;
const items = rewards.items;
this.contents.clear();
this.resetTextColor();
this.drawText(rewards.exp, x, y);
x += this.textWidth(rewards.exp) + 6;
this.changeTextColor(this.systemColor());
this.drawText(TextManager.expA, x, y);
x += this.textWidth(TextManager.expA + " ");
this.resetTextColor();
this.drawText(rewards.gold, x, y);
x += this.textWidth(rewards.gold) + 6;
this.changeTextColor(this.systemColor());
this.drawText(TextManager.currencyUnit, x, y);
x = 0;
y += lineHeight;
items.forEach(function (item) {
this.drawItemName(item, x, y, width);
y += lineHeight;
}, this);
};
})();