From 8b1c75afec096111d79fe2b09a91c187f676b0a4 Mon Sep 17 00:00:00 2001 From: ipkpjersi Date: Tue, 18 Jun 2024 00:09:48 -0400 Subject: [PATCH] Added Mac check for resize SD logout using HD --- .../main/kotlin/ToggleResizableSD/plugin.kt | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/plugin-playground/src/main/kotlin/ToggleResizableSD/plugin.kt b/plugin-playground/src/main/kotlin/ToggleResizableSD/plugin.kt index ecf53e7..c60c8cb 100644 --- a/plugin-playground/src/main/kotlin/ToggleResizableSD/plugin.kt +++ b/plugin-playground/src/main/kotlin/ToggleResizableSD/plugin.kt @@ -14,6 +14,7 @@ import java.awt.event.KeyEvent ) class plugin : Plugin() { var toggleResize = false + var wantHd = false //Setting wantHd to true hides the black screen on logout (when resize SD is enabled), by enabling HD on logout override fun Init() { API.AddKeyboardListener(object : KeyAdapter() { override fun keyPressed(e: KeyEvent) { @@ -25,6 +26,21 @@ class plugin : Plugin() { if (!DisplayMode.resizableSD && API.GetData("use-resizable-sd") == true) { toggleResize = true } + var osNameLowerCase: String = "" + var osName: String + + try { + osName = System.getProperty("os.name") + } catch (e: Exception) { + osName = "Unknown" + } + + osNameLowerCase = osName.toLowerCase() + if (!osNameLowerCase.startsWith("mac")) { + wantHd = true + } + //Alternatively, we could just force HD off here, if we want: + //wantHd = false } override fun ProcessCommand(commandStr: String, args: Array?) { @@ -36,6 +52,7 @@ class plugin : Plugin() { } fun toggleResizableSd() { + //We only want to toggle resizable SD when we are logged in and the lobby/welcome interface is not open. if (InterfaceList.aClass13_26 == null || client.gameState != 30) { return } @@ -59,7 +76,7 @@ class plugin : Plugin() { } override fun OnLogout() { - if (DisplayMode.resizableSD) { + if (DisplayMode.resizableSD && wantHd) { //Because resizable SD always uses the "HD" size canvas/window mode (check the in-game Graphics Options with resizeable SD enabled if you don't believe me!), useHD becomes true when logging out, so logging out with resizeSD enabled means "HD" will always be enabled on the login screen after logging out, so we might as well fix the HD flyover by setting resizableSD to false first, and then calling setWindowMode to replace the canvas and set newMode to 2. DisplayMode.resizableSD = false DisplayMode.setWindowMode(true, 2, GameShell.frameWidth, GameShell.frameHeight)