2022-06-24 22:09:19 +02:00
|
|
|
local vfBrackets = {0, 10, 12, 14, 15, 16, 17, 18, 19, 20, 24}
|
2021-08-12 21:21:42 +02:00
|
|
|
|
2022-06-24 22:09:19 +02:00
|
|
|
local stNum = 1
|
2021-08-12 21:21:42 +02:00
|
|
|
|
2022-06-24 22:09:19 +02:00
|
|
|
if not volforceAmount then
|
|
|
|
volforceAmount = -1
|
|
|
|
end
|
2021-08-12 21:21:42 +02:00
|
|
|
|
2022-06-24 22:09:19 +02:00
|
|
|
local function handleForce(vf)
|
|
|
|
volforceAmount = vf
|
|
|
|
for i = 1, 10 do
|
|
|
|
local top = vfBrackets[i+1]
|
|
|
|
local down = vfBrackets[i]
|
|
|
|
if vf < top or i == 10 then
|
|
|
|
vfNum = i
|
|
|
|
local range = top - down
|
|
|
|
for b = 1, 4 do
|
|
|
|
if vf < (down + b*0.25*range) or b == 4 then
|
|
|
|
starsCount = b
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
break
|
|
|
|
end
|
|
|
|
if i > 7 then
|
|
|
|
stNum = 2
|
|
|
|
else
|
|
|
|
stNum = 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
handleForce(volforceAmount)
|
2021-08-12 21:21:42 +02:00
|
|
|
|
2022-06-24 22:09:19 +02:00
|
|
|
volforceBadgeImage = gfx.CreateSkinImage("volforce/"..vfNum..".png",1)
|
|
|
|
vfStar = gfx.CreateSkinImage("volforce/stars/"..stNum..".png",1)
|
2021-08-12 21:21:42 +02:00
|
|
|
|
2022-06-24 22:09:19 +02:00
|
|
|
function render(deltatime, x, y,size,iftxt,amount)
|
|
|
|
|
|
|
|
volforceAmount = amount
|
|
|
|
|
|
|
|
gfx.LoadSkinFont('Digital-Serial-Bold.ttf')
|
|
|
|
gfx.TextAlign(gfx.TEXT_ALIGN_LEFT + gfx.TEXT_ALIGN_MIDDLE)
|
2021-08-12 21:21:42 +02:00
|
|
|
-- Draw volforce badge
|
|
|
|
gfx.BeginPath();
|
2022-06-24 22:09:19 +02:00
|
|
|
gfx.ImageRect(x-8, y-16, size*1.5, size*1.5, volforceBadgeImage, 1, 0);
|
|
|
|
if iftxt == true then
|
|
|
|
for i = 1, starsCount do
|
|
|
|
divider = 0
|
|
|
|
if starsCount == 1 then
|
|
|
|
divider = 18
|
|
|
|
gfx.BeginPath();
|
|
|
|
gfx.ImageRect(x+divider+(i-1)*divider, y+32.5, size/4, size/4, vfStar, 1, 0);
|
|
|
|
elseif starsCount == 2 then
|
|
|
|
divider = 13
|
|
|
|
gfx.BeginPath();
|
|
|
|
gfx.ImageRect(x+divider+(i-1)*(divider-2), y+32.5, size/4, size/4, vfStar, 1, 0);
|
|
|
|
elseif starsCount == 3 then
|
|
|
|
divider = 8.25
|
|
|
|
gfx.BeginPath();
|
|
|
|
gfx.ImageRect(x+divider+(i-1)*(divider+2), y+32.5, size/4, size/4, vfStar, 1, 0);
|
|
|
|
elseif starsCount == 4 then
|
|
|
|
divider = 5
|
|
|
|
gfx.BeginPath();
|
|
|
|
gfx.ImageRect(x+(divider-1)+(i-1)*(divider+5), y+32.5, size/4, size/4, vfStar, 1, 0);
|
|
|
|
end
|
|
|
|
end
|
2021-08-12 21:21:42 +02:00
|
|
|
-- Draw volforce label
|
|
|
|
gfx.FontSize(11)
|
|
|
|
gfx.Text('VOLFORCE', x + 47, y + 14);
|
|
|
|
gfx.FontSize(18)
|
2022-06-24 22:09:19 +02:00
|
|
|
gfx.Text(string.format('%.3f', amount), x + 47, y + 30);
|
|
|
|
end
|
2021-08-12 21:21:42 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
return {
|
|
|
|
render = render
|
|
|
|
}
|