From 01ea812b7f96accde7ac9ed463ced676deaf4097 Mon Sep 17 00:00:00 2001 From: FajsiEx Date: Thu, 25 Nov 2021 19:02:21 +0100 Subject: [PATCH] + score panel landscape support --- scripts/gameplay/score_panel.lua | 34 +++++++++++++++++++------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/scripts/gameplay/score_panel.lua b/scripts/gameplay/score_panel.lua index 7c4da87..b52f6fa 100644 --- a/scripts/gameplay/score_panel.lua +++ b/scripts/gameplay/score_panel.lua @@ -4,6 +4,8 @@ local bgImage = gfx.CreateSkinImage("gameplay/score_panel/bg.png", 0) local desw = 1080; local desh = 1920; +local isLandscape = false; + function load_number_image(path) local images = {} for i = 0, 9 do @@ -40,15 +42,26 @@ local tickTransitions = function (deltaTime) end local render = function (deltaTime, score, maxChain) - tickTransitions(deltaTime) gfx.Save(); + + local resx, resy = game.GetResolution(); + isLandscape = resx > resy; - local x = desw - 740*0.61; -- WHY IS THERE DIFFERENT SCALING FOR THIS TOO???? - local y = 330; + tickTransitions(deltaTime) + + local x = desw; + local y = isLandscape and 0 or 330; + + if (isLandscape) then + gfx.Translate(x, 0); + x=0 + + gfx.Scale(0.7, 0.7); + end gfx.BeginPath(); gfx.ImageRect( - x, + x-740*0.61, -- WHY IS THERE DIFFERENT SCALING FOR THIS TOO???? y, 740*0.61, 320*0.61, @@ -57,24 +70,17 @@ local render = function (deltaTime, score, maxChain) 0 ); - draw_number(x+142, y + 83, 1.0, score/10000, 4, scoreNumbers, true, 0.38, 1.12) - draw_number(x+338, y + 90, 1.0, score, 4, scoreNumbers, true, 0.28, 1.12) + draw_number(x-309.4, y + 83, 1.0, score/10000, 4, scoreNumbers, true, 0.38, 1.12) + draw_number(x-113.4, y + 90, 1.0, score, 4, scoreNumbers, true, 0.28, 1.12) -- Draw max chain gfx.BeginPath(); gfx.LoadSkinFont('Digital-Serial-Bold.ttf') gfx.TextAlign(gfx.TEXT_ALIGN_RIGHT + gfx.TEXT_ALIGN_MIDDLE) gfx.FontSize(30); - - - -- gfx.FillColor(0,0,0,255); - -- gfx.Text(string.format("%04d", maxChain), x+170-2, y+155-2); - -- gfx.Text(string.format("%04d", maxChain), x+170-2, y+155+2); - -- gfx.Text(string.format("%04d", maxChain), x+170+2, y+155-2); - -- gfx.Text(string.format("%04d", maxChain), x+170+2, y+155+2); gfx.FillColor(255,255,255,255); - gfx.Text(string.format("%04d", maxChain), x+170, y+155); + gfx.Text(string.format("%04d", maxChain), x-281.4, y+155); gfx.Restore(); end