-
Notifications
You must be signed in to change notification settings - Fork 66
/
Copy pathMrTS_HPMPTPMulticolorGauges.js
171 lines (161 loc) · 6.75 KB
/
MrTS_HPMPTPMulticolorGauges.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
//=============================================================================
// MrTS_HPMPTPMulticolorGauges.js
//=============================================================================
//
var Imported = Imported || {};
Imported.MrTS_HPMPTPMulticolorGauges = true;
/*:
* @plugindesc Allows to set more than starting/ending color for HP/MP/TP gauges.
* @author Mr. Trivel
*
* @param Use HP Gauge
* @desc Use multicolored HP Gauge? True/False
* Default: True
* @default True
*
* @param Use MP Gauge
* @desc Use multicolored MP Gauge? True/False
* Default: True
* @default True
*
* @param Use TP Gauge
* @desc Use multicolored TP Gauge? True/False
* Default: True
* @default True
*
* @param HP Gauge
* @desc Colors for HP gauge. Any amount. In Hex.
* Default: #ff0000 #f1913c #dffc1d #3bbd48 #1f8304
* @default #ff0000 #f1913c #dffc1d #3bbd48 #1f8304
*
* @param MP Gauge
* @desc Colors for MP gauge. Any amount. In Hex
* Default: #f19aea #dab5eb #7f85fe #3800a9 #021456
* @default #f19aea #dab5eb #7f85fe #3800a9 #021456
*
* @param TP Gauge
* @desc Colors for TP gauge. Any amount. In Hex.
* Default: #ffffff #bababa #7a7a7a #393939 #000000
* @default #ffffff #bababa #7a7a7a #393939 #000000
*
* @help
* --------------------------------------------------------------------------------
* Terms of Use
* --------------------------------------------------------------------------------
* Don't remove the header or claim that you wrote this plugin.
* Credit Mr. Trivel if using this plugin in your project.
* Free for commercial and non-commercial projects.
* --------------------------------------------------------------------------------
* Version 1.2
* --------------------------------------------------------------------------------
*
* --------------------------------------------------------------------------------
* Version History
* --------------------------------------------------------------------------------
* 1.2 - Compatibility with MrTS_DifferentMPColorsAndNames
* - Crash fix with MP/TP bars
* 1.1 - Crash fix, disabling multicolor bars from plugin parameters added.
* 1.0 - Release
*/
(function() {
var parameters = PluginManager.parameters('MrTS_HPMPTPMulticolorGauges');
var paramHPGauge = String(parameters['HP Gauge'] || "#ff0000 #f1913c #dffc1d #3bbd48 #1f8304");
var paramMPGauge = String(parameters['MP Gauge'] || "#f19aea #dab5eb #7f85fe #3800a9 #021456");
var paramTPGauge = String(parameters['TP Gauge'] || "#ffffff #bababa #7a7a7a #393939 #000000");
var paramUseHP = (parameters['Use HP Gauge'] || "True").toLowerCase() === "true";
var paramUseMP = (parameters['Use MP Gauge'] || "True").toLowerCase() === "true";
var paramUseTP = (parameters['Use TP Gauge'] || "True").toLowerCase() === "true";
var parArrHP = paramHPGauge.split(' ');
var parArrMP = paramMPGauge.split(' ');
var parArrTP = paramTPGauge.split(' ');
var _WindowBase_drawActorHp = Window_Base.prototype.drawActorHp;
Window_Base.prototype.drawActorHp = function(actor, x, y, width) {
var hpColorArray = parArrHP;
if (Imported.MrTS_DifferentHpMpTpColorsAndNames)
{
this.setHpGaugeColors(actor.actorId());
hpColorArray = this._hpGaugeColors;
}
if (hpColorArray.length > 0 && paramUseHP)
{
width = width || 186;
var offset = Math.floor(width/(hpColorArray.length-1));
for (var i = 0; i < hpColorArray.length-1; i++) {
var color1 = hpColorArray[i];
var color2 = hpColorArray[i+1];
this.drawGauge(x + offset*i - (i !== 0 && i !== hpColorArray.length-1 ? 1 : 0), y, offset + (i !== 0 && i !== hpColorArray.length-1 ? 1 : 0), 1.00, color1, color2);
}
var rate = 1.00 - actor.hpRate();
var amount = width * rate;
var height = Imported.YEP_CoreEngine ? this.gaugeHeight() : 8;
var yPos = Imported.YEP_CoreEngine ? y + this.lineHeight() - height - 2 : Math.floor(y + this.lineHeight() - 8);
this.contents.fillRect(x+width-amount, yPos, amount, height, this.gaugeBackColor());
this.changeTextColor(this.systemColor());
this.drawText(TextManager.hpA, x, y, 44);
this.drawCurrentAndMax(actor.hp, actor.mhp, x, y, width,
this.hpColor(actor), this.normalColor());
}
else
_WindowBase_drawActorHp.call(this, actor, x, y, width);
};
var _WindowBase_drawActorMp = Window_Base.prototype.drawActorMp;
Window_Base.prototype.drawActorMp = function(actor, x, y, width) {
var mpColorArray = parArrMP;
if (Imported.MrTS_DifferentHpMpTpColorsAndNames)
{
this.setMpGaugeColors(actor.actorId());
mpColorArray = this._mpGaugeColors;
}
if (mpColorArray.length > 0 && paramUseMP)
{
width = width || 186;
var offset = Math.floor(width/(mpColorArray.length-1));
for (var i = 0; i < mpColorArray.length-1; i++) {
var color1 = mpColorArray[i];
var color2 = mpColorArray[i+1];
this.drawGauge(x + offset*i - (i !== 0 && i !== mpColorArray.length-1 ? 1 : 0), y, offset + (i !== 0 && i !== mpColorArray.length-1 ? 1 : 0), 1.00, color1, color2);
}
var rate = 1.00 - actor.mpRate();
var amount = width * rate;
var height = Imported.YEP_CoreEngine ? this.gaugeHeight() : 8;
var yPos = Imported.YEP_CoreEngine ? y + this.lineHeight() - height - 2 : y + this.lineHeight() - 9;
this.contents.fillRect(x+width-amount, yPos, amount, height, this.gaugeBackColor());
this.changeTextColor(this.systemColor());
this.drawText(TextManager.mpA, x, y, 44);
this.drawCurrentAndMax(actor.mp, actor.mmp, x, y, width,
this.mpColor(actor), this.normalColor());
}
else
_WindowBase_drawActorMp.call(this, actor, x, y, width);
};
var _WindowBase_drawActorTp = Window_Base.prototype.drawActorTp;
Window_Base.prototype.drawActorTp = function(actor, x, y, width) {
var tpColorArray = parArrTP;
if (Imported.MrTS_DifferentHpMpTpColorsAndNames)
{
this.setTpGaugeColors(actor.actorId());
tpColorArray = this._tpGaugeColors;
}
if (tpColorArray.length > 0 && paramUseTP)
{
width = width || 186;
var offset = Math.floor(width/(tpColorArray.length-1));
for (var i = 0; i < tpColorArray.length-1; i++) {
var color1 = tpColorArray[i];
var color2 = tpColorArray[i+1];
this.drawGauge(x + offset*i - (i !== 0 && i !== tpColorArray.length-1 ? 1 : 0), y, offset + (i !== 0 && i !== tpColorArray.length-1 ? 1 : 0), 1.00, color1, color2);
}
var rate = 1.00 - actor.tpRate();
var amount = width * rate;
var height = Imported.YEP_CoreEngine ? this.gaugeHeight() : 8;
var yPos = Imported.YEP_CoreEngine ? y + this.lineHeight() - height - 2 : y + this.lineHeight() - 9;
this.contents.fillRect(x+width-amount, yPos, amount, height, this.gaugeBackColor());
this.changeTextColor(this.systemColor());
this.drawText(TextManager.tpA, x, y, 44);
this.changeTextColor(this.tpColor(actor));
this.drawText(actor.tp, x + width - 64, y, 64, 'right');
}
else
_WindowBase_drawActorTp.call(this, actor, x, y, width);
};
})();