From 53ff5413cda11d15ec412a103c0472b29063702c Mon Sep 17 00:00:00 2001 From: Dean Lee Date: Fri, 24 Oct 2025 23:50:32 +0800 Subject: [PATCH] ui: auto-size on PC if screen is smaller than tici (#36452) auto-scale on PC to fit screen --- system/ui/lib/application.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/system/ui/lib/application.py b/system/ui/lib/application.py index 68e1fdc44a..4ed59f1942 100644 --- a/system/ui/lib/application.py +++ b/system/ui/lib/application.py @@ -140,7 +140,12 @@ class GuiApplication: self._fonts: dict[FontWeight, rl.Font] = {} self._width = width self._height = height - self._scale = SCALE + + if PC and SCALE == 1.0: + self._scale = self._calculate_auto_scale() + else: + self._scale = SCALE + self._scaled_width = int(self._width * self._scale) self._scaled_height = int(self._height * self._scale) self._render_texture: rl.RenderTexture | None = None @@ -460,5 +465,17 @@ class GuiApplication: cloudlog.error(f"FPS dropped critically below {fps}. Shutting down UI.") os._exit(1) + def _calculate_auto_scale(self) -> float: + # Create temporary window to query monitor info + rl.init_window(1, 1, "") + w, h = rl.get_monitor_width(0), rl.get_monitor_height(0) + rl.close_window() + + if w == 0 or h == 0 or (w >= self._width and h >= self._height): + return 1.0 + + # Apply 0.95 factor for window decorations/taskbar margin + return max(0.3, min(w / self._width, h / self._height) * 0.95) + gui_app = GuiApplication(2160, 1080)