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

181 lines
No EOL
4.3 KiB
JavaScript

UIFormat.NUMBER_WIDTH = 160;
NumberRenderer._drawNumberInternal = function(x, y, number, pic, ySrc, width, height, alpha) {
var i, n;
var count = 0;
var digitArray = [];
if (pic === null || number < 0) {
return;
}
if (number === 0) {
pic.drawParts(x, y - 2, 0, ySrc, width, height);
return;
}
while (number > 0) {
n = Math.floor(number % 10);
number = Math.floor(number / 10);
digitArray[count] = n;
count++;
}
for (i = 0; i < count; i++) {
pic.setAlpha(alpha);
pic.drawParts(x, y - 2, digitArray[i] * width, ySrc, width, height);
x -= 14;
}
}
NumberRenderer._drawRightNumberInternal = function(x, y, number, pic, ySrc, width, height, alpha) {
var i, n;
var count = 0;
var digitArray = [];
if (pic === null || number < 0) {
return;
}
if (number === 0) {
pic.drawParts(x + 3, y + 1, 0, ySrc, width, height);
return;
}
while (number > 0) {
n = Math.floor(number % 10);
number = Math.floor(number / 10);
digitArray[count] = n;
count++;
}
for (i = count - 1; i >= 0; i--) {
pic.setAlpha(alpha);
pic.drawParts(x + 3, y + 1, digitArray[i] * width, ySrc, width, height);
x += 14;
}
};
var battleNumberPic = null;
function getBattleNumberPic() {
if (battleNumberPic) {
return battleNumberPic;
}
battleNumberPic = getMyNumberPic(127);
return battleNumberPic;
};
var battleHpNumberPic = null;
function getBattleHpNumberPic() {
if (battleHpNumberPic) {
return battleHpNumberPic;
}
battleHpNumberPic = getMyNumberPic(128);
return battleHpNumberPic;
};
function getMyNumberPic(id) {
var list = root.getBaseData().getGraphicsResourceList(GraphicsType.PICTURE, false);
var count = list.getCount();
if (count !== 0) {
pic = list.getDataFromId(id);
if (pic !== null) {
return pic;
}
}
return null;
};
var NumberRenderer2 = {
drawNumber: function(x, y, number) {
this.drawNumberColor(x, y, number, 0, 255);
},
drawNumberColor: function(x, y, number, colorIndex, alpha) {
var pic
if (colorIndex === 0) {
pic = getBattleNumberPic();
} else if (colorIndex === 1) {
pic = getBattleHpNumberPic();
}
var width = pic.getWidth() / 10;
var height = pic.getHeight();
var ySrc = 0;
this._drawNumberInternal(x, y, number, pic, ySrc, width, height, alpha);
},
drawRightNumber: function(x, y, number) {
this.drawRightNumberColor(x, y, number, 0, 255);
},
drawRightNumberColor: function(x, y, number, colorIndex, alpha) {
var pic = root.queryUI('number');
var width = UIFormat.NUMBER_WIDTH / 10;
var height = UIFormat.NUMBER_HEIGHT / 5;
var ySrc = height * colorIndex;
this._drawRightNumberInternal(x, y, number, pic, ySrc, width, height, alpha);
},
drawAttackNumber: function(x, y, number) {
this.drawAttackNumberColor(x, y, number, 0, 255);
},
drawAttackNumberColor: function(x, y, number, colorIndex, alpha) {
var pic = root.queryUI('bignumber');
var width = UIFormat.BIGNUMBER_WIDTH / 10;
var height = UIFormat.BIGNUMBER_HEIGHT / 5;
var ySrc = height * colorIndex;
this._drawAttackNumberInternal(x, y, number, pic, ySrc, width, height, alpha);
},
drawAttackNumberCenter: function(x, y, number) {
var dx;
if (number >= 1000) {
dx = 32;
}
else if (number >= 100) {
dx = 24;
}
else if (number >= 10) {
dx = 16;
}
else {
dx = 8;
}
this.drawAttackNumber(x - dx, y, number);
},
_drawNumberInternal: function(x, y, number, pic, ySrc, width, height, alpha) {
var i, n;
var count = 0;
var digitArray = [];
if (pic === null || number < 0) {
return;
}
if (number === 0) {
pic.setAlpha(120);
pic.drawParts(x, y, 0, ySrc, width, height);
return;
}
while (number > 0) {
n = Math.floor(number % 10);
number = Math.floor(number / 10);
digitArray[count] = n;
count++;
}
for (i = 0; i < count; i++) {
pic.setAlpha(alpha);
pic.drawParts(x, y, digitArray[i] * width, ySrc, width, height);
x -= width - 2;
}
}
};