From 3a33995006a50046c423ba0caad8a36ef98fe703 Mon Sep 17 00:00:00 2001 From: downthecrop Date: Sun, 3 Nov 2024 10:24:11 -0800 Subject: [PATCH 1/2] Better alt canvas logic --- .../src/main/kotlin/KondoKit/plugin.kt | 70 +++++++++---------- 1 file changed, 34 insertions(+), 36 deletions(-) diff --git a/plugin-playground/src/main/kotlin/KondoKit/plugin.kt b/plugin-playground/src/main/kotlin/KondoKit/plugin.kt index f5073ac..1b57c5a 100644 --- a/plugin-playground/src/main/kotlin/KondoKit/plugin.kt +++ b/plugin-playground/src/main/kotlin/KondoKit/plugin.kt @@ -308,23 +308,17 @@ class plugin : Plugin() { return true } - private fun initAltCanvas(){ - if (frame != null) { - altCanvas = AltCanvas().apply { - preferredSize = Dimension(FIXED_WIDTH, FIXED_HEIGHT) - } - altCanvas?.let { frame.add(it) } - moveAltCanvasToFront() - frame.setComponentZOrder(rightPanelWrapper, 2) - } - updateDisplaySettings() - } - private fun updateDisplaySettings() { val mode = GetWindowMode() val currentScrollPaneWidth = if (mainContentPanel.isVisible) NAVBAR_WIDTH + MAIN_CONTENT_WIDTH else NAVBAR_WIDTH lastUIOffset = uiOffset + if(mode != WindowMode.FIXED) { + destroyAltCanvas() + } else if (useScaledFixed && altCanvas == null) { + initAltCanvas() + } + when (mode) { WindowMode.FIXED -> { if (frame.width < FIXED_WIDTH + currentScrollPaneWidth + uiOffset) { @@ -373,22 +367,43 @@ class plugin : Plugin() { StoreData("kondoLaunchMinimized", launchMinimized) StoreData("kondoUIOffset", uiOffset) StoreData("kondoScaledFixed", useScaledFixed) - if(altCanvas == null && useScaledFixed){ - initAltCanvas() - } else if(altCanvas != null && !useScaledFixed){ - destroyAltCanvas() - } - if(lastUIOffset != uiOffset){ + if(lastUIOffset != uiOffset || useScaledFixed){ updateDisplaySettings() reloadInterfaces = true } } + private fun initAltCanvas(){ + if(GetWindowMode() != WindowMode.FIXED || altCanvas != null) return + if (frame != null) { + altCanvas = AltCanvas().apply { + preferredSize = Dimension(FIXED_WIDTH, FIXED_HEIGHT) + } + altCanvas?.let { frame.add(it) } + moveAltCanvasToFront() + frame.setComponentZOrder(rightPanelWrapper, 2) + } + } + private fun destroyAltCanvas(){ + if (altCanvas == null) return moveCanvasToFront() frame.remove(altCanvas) altCanvas = null - updateDisplaySettings() + } + + private fun moveAltCanvasToFront(){ + if (altCanvas == null) return + frame.setComponentZOrder(canvas, 2) + frame.setComponentZOrder(altCanvas, 1) + frame.setComponentZOrder(rightPanelWrapper, 0) + } + + private fun moveCanvasToFront(){ + if (altCanvas == null) return + frame.setComponentZOrder(altCanvas, 2) + frame.setComponentZOrder(canvas, 1) + frame.setComponentZOrder(rightPanelWrapper, 0) } private fun searchHiscore(username: String): Runnable { @@ -402,20 +417,6 @@ class plugin : Plugin() { } } - private fun moveAltCanvasToFront(){ - if(altCanvas == null) return - frame.setComponentZOrder(canvas, 2) - frame.setComponentZOrder(altCanvas, 1) - frame.setComponentZOrder(rightPanelWrapper, 0) - } - - private fun moveCanvasToFront(){ - if(altCanvas == null) return - frame.setComponentZOrder(altCanvas, 2) - frame.setComponentZOrder(canvas, 1) - frame.setComponentZOrder(rightPanelWrapper, 0) - } - private fun restoreSettings(){ themeName = (GetData("kondoTheme") as? String) ?: "RUNELITE" useLiveGEPrices = (GetData("kondoUseRemoteGE") as? Boolean) ?: true @@ -490,9 +491,6 @@ class plugin : Plugin() { } else { setActiveView(XPTrackerView.VIEW_NAME) } - if(useScaledFixed) { - initAltCanvas() - } initialized = true pluginsReloaded = true } From 77c5528fc1c4e802047cc28ed1d4eb29ba580436 Mon Sep 17 00:00:00 2001 From: downthecrop Date: Sun, 3 Nov 2024 10:25:50 -0800 Subject: [PATCH 2/2] always update display settings --- plugin-playground/src/main/kotlin/KondoKit/plugin.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin-playground/src/main/kotlin/KondoKit/plugin.kt b/plugin-playground/src/main/kotlin/KondoKit/plugin.kt index 1b57c5a..fcf4666 100644 --- a/plugin-playground/src/main/kotlin/KondoKit/plugin.kt +++ b/plugin-playground/src/main/kotlin/KondoKit/plugin.kt @@ -367,10 +367,10 @@ class plugin : Plugin() { StoreData("kondoLaunchMinimized", launchMinimized) StoreData("kondoUIOffset", uiOffset) StoreData("kondoScaledFixed", useScaledFixed) - if(lastUIOffset != uiOffset || useScaledFixed){ - updateDisplaySettings() + if(lastUIOffset != uiOffset){ reloadInterfaces = true } + updateDisplaySettings() } private fun initAltCanvas(){