From fbe94a1414a68c33187b0506544e611c02c62a1c Mon Sep 17 00:00:00 2001 From: FajsiEx Date: Mon, 26 Jul 2021 17:10:50 +0200 Subject: [PATCH] * properly scale gauges --- scripts/gameplay.lua | 50 ++++++++++++++++++++------------------------ 1 file changed, 23 insertions(+), 27 deletions(-) diff --git a/scripts/gameplay.lua b/scripts/gameplay.lua index 70ea586..05ead4c 100644 --- a/scripts/gameplay.lua +++ b/scripts/gameplay.lua @@ -709,16 +709,6 @@ local gaugeExcArsFillImage = gfx.CreateSkinImage("gameplay/gauges/excessive_ars/ function draw_gauge(deltaTime) - - local width = 82 * scale / 1 - local height = 702 * scale / 1 - local posx = resx - width - local posy = resy / 2 - height / 2 + 60 - if portrait then - posx = resx - width - posy = posy - 90 - end - -- fallbacks in case of unsupported type local gaugeBgImage = gaugeEffBgImage; local gaugeFillImage = gaugeEffPassFillImage; @@ -738,30 +728,36 @@ function draw_gauge(deltaTime) end - local tw, th = gfx.ImageSize(gaugeBgImage) - gfx.ImageRect(posx, posy, tw, th, gaugeBgImage, 1, 0) - gfx.ImageRect(posx+22, posy+11+(629-(629*(gameplay.gauge.value))), 23, 629*(gameplay.gauge.value), gaugeFillImage, 1, 0) + local BgW, BgH = gfx.ImageSize(gaugeBgImage); + local FillW, FillH = gfx.ImageSize(gaugeFillImage); + local gaugePosX = 1080 - BgW - 48; + local gaugePosY = 1920/2 - BgH/2 - 32; + + -- gfx.Text('RESX: ' .. resx .. ' // RESY: ' .. resy .. ' // GPX: ' .. gaugePosX, 255,1200); + + gfx.ImageRect(gaugePosX, gaugePosY, BgW, BgH, gaugeBgImage, 1, 0) + gfx.ImageRect(gaugePosX+22, gaugePosY+11+(FillH-(FillH*(gameplay.gauge.value))), FillW, FillH*(gameplay.gauge.value), gaugeFillImage, 1, 0) - --draw gauge % label - posx = posx / scale - posx = posx + (-20 * 0.5) - -- 630 = 0% position - height = 960 * 0.5 - posy = posy / scale + -- --draw gauge % label + -- posx = posx / scale + -- posx = posx + (-20 * 0.5) + -- -- 630 = 0% position + -- height = 960 * 0.5 + -- posy = posy / scale - tw, th = gfx.ImageSize(gaugeNumBack) + -- tw, th = gfx.ImageSize(gaugeNumBack) -- 80 = 100% position - posy = posy + (95 * 0.5) + height - height * gameplay.gauge.value - -- Draw the background - gfx.BeginPath() - gfx.FillColor(255, 255, 255) - gfx.ImageRect(posx - 44, posy - 10, tw, th, gaugeNumBack, 1, 0) + -- posy = posy + (95 * 0.5) + height - height * gameplay.gauge.value + -- -- Draw the background + -- gfx.BeginPath() + -- gfx.FillColor(255, 255, 255) + -- gfx.ImageRect(posx - 44, posy - 10, tw, th, gaugeNumBack, 1, 0) - gfx.BeginPath() + -- gfx.BeginPath() -- gfx.FillColor(250, 228, 112) - draw_number(posx - 24, posy + 4, 1.0, math.floor(gameplay.gauge.value * 100), 3, numberImages, true) + -- draw_number(posx - 24, posy + 4, 1.0, math.floor(gameplay.gauge.value * 100), 3, numberImages, true) -- gfx.TextAlign(gfx.TEXT_ALIGN_RIGHT + gfx.TEXT_ALIGN_MIDDLE) -- gfx.FontSize(18) -- gfx.Text(string.format("%d", math.floor(gameplay.gauge.value * 100)), posx, posy + 4)