138 lines
4.5 KiB
Plaintext
138 lines
4.5 KiB
Plaintext
/*
|
|
文件名:FixItemCout.nut
|
|
路径:Project/FixItemCout/FixItemCout.nut
|
|
创建日期:2026-01-14 16:58
|
|
文件用途:
|
|
*/
|
|
|
|
class FixItemCoutC {
|
|
|
|
Img = Rindro_Image("common/smallnumber.img");
|
|
Img2 = Rindro_Image("interface/digit/small_stroke_white.img");
|
|
|
|
LengthList = [6, 4, 6, 6, 6, 6, 6, 6, 6, 6, 3, 8, 7];
|
|
SmallLengthList = [5, 4, 5, 5, 5, 5, 5, 5, 5, 5];
|
|
|
|
constructor() {
|
|
_FixItemCount_();
|
|
}
|
|
|
|
function Logic(X, Y, Count) {
|
|
if (Count > 1) {
|
|
local Suf = -1;
|
|
if (Count > 9999) {
|
|
Count = Count / 10000.0;
|
|
Suf = 12;
|
|
|
|
local Str = Count.tostring();
|
|
if (typeof Count == "float") Str = format("%.1f", Count);
|
|
local Length = 0;
|
|
local DrawList = [];
|
|
for (local i = 0; i< Str.len(); i++) {
|
|
local char = Str.slice(i, i + 1);
|
|
local Width = 0;
|
|
if (char == ".") {
|
|
Width = 3;
|
|
DrawList.append({
|
|
index = 10,
|
|
width = Width
|
|
|
|
})
|
|
} else {
|
|
local Index = char.tointeger();
|
|
Width = LengthList[Index];
|
|
DrawList.append({
|
|
index = Index,
|
|
width = Width
|
|
})
|
|
}
|
|
Length += Width;
|
|
}
|
|
if (Suf != -1) {
|
|
DrawList.append({
|
|
index = Suf,
|
|
width = LengthList[Suf]
|
|
})
|
|
Length += LengthList[Suf];
|
|
}
|
|
|
|
local DrawOffset = 0;
|
|
foreach(index, info in DrawList) {
|
|
local offset = 0;
|
|
if (index != 0) {
|
|
offset = DrawList[index - 1].width + DrawOffset
|
|
}
|
|
Img.DrawPng(info.index, X - Length + offset, Y + (info.index == 10 ? 7 : 0) + (info.index == 12 ? -1 : 0));
|
|
DrawOffset = offset;
|
|
}
|
|
} else if (Count > 999 && Count <= 9999) {
|
|
local Str = Count.tostring();
|
|
local Length = 0;
|
|
local DrawList = [];
|
|
for (local i = 0; i< Str.len(); i++) {
|
|
local char = Str.slice(i, i + 1);
|
|
local Index = char.tointeger();
|
|
DrawList.append({
|
|
index = Index,
|
|
width = SmallLengthList[Index]
|
|
});
|
|
Length += SmallLengthList[Index];
|
|
}
|
|
|
|
local DrawOffset = 0;
|
|
foreach(index, info in DrawList) {
|
|
local offset = 0;
|
|
if (index != 0) {
|
|
offset = DrawList[index - 1].width + DrawOffset
|
|
}
|
|
Img2.DrawPng(info.index, X - 1 - Length + offset, Y);
|
|
DrawOffset = offset;
|
|
}
|
|
} else if (Count <= 999) {
|
|
local Str = Count.tostring();
|
|
local Length = 0;
|
|
local DrawList = [];
|
|
for (local i = 0; i< Str.len(); i++) {
|
|
local char = Str.slice(i, i + 1);
|
|
local Index = char.tointeger();
|
|
DrawList.append({
|
|
index = Index,
|
|
width = LengthList[Index]
|
|
});
|
|
Length += LengthList[Index];
|
|
}
|
|
|
|
|
|
local DrawOffset = 0;
|
|
foreach(index, info in DrawList) {
|
|
local offset = 0;
|
|
if (index != 0) {
|
|
offset = DrawList[index - 1].width + DrawOffset
|
|
}
|
|
Img.DrawPng(info.index, X - 1 - Length + offset, Y);
|
|
DrawOffset = offset;
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
getroottable().rawdelete("FixItemCout_Obj");
|
|
|
|
function Lenheart_FixItemCout_Fun(obj) {
|
|
local RootTab = getroottable();
|
|
if (!RootTab.rawin("FixItemCout_Obj")) {
|
|
RootTab.rawset("FixItemCout_Obj", FixItemCoutC());
|
|
}
|
|
}
|
|
|
|
function Sq_FixItemCount(X, Y, Count) {
|
|
local RootTab = getroottable();
|
|
if (RootTab.rawin("FixItemCout_Obj")) {
|
|
RootTab["FixItemCout_Obj"].Logic(X, Y, Count);
|
|
}
|
|
}
|
|
|
|
getroottable()["LenheartFuncTab"].rawset("FixItemCoutFuncN", Lenheart_FixItemCout_Fun); |