fixed challengeresult for landscape mode

This commit is contained in:
Hersi 2021-12-03 03:28:45 +01:00
parent ee3d8ce3f0
commit feb6a36b51
1 changed files with 44 additions and 8 deletions

View File

@ -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