From feb6a36b51e4819cdedb8e944332cedbf8dfacbc Mon Sep 17 00:00:00 2001 From: Hersi Date: Fri, 3 Dec 2021 03:28:45 +0100 Subject: [PATCH] fixed challengeresult for landscape mode --- scripts/challengeresult.lua | 52 +++++++++++++++++++++++++++++++------ 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/scripts/challengeresult.lua b/scripts/challengeresult.lua index b246413..3189ccd 100644 --- a/scripts/challengeresult.lua +++ b/scripts/challengeresult.lua @@ -5,17 +5,33 @@ local common = require('common.common'); local VolforceWindow = require("components.volforceWindow") -local resx, resy = game.GetResolution() +-- Window variables +local resX, resY + +-- Aspect Ratios +local landscapeWidescreenRatio = 16 / 9 +local landscapeStandardRatio = 4 / 3 +local portraitWidescreenRatio = 9 / 16 + +-- Portrait sizes +local fullX, fullY local desw = 1080 local desh = 1920 -local scale = 1 + +local function resolutionChange(x, y) + resX = x + resY = y + fullX = portraitWidescreenRatio * y + fullY = y +end local bgSfxPlayed = false; local BAR_ALPHA = 191; local HEADER_HEIGHT = 100 -local backgroundImage = gfx.CreateSkinImage("challenge_result/bg.png", 0); +local backgroundImage = gfx.CreateSkinImage("bg_pattern.png", gfx.IMAGE_REPEATX | gfx.IMAGE_REPEATY) +local resultBgImage = gfx.CreateSkinImage("challenge_result/bg.png", 0); local playerInfoOverlayBgImage = gfx.CreateSkinImage("challenge_result/player_info_overlay_bg.png", 0); local headerTitleImage = gfx.CreateSkinImage("challenge_result/header/title.png", 0); @@ -126,7 +142,7 @@ end function drawBackground() gfx.BeginPath() - gfx.ImageRect(0, 0, desw, desh, backgroundImage, 1, 0); + gfx.ImageRect(0, 0, desw, desh, resultBgImage, 1, 0); end function drawHeader() @@ -282,10 +298,12 @@ local IR_Handle = function() end end -function render(deltaTime) - gfx.ResetTransform(); - resetLayoutInformation(); - gfx.Scale(scale, scale); +local function drawResultScreen(x, y, w, h, deltaTime) + gfx.BeginPath() + + gfx.Translate(x, y); + gfx.Scale(w / 1080, h / 1920); + gfx.Scissor(0, 0, 1080, 1920); handleSfx() IR_Handle() @@ -302,4 +320,22 @@ function render(deltaTime) drawHeader() Footer.draw(deltaTime); + + gfx.ResetTransform() +end + +function render(deltaTime) + -- detect resolution change + local resx, resy = game.GetResolution() + if resx ~= resX or resy ~= resY then + resolutionChange(resx, resy) + end + + gfx.BeginPath() + local bgImageWidth, bgImageHeight = gfx.ImageSize(backgroundImage) + gfx.Rect(0, 0, resX, resY) + gfx.FillPaint(gfx.ImagePattern(0, 0, bgImageWidth, bgImageHeight, 0, backgroundImage, 0.2)) + gfx.Fill() + + drawResultScreen((resX - fullX) / 2, 0, fullX, fullY, deltaTime) end