From be66b411b0843e008b689dd97b0a9022842f5c60 Mon Sep 17 00:00:00 2001 From: = Date: Thu, 19 Jun 2025 23:03:38 -0400 Subject: [PATCH] UWP: Use MarbleGame.instance.scene2d Prevents offset/extent corruption in 2d menus --- src/Main.hx | 5 +++++ src/Settings.hx | 5 +++++ src/gui/AboutMenuOptionsGui.hx | 2 +- src/gui/AchievementsGui.hx | 2 +- src/gui/CreateMatchGui.hx | 2 +- src/gui/DifficultySelectGui.hx | 2 +- src/gui/EndGameGui.hx | 2 +- src/gui/ExitGameDlg.hx | 2 +- src/gui/GuiControl.hx | 2 +- src/gui/HelpCreditsGui.hx | 2 +- src/gui/InputOptionsGui.hx | 2 +- src/gui/JoinServerGui.hx | 2 +- src/gui/KeyBindingsGui.hx | 2 +- src/gui/LeaderboardsGui.hx | 2 +- src/gui/LevelSelectGui.hx | 2 +- src/gui/MPServerListGui.hx | 2 +- src/gui/MainMenuGui.hx | 2 +- src/gui/MarblePickerGui.hx | 2 +- src/gui/MiscOptionsGui.hx | 2 +- src/gui/MultiplayerGui.hx | 2 +- src/gui/MultiplayerLevelSelectGui.hx | 2 +- src/gui/MultiplayerLoadingGui.hx | 2 +- src/gui/OptionsListGui.hx | 2 +- src/gui/PlayGui.hx | 10 +++++----- src/gui/ReplayCenterGui.hx | 2 +- src/gui/TouchCtrlsEditGui.hx | 2 +- src/gui/TouchOptionsGui.hx | 2 +- src/gui/VersionGui.hx | 2 +- src/gui/VideoOptionsGui.hx | 2 +- 29 files changed, 41 insertions(+), 31 deletions(-) diff --git a/src/Main.hx b/src/Main.hx index 304447ec..6b4c6968 100644 --- a/src/Main.hx +++ b/src/Main.hx @@ -79,6 +79,11 @@ class Main extends hxd.App { + ")"); #end + #if uwp + Settings.zoomRatio = Window.getInstance().height / 1200; + s2d.scaleMode = Zoom(Settings.zoomRatio); + #end + #if android Window.getInstance().addEventTarget(ev -> { if (ev.kind == EPush || ev.kind == ERelease || ev.kind == EMove) { diff --git a/src/Settings.hx b/src/Settings.hx index 05855d18..e1b94fff 100644 --- a/src/Settings.hx +++ b/src/Settings.hx @@ -570,6 +570,11 @@ class Settings { canvasElement.style.height = "100%"; #end + #if uwp + zoomRatio = Window.getInstance().height / 1200; + Settings.zoomRatio = zoomRatio; + #end + Console.log("Window resized to " + Settings.optionsSettings.screenWidth + "x" + Settings.optionsSettings.screenHeight + " (Zoom " + zoomRatio + ")"); diff --git a/src/gui/AboutMenuOptionsGui.hx b/src/gui/AboutMenuOptionsGui.hx index 97b0fe84..84f0659b 100644 --- a/src/gui/AboutMenuOptionsGui.hx +++ b/src/gui/AboutMenuOptionsGui.hx @@ -27,7 +27,7 @@ class AboutMenuOptionsGui extends GuiImage { #if hl var scene2d = hxd.Window.getInstance(); #end - #if js + #if (js || uwp) var scene2d = MarbleGame.instance.scene2d; #end diff --git a/src/gui/AchievementsGui.hx b/src/gui/AchievementsGui.hx index 7a4b26f1..18f5df5e 100644 --- a/src/gui/AchievementsGui.hx +++ b/src/gui/AchievementsGui.hx @@ -29,7 +29,7 @@ class AchievementsGui extends GuiImage { #if hl var scene2d = hxd.Window.getInstance(); #end - #if js + #if (js || uwp) var scene2d = MarbleGame.instance.scene2d; #end diff --git a/src/gui/CreateMatchGui.hx b/src/gui/CreateMatchGui.hx index 7f8b2fe1..cd8aa224 100644 --- a/src/gui/CreateMatchGui.hx +++ b/src/gui/CreateMatchGui.hx @@ -27,7 +27,7 @@ class CreateMatchGui extends GuiImage { #if hl var scene2d = hxd.Window.getInstance(); #end - #if js + #if (js || uwp) var scene2d = MarbleGame.instance.scene2d; #end diff --git a/src/gui/DifficultySelectGui.hx b/src/gui/DifficultySelectGui.hx index b83831db..f8eed38e 100644 --- a/src/gui/DifficultySelectGui.hx +++ b/src/gui/DifficultySelectGui.hx @@ -28,7 +28,7 @@ class DifficultySelectGui extends GuiImage { #if hl var scene2d = hxd.Window.getInstance(); #end - #if js + #if (js || uwp) var scene2d = MarbleGame.instance.scene2d; #end diff --git a/src/gui/EndGameGui.hx b/src/gui/EndGameGui.hx index f9dedb00..934db6c1 100644 --- a/src/gui/EndGameGui.hx +++ b/src/gui/EndGameGui.hx @@ -50,7 +50,7 @@ class EndGameGui extends GuiImage { #if hl var scene2d = hxd.Window.getInstance(); #end - #if js + #if (js || uwp) var scene2d = MarbleGame.instance.scene2d; #end diff --git a/src/gui/ExitGameDlg.hx b/src/gui/ExitGameDlg.hx index a5297019..fa9f14d4 100644 --- a/src/gui/ExitGameDlg.hx +++ b/src/gui/ExitGameDlg.hx @@ -34,7 +34,7 @@ class ExitGameDlg extends GuiImage { #if hl var scene2d = hxd.Window.getInstance(); #end - #if js + #if (js || uwp) var scene2d = MarbleGame.instance.scene2d; #end diff --git a/src/gui/GuiControl.hx b/src/gui/GuiControl.hx index 8f59824c..446b55f3 100644 --- a/src/gui/GuiControl.hx +++ b/src/gui/GuiControl.hx @@ -204,7 +204,7 @@ class GuiControl { } var scaleFactor = 1.0 / Window.getInstance().windowToPixelRatio; - #if (js || android) + #if (js || android || uwp) scaleFactor = 1 / Settings.zoomRatio; // 768 / js.Browser.window.innerHeight * js.Browser.window.devicePixelRatio; // 0.5; // 768 / js.Browser.window.innerHeight; // js.Browser.window.innerHeight * js.Browser.window.devicePixelRatio / 768; #end diff --git a/src/gui/HelpCreditsGui.hx b/src/gui/HelpCreditsGui.hx index 77c26137..e2a6e24d 100644 --- a/src/gui/HelpCreditsGui.hx +++ b/src/gui/HelpCreditsGui.hx @@ -36,7 +36,7 @@ class HelpCreditsGui extends GuiImage { #if hl var scene2d = hxd.Window.getInstance(); #end - #if js + #if (js || uwp) var scene2d = MarbleGame.instance.scene2d; #end diff --git a/src/gui/InputOptionsGui.hx b/src/gui/InputOptionsGui.hx index 90e8dbc8..e63f7901 100644 --- a/src/gui/InputOptionsGui.hx +++ b/src/gui/InputOptionsGui.hx @@ -27,7 +27,7 @@ class InputOptionsGui extends GuiImage { #if hl var scene2d = hxd.Window.getInstance(); #end - #if js + #if (js || uwp) var scene2d = MarbleGame.instance.scene2d; #end diff --git a/src/gui/JoinServerGui.hx b/src/gui/JoinServerGui.hx index 98014679..73d0145b 100644 --- a/src/gui/JoinServerGui.hx +++ b/src/gui/JoinServerGui.hx @@ -27,7 +27,7 @@ class JoinServerGui extends GuiImage { #if hl var scene2d = hxd.Window.getInstance(); #end - #if js + #if (js || uwp) var scene2d = MarbleGame.instance.scene2d; #end diff --git a/src/gui/KeyBindingsGui.hx b/src/gui/KeyBindingsGui.hx index a97e9713..dfaeab2f 100644 --- a/src/gui/KeyBindingsGui.hx +++ b/src/gui/KeyBindingsGui.hx @@ -89,7 +89,7 @@ class KeyBindingsGui extends GuiImage { #if hl var scene2d = hxd.Window.getInstance(); #end - #if js + #if (js || uwp) var scene2d = MarbleGame.instance.scene2d; #end diff --git a/src/gui/LeaderboardsGui.hx b/src/gui/LeaderboardsGui.hx index 3a0d8a35..08f9238e 100644 --- a/src/gui/LeaderboardsGui.hx +++ b/src/gui/LeaderboardsGui.hx @@ -33,7 +33,7 @@ class LeaderboardsGui extends GuiImage { #if hl var scene2d = hxd.Window.getInstance(); #end - #if js + #if (js || uwp) var scene2d = MarbleGame.instance.scene2d; #end diff --git a/src/gui/LevelSelectGui.hx b/src/gui/LevelSelectGui.hx index 65c60c8e..a32f6310 100644 --- a/src/gui/LevelSelectGui.hx +++ b/src/gui/LevelSelectGui.hx @@ -102,7 +102,7 @@ class LevelSelectGui extends GuiImage { #if hl var scene2d = hxd.Window.getInstance(); #end - #if js + #if (js || uwp) var scene2d = MarbleGame.instance.scene2d; #end diff --git a/src/gui/MPServerListGui.hx b/src/gui/MPServerListGui.hx index 1b61b52a..492a3ede 100644 --- a/src/gui/MPServerListGui.hx +++ b/src/gui/MPServerListGui.hx @@ -33,7 +33,7 @@ class MPServerListGui extends GuiImage { #if hl var scene2d = hxd.Window.getInstance(); #end - #if js + #if (js || uwp) var scene2d = MarbleGame.instance.scene2d; #end diff --git a/src/gui/MainMenuGui.hx b/src/gui/MainMenuGui.hx index 70e1cfc7..d44729e2 100644 --- a/src/gui/MainMenuGui.hx +++ b/src/gui/MainMenuGui.hx @@ -33,7 +33,7 @@ class MainMenuGui extends GuiImage { #if hl var scene2d = hxd.Window.getInstance(); #end - #if js + #if (js || uwp) var scene2d = MarbleGame.instance.scene2d; #end diff --git a/src/gui/MarblePickerGui.hx b/src/gui/MarblePickerGui.hx index 4408e2ab..3bb8033c 100644 --- a/src/gui/MarblePickerGui.hx +++ b/src/gui/MarblePickerGui.hx @@ -248,7 +248,7 @@ class MarblePickerGui extends GuiImage { #if hl var scene2d = hxd.Window.getInstance(); #end - #if js + #if (js || uwp) var scene2d = MarbleGame.instance.scene2d; #end diff --git a/src/gui/MiscOptionsGui.hx b/src/gui/MiscOptionsGui.hx index 06352b16..b8d198fd 100644 --- a/src/gui/MiscOptionsGui.hx +++ b/src/gui/MiscOptionsGui.hx @@ -26,7 +26,7 @@ class MiscOptionsGui extends GuiImage { #if hl var scene2d = hxd.Window.getInstance(); #end - #if js + #if (js || uwp) var scene2d = MarbleGame.instance.scene2d; #end diff --git a/src/gui/MultiplayerGui.hx b/src/gui/MultiplayerGui.hx index 1361e68d..1d6fb155 100644 --- a/src/gui/MultiplayerGui.hx +++ b/src/gui/MultiplayerGui.hx @@ -28,7 +28,7 @@ class MultiplayerGui extends GuiImage { #if hl var scene2d = hxd.Window.getInstance(); #end - #if js + #if (js || uwp) var scene2d = MarbleGame.instance.scene2d; #end diff --git a/src/gui/MultiplayerLevelSelectGui.hx b/src/gui/MultiplayerLevelSelectGui.hx index a4dee1dd..7e7560b1 100644 --- a/src/gui/MultiplayerLevelSelectGui.hx +++ b/src/gui/MultiplayerLevelSelectGui.hx @@ -120,7 +120,7 @@ class MultiplayerLevelSelectGui extends GuiImage { #if hl var scene2d = hxd.Window.getInstance(); #end - #if js + #if (js || uwp) var scene2d = MarbleGame.instance.scene2d; #end diff --git a/src/gui/MultiplayerLoadingGui.hx b/src/gui/MultiplayerLoadingGui.hx index 78af3e2d..4714ee76 100644 --- a/src/gui/MultiplayerLoadingGui.hx +++ b/src/gui/MultiplayerLoadingGui.hx @@ -65,7 +65,7 @@ class MultiplayerLoadingGui extends GuiImage { #if hl var scene2d = hxd.Window.getInstance(); #end - #if js + #if (js || uwp) var scene2d = MarbleGame.instance.scene2d; #end diff --git a/src/gui/OptionsListGui.hx b/src/gui/OptionsListGui.hx index c507a493..4678d91a 100644 --- a/src/gui/OptionsListGui.hx +++ b/src/gui/OptionsListGui.hx @@ -26,7 +26,7 @@ class OptionsListGui extends GuiImage { #if hl var scene2d = hxd.Window.getInstance(); #end - #if js + #if (js || uwp) var scene2d = MarbleGame.instance.scene2d; #end diff --git a/src/gui/PlayGui.hx b/src/gui/PlayGui.hx index 25f0be09..c954d375 100644 --- a/src/gui/PlayGui.hx +++ b/src/gui/PlayGui.hx @@ -156,7 +156,7 @@ class PlayGui { #if hl var wnd = hxd.Window.getInstance(); #end - #if js + #if (js || uwp) var wnd = MarbleGame.instance.scene2d; #end @@ -236,7 +236,7 @@ class PlayGui { #if hl var scene2d = hxd.Window.getInstance(); #end - #if js + #if (js || uwp) var scene2d = MarbleGame.instance.scene2d; #end var safeVerMargin = 1 + (scene2d.height * 0.15) / 2; @@ -347,7 +347,7 @@ class PlayGui { #if hl var scene2d = hxd.Window.getInstance(); #end - #if js + #if (js || uwp) var scene2d = MarbleGame.instance.scene2d; #end var safeVerMargin = 1 + (scene2d.height * 0.15) / 2; @@ -439,7 +439,7 @@ class PlayGui { #if hl var scene2d = hxd.Window.getInstance(); #end - #if js + #if (js || uwp) var scene2d = MarbleGame.instance.scene2d; #end var safeVerMargin = 1 + (scene2d.height * 0.15) / 2; @@ -596,7 +596,7 @@ class PlayGui { #if hl var scene2d = hxd.Window.getInstance(); #end - #if js + #if (js || uwp) var scene2d = MarbleGame.instance.scene2d; #end var safeVerMargin = 1 + (scene2d.height * 0.15) / 2; diff --git a/src/gui/ReplayCenterGui.hx b/src/gui/ReplayCenterGui.hx index 1dc93651..f7e21bf7 100644 --- a/src/gui/ReplayCenterGui.hx +++ b/src/gui/ReplayCenterGui.hx @@ -33,7 +33,7 @@ class ReplayCenterGui extends GuiImage { #if hl var scene2d = hxd.Window.getInstance(); #end - #if js + #if (js || uwp) var scene2d = MarbleGame.instance.scene2d; #end diff --git a/src/gui/TouchCtrlsEditGui.hx b/src/gui/TouchCtrlsEditGui.hx index 63df44aa..36d7dc48 100644 --- a/src/gui/TouchCtrlsEditGui.hx +++ b/src/gui/TouchCtrlsEditGui.hx @@ -24,7 +24,7 @@ class TouchCtrlsEditGui extends GuiImage { #if hl var scene2d = hxd.Window.getInstance(); #end - #if js + #if (js || uwp) var scene2d = MarbleGame.instance.scene2d; #end diff --git a/src/gui/TouchOptionsGui.hx b/src/gui/TouchOptionsGui.hx index 1ca9db99..6858a544 100644 --- a/src/gui/TouchOptionsGui.hx +++ b/src/gui/TouchOptionsGui.hx @@ -27,7 +27,7 @@ class TouchOptionsGui extends GuiImage { #if hl var scene2d = hxd.Window.getInstance(); #end - #if js + #if (js || uwp) var scene2d = MarbleGame.instance.scene2d; #end diff --git a/src/gui/VersionGui.hx b/src/gui/VersionGui.hx index 83eaf64a..57fbec5a 100644 --- a/src/gui/VersionGui.hx +++ b/src/gui/VersionGui.hx @@ -22,7 +22,7 @@ class VersionGui extends GuiImage { #if hl var scene2d = hxd.Window.getInstance(); #end - #if js + #if (js || uwp) var scene2d = MarbleGame.instance.scene2d; #end diff --git a/src/gui/VideoOptionsGui.hx b/src/gui/VideoOptionsGui.hx index a97dbb55..ccbf2c63 100644 --- a/src/gui/VideoOptionsGui.hx +++ b/src/gui/VideoOptionsGui.hx @@ -26,7 +26,7 @@ class VideoOptionsGui extends GuiImage { #if hl var scene2d = hxd.Window.getInstance(); #end - #if js + #if (js || uwp) var scene2d = MarbleGame.instance.scene2d; #end