slave-princess-charlotte/data/Plugin/gauge.js
2025-10-12 13:17:46 -05:00

92 lines
2.4 KiB
JavaScript

var GAUGE_TYPE = {
NORMAL: 0,
EMPTY: 1,
DAMAGE: 2,
DAMAGE2: 3,
RECOVERY: 4
};
ContentRenderer.drawGauge2 = ContentRenderer.drawGauge;
ContentRenderer.drawGauge = function (x, y, curValue, maxValue, colorIndex, totalWidth, pic, damage, damage2, type2, noNewLine) {
if (pic === null) {
return;
}
if (maxValue <= 40 && ! noNewLine) {
y -= 10;
}
for (var i = 0; i < maxValue; i++) {
var type = GAUGE_TYPE.NORMAL;
if (type2) {
type = type2;
}
if (curValue <= i) {
type = GAUGE_TYPE.EMPTY;
}
else if (damage > 0 && i >= curValue - damage) {
type = GAUGE_TYPE.DAMAGE;
}
else if (damage2 > 0 && i >= curValue - damage - damage2) {
type = GAUGE_TYPE.DAMAGE2;
}
if (damage < 0 && i >= curValue && i < curValue - damage) {
type = GAUGE_TYPE.RECOVERY;
}
this.drawGaugeParts(x, y, i, type, pic, noNewLine);
}
};
ContentRenderer.drawGaugeParts = function (x, y, index, type, pic, noNewLine) {
y += 20;
var width = 10;
var height = 20;
if (index >= 40 && !noNewLine) {
index -= 40;
y -= 22;
} else {
y -= 2;
}
y += 10;
var sx = 0;
var sy = 0;
var interval = 6;
switch (type) {
case GAUGE_TYPE.EMPTY:
sx = width;
break;
case GAUGE_TYPE.DAMAGE:
sx = width * 2;
break;
case GAUGE_TYPE.DAMAGE2:
sx = width * 3;
break;
case GAUGE_TYPE.RECOVERY:
sx = width * 4;
break;
}
x += index * interval;
pic.drawParts(x, y, sx, sy, width, height);
};
GaugeBar.setGaugeInfo = function(value, maxValue, colorIndex, damage, damage2, noNewLine) {
this._balancer.setBalancerInfo(value, maxValue);
this._colorIndex = colorIndex;
this._partsCount = 11;
this._damage = damage;
this._damage2 = damage2;
this._noNewLine = noNewLine;
};
GaugeBar.drawGaugeBar = function(xBase, yBase, pic) {
var curValue = this._balancer.getCurrentValue();
var maxValue = this._balancer.getMaxValue();
ContentRenderer.drawGauge(xBase, yBase, curValue, maxValue, this._colorIndex, this.getGaugeWidth(), pic, this._damage, this._damage2, this._colorIndex - 1, this._noNewLine);
};
DefineControl.getNumberSpace = function() {
// 数字3けたを想定
return 28;
};