Skip to content

Commit

Permalink
apply windowSizePinned on config loaded as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Fallen-Breath committed Jul 14, 2024
1 parent d1f2353 commit dbfa176
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand All @@ -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());
}
}

0 comments on commit dbfa176

Please sign in to comment.