From dbfa176e7b9a125282ec62989d0040884f4b1213 Mon Sep 17 00:00:00 2001 From: Fallen_Breath Date: Sun, 14 Jul 2024 17:30:44 +0800 Subject: [PATCH] apply `windowSizePinned` on config loaded as well --- .../config/TweakerMoreConfigs.java | 1 + .../windowSize/WindowSizeHelper.java | 48 +++++++++++-------- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/src/main/java/me/fallenbreath/tweakermore/config/TweakerMoreConfigs.java b/src/main/java/me/fallenbreath/tweakermore/config/TweakerMoreConfigs.java index 7cb0d800..fb43236f 100644 --- a/src/main/java/me/fallenbreath/tweakermore/config/TweakerMoreConfigs.java +++ b/src/main/java/me/fallenbreath/tweakermore/config/TweakerMoreConfigs.java @@ -954,6 +954,7 @@ static void onConfigLoaded() TweakerMoreConfigs.AUTO_CLEAN_CONTAINER_RESTRICTION.setListContents(TweakerMoreConfigs.AUTO_CLEAN_CONTAINER_BLACKLIST.getStrings(), TweakerMoreConfigs.AUTO_CLEAN_CONTAINER_WHITELIST.getStrings()); SpectatorTeleportCommand.init(); + WindowSizeHelper.onConfigLoaded(); } // Config fields collecting diff --git a/src/main/java/me/fallenbreath/tweakermore/impl/mc_tweaks/windowSize/WindowSizeHelper.java b/src/main/java/me/fallenbreath/tweakermore/impl/mc_tweaks/windowSize/WindowSizeHelper.java index 8e9ba53f..91e8a733 100644 --- a/src/main/java/me/fallenbreath/tweakermore/impl/mc_tweaks/windowSize/WindowSizeHelper.java +++ b/src/main/java/me/fallenbreath/tweakermore/impl/mc_tweaks/windowSize/WindowSizeHelper.java @@ -52,25 +52,6 @@ public static void applyWindowSize() applyWindowSizeImpl(window); } - private static int getConfigWidth() - { - return Math.max(1, TweakerMoreConfigs.WINDOW_SIZE_WIDTH.getIntegerValue()); - } - - private static int getConfigHeight() - { - return Math.max(1, TweakerMoreConfigs.WINDOW_SIZE_HEIGHT.getIntegerValue()); - } - - private static void applyWindowSizeImpl(Window window) - { - if (window.isFullscreen()) - { - throw new RuntimeException("resize in full screen"); - } - GLFW.glfwSetWindowSize(window.getHandle(), getConfigWidth(), getConfigHeight()); - } - public static void onWindowSizeChanged(Window window) { if (!TweakerMoreConfigs.WINDOW_SIZE_PINNED.getBooleanValue()) @@ -96,4 +77,33 @@ public static void onWindowSizeChanged(Window window) applyWindowSizeImpl(window); } } + + public static void onConfigLoaded() + { + Window window = MinecraftClient.getInstance().getWindow(); + if (window != null) + { + onWindowSizeChanged(window); + } + } + + private static int getConfigWidth() + { + return Math.max(1, TweakerMoreConfigs.WINDOW_SIZE_WIDTH.getIntegerValue()); + } + + private static int getConfigHeight() + { + return Math.max(1, TweakerMoreConfigs.WINDOW_SIZE_HEIGHT.getIntegerValue()); + } + + private static void applyWindowSizeImpl(Window window) + { + if (window.isFullscreen()) + { + // remember to check this before calling applyWindowSizeImpl() + throw new RuntimeException("resize in full screen"); + } + GLFW.glfwSetWindowSize(window.getHandle(), getConfigWidth(), getConfigHeight()); + } }