forked from aaixy/rm-mvmz-plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAXY_Quality.js
354 lines (337 loc) · 11.2 KB
/
AXY_Quality.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
//=============================================================================
// A XueYu Plugins - Quality
// AXY_Quality.js
// Version: 1.02
// License: MIT
//=============================================================================
/*:
* @plugindesc v1.02 Display colorful name of actor, class, enemy, item, armor, weapon, skill, etc.
* @author A XueYu Plugins
*
* @help
* Introduction
* This plugin allows you to set colorful name of actor, class, enemy, item, armor, weapon, skill, etc.
* Github: https://github.com/aaixy/rmmv-plugins
*
* Usage:
* Write <quality:3> to meta note box,
* such as actor, class, item, weapon, armor, enemy, state;
* This plugin must be place before YEP_ItemCore.js and BOB_SocketsEx.js;
* I have to hacked YEP_ItemCore.js about drawEquippedActor to draw current name color;
* If you use YEP_VictoryAftermath.js, the order is no matter.
* But if you use MOG_BattleResult.js or MOG_TreasurePopup.js,
* This plugin must be place after MOG_BattleResult.js and MOG_TreasurePopup.js;
* actor color> class color;
* default class or actor color is index by param default set;
* default others color is index by param default set;
* script:
* AXY.Quality.get(type, id);
* return quality value or null;
* AXY.Quality.set(type, id, value);
* return true or false;
* type can be: actor, class, item, weapon, armor, enemy;
* Example:
* AXY.Quality.get('actor', 1);
* AXY.Quality.set('actor', 1, 2);
*
* changelog
* 1.02 2019.11.25
* add: compatible with MOG_BattleResult.js v1.1
* add: compatible with MOG_TreasurePopup.js v1.1
* 1.01 2019.11.24
* add: param: default;
* 1.00 2019.11.19
* first release.
*
* //=============================================================================
* End of Help File
* //=============================================================================
*
* @param quality
* @text Quality Settings
* @desc name and color.
* @type struct<qualityStruct>[]
* @default ["{\"name\":\"Incomplete\",\"color\":\"rgba(255,255,255,1)\"}","{\"name\":\"Damaged\",\" Color\":\"rgba(128,255,28,1)\"}","{\"name\":\"Ordinary\",\"color\":\"rgba(57,185,255,1)\"} ","{\"name\":\"Good\",\"color\":\"rgba(255,255,0,1)\"}","{\"name\":\"Exquisite\" ,\"color\":\"rgba(128,100,254,1)\"}","{\"name\":\"Excellent\",\"color\":\"rgba(255,0,100,1) \"}","{\"name\":\"Best\",\"color\":\"rgba(255,40,255,1)\"}","{\"name\":\" Perfect\",\"color\":\"rgba(255,128,0,1)\"}","{\"name\":\"Legend\",\"color\":\"rgba(255,128 ,0,1)\"}","{\"name\":\"Epic\",\"color\":\"rgba(255,128,0,1)\"}"]
*
* @param default
* @text Default Quality
* @desc Default Quality. default: 2
* @type number
* @default 2
*/
/*~struct~qualityStruct:
* @param name
* @text Name
* @desc Name it.
* @type text
* @default
*
* @param color
* @text Color
* @desc Color it. format: rgba(0~255,0~255,0~255,0~1), #000000~#ffffff, red, green, blue, yellow, etc.
* @type text
* @default
*
*/
// Imported
var Imported = Imported || {};
Imported.AXY_Quality = true;
// Parameter Variables
var AXY = AXY || {};
AXY.Quality = AXY.Quality || {};
AXY.Quality.Parameters = PluginManager.parameters('AXY_Quality');
AXY.Quality.Param = AXY.Quality.Param || {};
AXY.Quality.Alias = AXY.Quality.Alias || {};
AXY.Quality.Variables = AXY.Quality.Variables || {};
var RJO = RJO || {};
RJO.IQ = RJO.IQ || {};
RJO.HE = RJO.HE || {};
//=============================================================================
// Utils
//=============================================================================
// Create a utility function to parse complex parameters.
//=============================================================================
Utils.recursiveParse = function (param) {
try {
if (typeof JSON.parse(param) == 'object') {
return JSON.parse(
param,
function (key, value) {
try {
return this.recursiveParse(value);
} catch (e) {
return value;
}
}.bind(this)
);
} else {
return JSON.parse(
param,
function (key, value) {
return value;
}.bind(this)
);
}
} catch (e) {
return param;
}
};
//=============================================================================
// Parameters
//=============================================================================
// Read and parse parameters into a locally scoped Parameters object.
//=============================================================================
Object.keys(AXY.Quality.Parameters).forEach(function (key) {
return (AXY.Quality.Param[key] = Utils.recursiveParse(
AXY.Quality.Parameters[key]
));
});
// Main
(function () {
AXY.Quality.get = function (type, id) {
switch (type) {
case 'actor':
return $gameActors.actor(id).actor().meta.quality;
case 'class':
return $gameActors.actor(id).currentClass().meta.quality;
case 'item':
return $dataItems[id].meta.quality;
case 'weapon':
return $dataWeapons[id].meta.quality;
case 'armor':
return $$dataArmors[id].meta.quality;
case 'enemy':
return $dataEnemies[id].meta.quality;
default:
return null;
}
};
AXY.Quality.set = function (type, id, value) {
switch (type) {
case 'actor':
$gameActors.actor(id).actor().meta.quality = value;
break;
case 'class':
$gameActors.actor(id).currentClass().meta.quality = value;
break;
case 'item':
$dataItems[id].meta.quality = value;
break;
case 'weapon':
$dataWeapons[id].meta.quality = value;
break;
case 'armor':
$$dataArmors[id].meta.quality = value;
break;
case 'enemy':
$dataEnemies[id].meta.quality = value;
break;
default:
return false;
}
return true;
};
RJO.IQ.getItemExtraDescParams2 = RJO.HE.getItemExtraDescParams2;
RJO.HE.normalcolor = function (item) {
//console.log(item.meta);
return AXY.Quality.Param.quality[
item.meta.quality || AXY.Quality.Param.default
].color;
};
RJO.HE.namecolor = function (item) {
//console.log(item.meta);
return AXY.Quality.Param.quality[
item.meta.quality || AXY.Quality.Param.default
].color;
};
RJO.HE.getItemExtraDescParams2 = function (item, type) {
//console.log(item.meta);
RJO.IQ.getItemExtraDescParams2.call(this, item, type);
var text =
'<pos=AD text=品质:' +
AXY.Quality.Param.quality[
item.meta.quality || AXY.Quality.Param.default
].name +
' size=18 color=normalcolor line=false align=0>';
this.processExtraDescParams(item, text);
};
Window_Base.prototype.drawActorName = function (actor, x, y, width) {
width = width || 168;
var _color = AXY.Quality.Param.quality[AXY.Quality.Param.default].color;
if (this.hpColor(actor) == this.normalColor()) {
if (actor.actor().meta.quality) {
_color =
AXY.Quality.Param.quality[actor.actor().meta.quality].color;
} else if (actor.currentClass().meta.quality) {
_color =
AXY.Quality.Param.quality[actor.currentClass().meta.quality]
.color;
} else {
_color =
AXY.Quality.Param.quality[AXY.Quality.Param.default].color;
}
} else {
_color = this.hpColor(actor);
}
this.changeTextColor(_color);
this.drawText(actor.name(), x, y, width);
};
Window_Base.prototype.drawActorClass = function (actor, x, y, width) {
width = width || 168;
//this.resetTextColor();
this.changeTextColor(
AXY.Quality.Param.quality[
actor.currentClass().meta.quality || AXY.Quality.Param.default
].color
);
this.drawText(actor.currentClass().name, x, y, width);
};
Window_BattleEnemy.prototype.drawItem = function (index) {
//this.resetTextColor();
this.changeTextColor(
AXY.Quality.Param.quality[
$dataEnemies[this._enemies[index]._enemyId].meta.quality ||
AXY.Quality.Param.default
].color
);
var name = this._enemies[index].name();
var rect = this.itemRectForText(index);
this.drawText(name, rect.x, rect.y, rect.width);
};
Window_Base.prototype.drawItemName = function (item, x, y, width) {
width = width || 312;
//console.log(item);
if (item) {
var iconBoxWidth = Window_Base._iconWidth + 4;
//this.resetTextColor();
this.changeTextColor(
AXY.Quality.Param.quality[
item.meta.quality || AXY.Quality.Param.default
].color
);
this.drawIcon(item.iconIndex, x + 2, y + 2);
this.drawText(item.name, x + iconBoxWidth, y, width - iconBoxWidth);
}
};
Window_ItemList.prototype.drawItemNumber = function (item, x, y, width) {
if (this.needsNumber()) {
this.resetTextColor();
this.drawText(':', x, y, width - this.textWidth('00'), 'right');
this.drawText($gameParty.numItems(item), x, y, width, 'right');
}
};
Sprite_ItemHelp.prototype.standardLineColor = function () {
//console.log(this);
return this.item ?
AXY.Quality.Param.quality[
this.item.meta.quality || AXY.Quality.Param.default
].color :
RJO.HE.ItemDescLineColor;
//return AXY.Quality.Param.quality[this.item.meta.quality || 0].color;
};
if (Imported.MOG_TreasurePopup) {
//==============================
// * refresh Name
//==============================
TreasureIcons.prototype.refreshName = function () {
this._name.bitmap.clear();
var name = this._item ? this._item.name + " x " + this._amount : this._amount;
//console.log(this._item);
if (this._item) {
this._name.bitmap.textColor =
AXY.Quality.Param.quality[
this._item.meta.quality || AXY.Quality.Param.default
].color;
}
this._name.bitmap.drawText(name, 0, 0, 145, 32);
};
}
if (Imported.MOG_BattleResult) {
//==============================
// * Add ICon
//==============================
BattleResult.prototype.addIcon = function (sprite, data) {
var icon = new Sprite(this._icon_img);
var w = Window_Base._iconWidth;
var h = Window_Base._iconHeight;
var sx = data.iconIndex % 16 * w;
var sy = Math.floor(data.iconIndex / 16) * h;
icon.setFrame(sx, sy, w, h);
sprite.addChild(icon);
var name = new Sprite(new Bitmap(160, 32));
//console.log(data);
name.bitmap.textColor =
AXY.Quality.Param.quality[
data.meta.quality || AXY.Quality.Param.default
].color;
name.bitmap.drawText(data.name, 0, 0, 160, 32);
name.x = w + 4;
sprite.addChild(name);
};
//==============================
// * Create Actor Name
//==============================
BattleResult.prototype.createActorName = function () {
this._name = new Sprite(new Bitmap(140, 32));
this._name.opacity = 0;
//console.log(this._actor);
var _color = AXY.Quality.Param.quality[AXY.Quality.Param.default].color;
if (this._actor.actor().meta.quality) {
_color =
AXY.Quality.Param.quality[this._actor.actor().meta.quality].color;
} else if (this._actor.currentClass().meta.quality) {
_color =
AXY.Quality.Param.quality[this._actor.currentClass().meta.quality]
.color;
} else {
_color =
AXY.Quality.Param.quality[AXY.Quality.Param.default].color;
}
this._name.bitmap.textColor = _color;
this._name.bitmap.drawText(this._actor._name, 0, 0, 140, 32);
this._name.x = Moghunter.bresult_name_x;
this._name.y = Moghunter.bresult_name_y;
this.addChild(this._name);
};
}
})();