+ decimal gauge to gameplay

This commit is contained in:
FajsiEx 2021-11-22 22:52:48 +01:00
parent 543bf7b447
commit 30aefdde0a
1 changed files with 45 additions and 4 deletions

View File

@ -105,12 +105,53 @@ local render = function (deltaTime, gaugeType, gaugeValue, isArsEnabled)
gfx.BeginPath()
gfx.FillColor(255, 255, 255)
gfx.LoadSkinFont("Digital-Serial-Bold.ttf")
gfx.FontSize(22)
gfx.TextAlign(gfx.TEXT_ALIGN_RIGHT + gfx.TEXT_ALIGN_MIDDLE)
gfx.Text(math.floor(gaugeValue * 100), gaugePosX-16, gaugeMarkerY+17)
-- The big number
local gaugePercent = gaugeValue * 100;
local bigNumber = 0;
local smallNumber = 0;
local smallNumberX = gaugePosX-38;
if (gaugePercent < 10) then
bigNumber = math.floor(gaugePercent) .. '.';
local decimalPortion = math.floor(
(
gaugePercent -
math.floor(gaugePercent)
) * 100
);
smallNumber = string.format('%02d', decimalPortion);
smallNumberX = gaugePosX-38;
elseif (gaugePercent < 100) then
bigNumber = math.floor(gaugePercent) .. '.';
local decimalPortion = math.floor(
(
gaugePercent -
math.floor(gaugePercent)
) * 10
);
smallNumber = decimalPortion;
smallNumberX = gaugePosX-26;
else
bigNumber = '100';
smallNumber = 0;
smallNumberX = -100; -- yeet it out of existance
end
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_MIDDLE)
-- big text
gfx.FontSize(22)
gfx.Text(bigNumber, gaugePosX-56, gaugeMarkerY+16.5)
-- small text
gfx.FontSize(18)
gfx.Text(smallNumber, smallNumberX, gaugeMarkerY+17.5)
-- %
gfx.FontSize(16)
gfx.Text('%', gaugePosX-4, gaugeMarkerY+17)
gfx.Text('%', gaugePosX-15, gaugeMarkerY+16.5)
end
return {