From 056d3ac5a78626c6a09b34ea55a761d9013d03a7 Mon Sep 17 00:00:00 2001 From: meehl <12648828+meehl@users.noreply.github.com> Date: Tue, 2 Dec 2025 21:05:44 +0100 Subject: [PATCH 1/2] Add missing screen size conversions `GetScreenSize` returns the size in physical units if the "DPI_AWARE" flag is passed to `RenderInit`. The error popup and restart screen have the wrong position and size at UI scaling factor != 1.0 due to missing conversions to virtual units. This introduces a utility function for getting the virtual screen size and uses it to add the missing conversions. --- src/Launch.lua | 4 ++-- src/Modules/Common.lua | 11 +++++++++++ src/Modules/Main.lua | 7 +------ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/Launch.lua b/src/Launch.lua index e30750ee7c..2e383f8c96 100644 --- a/src/Launch.lua +++ b/src/Launch.lua @@ -122,7 +122,7 @@ function launch:OnFrame() self:DrawPopup(r, g, b, "^0%s", self.promptMsg) end if self.doRestart then - local screenW, screenH = GetScreenSize() + local screenW, screenH = GetVirtualScreenSize() SetDrawColor(0, 0, 0, 0.75) DrawImage(nil, 0, 0, screenW, screenH) SetDrawColor(1, 1, 1) @@ -387,7 +387,7 @@ function launch:RunPromptFunc(key) end function launch:DrawPopup(r, g, b, fmt, ...) - local screenW, screenH = GetScreenSize() + local screenW, screenH = GetVirtualScreenSize() SetDrawColor(0, 0, 0, 0.5) DrawImage(nil, 0, 0, screenW, screenH) local txt = string.format(fmt, ...) diff --git a/src/Modules/Common.lua b/src/Modules/Common.lua index 3d19d4c799..ac32512910 100644 --- a/src/Modules/Common.lua +++ b/src/Modules/Common.lua @@ -963,3 +963,14 @@ function ImportBuild(importLink, callback) callback(Inflate(common.base64.decode(importLink:gsub("-", "+"):gsub("_", "/"))), nil) end end + +-- Returns virtual screen size +function GetVirtualScreenSize() + local width, height = GetScreenSize() + local scale = GetScreenScale and GetScreenScale() or 1.0 + if scale ~= 1.0 then + width = math.floor(width / scale) + height = math.floor(height / scale) + end + return width, height +end diff --git a/src/Modules/Main.lua b/src/Modules/Main.lua index 7360bca91f..c329acc5ec 100644 --- a/src/Modules/Main.lua +++ b/src/Modules/Main.lua @@ -339,12 +339,7 @@ function main:Shutdown() end function main:OnFrame() - self.screenW, self.screenH = GetScreenSize() - self.screenScale = GetScreenScale and GetScreenScale() or 1 - if self.screenScale ~= 1.0 then - self.screenW = math.floor(self.screenW / self.screenScale) - self.screenH = math.floor(self.screenH / self.screenScale) - end + self.screenW, self.screenH = GetVirtualScreenSize() if self.screenH > self.screenW then self.portraitMode = true From 9cf781f08b4325406a8b61f0d16d3ffd64943a2d Mon Sep 17 00:00:00 2001 From: Jack Lockwood Date: Thu, 29 Jan 2026 01:16:58 +1100 Subject: [PATCH 2/2] Update export scripts --- src/Export/Launch.lua | 4 ++-- src/Export/Main.lua | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Export/Launch.lua b/src/Export/Launch.lua index 7a3496e08f..47878cc401 100644 --- a/src/Export/Launch.lua +++ b/src/Export/Launch.lua @@ -67,7 +67,7 @@ function launch:OnFrame() self:DrawPopup(r, g, b, "^0%s", self.promptMsg) end if self.doRestart then - local screenW, screenH = GetScreenSize() + local screenW, screenH = GetVirtualScreenSize() SetDrawColor(0, 0, 0, 0.75) DrawImage(nil, 0, 0, screenW, screenH) SetDrawColor(1, 1, 1) @@ -180,7 +180,7 @@ function launch:RunPromptFunc(key) end function launch:DrawPopup(r, g, b, fmt, ...) - local screenW, screenH = GetScreenSize() + local screenW, screenH = GetVirtualScreenSize() SetDrawColor(0, 0, 0, 0.5) DrawImage(nil, 0, 0, screenW, screenH) local txt = string.format(fmt, ...) diff --git a/src/Export/Main.lua b/src/Export/Main.lua index b99172ac07..fb90cb0567 100644 --- a/src/Export/Main.lua +++ b/src/Export/Main.lua @@ -415,7 +415,7 @@ function main:Shutdown() end function main:OnFrame() - self.screenW, self.screenH = GetScreenSize() + self.screenW, self.screenH = GetVirtualScreenSize() self.viewPort = { x = 0, y = 0, width = self.screenW, height = self.screenH }