Skip to content

Commit

Permalink
Added mc tweak windowSizeApply, windowSizeWidth, `windowSizeHeigh…
Browse files Browse the repository at this point in the history
…t`, `windowSizePinned`
  • Loading branch information
Fallen-Breath committed May 28, 2024
1 parent 40fa27b commit 0b474a0
Show file tree
Hide file tree
Showing 8 changed files with 328 additions and 0 deletions.
60 changes: 60 additions & 0 deletions docs/document-en_us.md
Original file line number Diff line number Diff line change
Expand Up @@ -1844,6 +1844,66 @@ The client-side weather value to be overridden by tweak weatherOverride
- Available options: `Clear sky`, `Rain`, `Thunderstorm`


### windowSizeApply

Change the size of the game window to windowSizeHeight and windowSizeWidth

Does not work in full screen

See also: option windowSizeHeight, windowSizeWidth, windowSizePinned

- Category: MC Tweaks
- Type: hotkey (Hotkey)
- Default value: *no hotkey*


### windowSizeHeight

Height to set for the game window

To apply the desired height, use option windowSizeApply

See also: option windowSizeApply, windowSizeWidth, windowSizePinned

- Category: MC Tweaks
- Type: integer (Generic)
- Default value: `480`
- Minimum value: `90`
- Maximum value: `8640`


### windowSizePinned

Pin the size of the game window to windowSizeHeight and windowSizeWidth

Actually it will revert any window size changed from a user action,

since it's not possible to complete disable windows resize after the window is created

Does not work in full screen

See also: option windowSizeApply, windowSizeHeight, windowSizeWidth

- Category: MC Tweaks
- Type: boolean (Generic)
- Default value: `false`


### windowSizeWidth

Width to set for the game window

To apply the desired width, use option windowSizeApply

See also: option windowSizeApply, windowSizeHeight, windowSizePinned

- Category: MC Tweaks
- Type: integer (Generic)
- Default value: `854`
- Minimum value: `160`
- Maximum value: `15360`


### yeetServerIpReversedDnsLookup

For servers whose addresses are represented solely by IP, disable reverse DNS lookups in the InetAddress object
Expand Down
60 changes: 60 additions & 0 deletions docs/document-zh_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -1840,6 +1840,66 @@ Format error: 修复使用原版聊天缩放设置来缩放聊天信息HUD中的
- 可用选项: `晴天`, `降雨`, `雷暴`


### 窗口大小-应用 (windowSizeApply)

调成游戏窗口大小至选项 窗口大小-高度 和 窗口大小-宽度 的值

该选项只在非全屏的情况下可用

另见:选项 窗口大小-高度、窗口大小-宽度、窗口大小-固定

- 分类: MC修改
- 类型: 热键 (热键)
- 默认值: *无快捷键*


### 窗口大小-高度 (windowSizeHeight)

设置游戏窗口的高度

要使窗口高度调整生效,需使用选项 窗口大小-应用

另见:选项 窗口大小-应用、窗口大小-宽度、窗口大小-固定

- 分类: MC修改
- 类型: 整数 (通用)
- 默认值: `480`
- 最小值: `90`
- 最大值: `8640`


### 窗口大小-固定 (windowSizePinned)

将游戏窗口的大小固定为 窗口大小-高度 和 窗口大小-宽度

由于技术限制,该选项的实际实现是,在玩家调整了窗口大小后,立刻把大小改回给定值,

因为在窗口创建后 GLFW 无法动态改变窗口的大小可调整性

该选项只在非全屏的情况下可用

另见:选项 option 窗口大小-应用、窗口大小-高度、窗口大小-宽度

- 分类: MC修改
- 类型: 布尔值 (通用)
- 默认值: `false`


### 窗口大小-宽度 (windowSizeWidth)

设置游戏窗口的宽度

要使窗口宽度调整生效,需使用选项 窗口大小-应用

另见:选项 窗口大小-应用、窗口大小-高度、窗口大小-固定

- 分类: MC修改
- 类型: 整数 (通用)
- 默认值: `854`
- 最小值: `160`
- 最大值: `15360`


### 禁止服务器IP地址DNS反查 (yeetServerIpReversedDnsLookup)

对于用纯IP表示的服务器地址,阻止其InetAddress对象进行逆向DNS查询操作
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import me.fallenbreath.tweakermore.impl.features.refreshInventory.InventoryRefresher;
import me.fallenbreath.tweakermore.impl.features.schematicProPlace.ProPlaceImpl;
import me.fallenbreath.tweakermore.impl.mc_tweaks.flawlessFrames.FlawlessFramesHandler;
import me.fallenbreath.tweakermore.impl.mc_tweaks.windowSize.WindowSizeHelper;
import me.fallenbreath.tweakermore.impl.mc_tweaks.particleLimit.ParticleLimitHelper;
import me.fallenbreath.tweakermore.impl.mod_tweaks.eCraftMassCraftCompact.EasierCraftingRegistrar;
import me.fallenbreath.tweakermore.impl.mod_tweaks.lmRemoveEntityCommand.LitematicaRemoveEntityCommandOverrider;
Expand Down Expand Up @@ -582,6 +583,18 @@ public class TweakerMoreConfigs
@Config(type = Config.Type.GENERIC, category = Config.Category.MC_TWEAKS)
public static final TweakerMoreConfigBoolean YEET_SERVER_IP_REVERSED_DNS_LOOKUP = newConfigBoolean("yeetServerIpReversedDnsLookup", false);

@Config(type = Config.Type.HOTKEY, category = Config.Category.MC_TWEAKS)
public static final TweakerMoreConfigHotkey WINDOW_SIZE_APPLY = newConfigHotKey("windowSizeApply", "");

@Config(type = Config.Type.GENERIC, category = Config.Category.MC_TWEAKS)
public static final TweakerMoreConfigInteger WINDOW_SIZE_WIDTH = newConfigInteger("windowSizeWidth", 854, 160, 15360);

@Config(type = Config.Type.GENERIC, category = Config.Category.MC_TWEAKS)
public static final TweakerMoreConfigInteger WINDOW_SIZE_HEIGHT = newConfigInteger("windowSizeHeight", 480, 90, 8640);

@Config(type = Config.Type.GENERIC, category = Config.Category.MC_TWEAKS)
public static final TweakerMoreConfigBoolean WINDOW_SIZE_PINNED = newConfigBoolean("windowSizePinned", false);

////////////////////
// Mod Tweaks //
////////////////////
Expand Down Expand Up @@ -872,6 +885,7 @@ public static void initConfigs()
setHotkeyCallback(OPEN_TWEAKERMORE_CONFIG_GUI, TweakerMoreConfigGui::openGui, true);
setHotkeyCallback(PISTORDER_CLEAR_DISPLAY, PistorderRenderer.getInstance()::clearDisplay, false);
setHotkeyCallback(REFRESH_INVENTORY, InventoryRefresher::refresh, false);
setHotkeyCallback(WINDOW_SIZE_APPLY, WindowSizeHelper::applyWindowSize, false);

// value listeners
ECRAFT_ITEM_SCROLLER_COMPACT.setValueChangeCallback(EasierCraftingRegistrar::onConfigValueChanged);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/*
* This file is part of the TweakerMore project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2024 Fallen_Breath and contributors
*
* TweakerMore is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TweakerMore is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with TweakerMore. If not, see <https://www.gnu.org/licenses/>.
*/

package me.fallenbreath.tweakermore.impl.mc_tweaks.windowSize;

import fi.dy.masa.malilib.gui.Message;
import fi.dy.masa.malilib.util.InfoUtils;
import me.fallenbreath.tweakermore.TweakerMoreMod;
import me.fallenbreath.tweakermore.config.TweakerMoreConfigs;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.util.Window;
import org.lwjgl.glfw.GLFW;

public class WindowSizeHelper
{
public static void applyWindowSize()
{
MinecraftClient mc = MinecraftClient.getInstance();
//#if MC >= 11500
Window window = mc.getWindow();
//#else
//$$ Window window = mc.window;
//#endif

if (window == null)
{
return;
}
if (window.isFullscreen())
{
InfoUtils.showGuiOrInGameMessage(Message.MessageType.WARNING, "tweakermore.impl.windowSize.full_screen_nope");
return;
}

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())
{
return;
}
if (window.isFullscreen())
{
return;
}

int windowWidth = window.getWidth();
int windowHeight = window.getHeight();
int configWidth = getConfigWidth();
int configHeight = getConfigHeight();

if (windowWidth != configWidth || windowHeight != configHeight)
{
TweakerMoreMod.LOGGER.debug(
"Window size was changed to ({}, {}) and is different to the configured size ({}, {}), resizing",
windowWidth, windowHeight, configWidth, configHeight
);
applyWindowSizeImpl(window);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* This file is part of the TweakerMore project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2024 Fallen_Breath and contributors
*
* TweakerMore is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* TweakerMore is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with TweakerMore. If not, see <https://www.gnu.org/licenses/>.
*/

package me.fallenbreath.tweakermore.mixins.tweaks.mc_tweaks.windowSize;

import me.fallenbreath.tweakermore.impl.mc_tweaks.windowSize.WindowSizeHelper;
import net.minecraft.client.util.Window;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(Window.class)
public abstract class WindowMixin
{
@Inject(method = "onWindowSizeChanged", at = @At("TAIL"))
private void onWindowSizeChanged_windowSize(CallbackInfo ci)
{
WindowSizeHelper.onWindowSizeChanged((Window)(Object)this);
}
}
28 changes: 28 additions & 0 deletions src/main/resources/assets/tweakermore/lang/en_us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,32 @@ tweakermore:
Many non-loopback IPs lack associated domain names, which makes reverse lookups time-consuming
This option sets the domain of those servers directly to their IP, bypassing the reverse DNS check
This results in a 1s ~ 5s reduction in time for server list pinging and connections to those servers
windowSizeApply:
.: windowSizeApply
comment: |-
Change the size of the game window to @option#windowSizeHeight@ and @option#windowSizeWidth@
Does not work in full screen
See also: option @option#windowSizeHeight@, @option#windowSizeWidth@, @option#windowSizePinned@
windowSizeWidth:
.: windowSizeWidth
comment: |-
Width to set for the game window
To apply the desired width, use option @option#windowSizeApply@
See also: option @option#windowSizeApply@, @option#windowSizeHeight@, @option#windowSizePinned@
windowSizeHeight:
.: windowSizeHeight
comment: |-
Height to set for the game window
To apply the desired height, use option @option#windowSizeApply@
See also: option @option#windowSizeApply@, @option#windowSizeWidth@, @option#windowSizePinned@
windowSizePinned:
.: windowSizePinned
comment: |-
Pin the size of the game window to @option#windowSizeHeight@ and @option#windowSizeWidth@
Actually it will revert any window size changed from a user action,
since it's not possible to complete disable windows resize after the window is created
Does not work in full screen
See also: option @option#windowSizeApply@, @option#windowSizeHeight@, @option#windowSizeWidth@
# ================================ Mod Tweaks ================================

Expand Down Expand Up @@ -1103,6 +1129,8 @@ tweakermore:
more: '... %1$sx'
tweakerMoreDevMixinAudit:
success: Mixin audit succeeded
windowSize:
full_screen_nope: Cannot perform window resize in full screen

# ================================ Misc ================================

Expand Down
28 changes: 28 additions & 0 deletions src/main/resources/assets/tweakermore/lang/zh_cn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,32 @@ tweakermore:
很多非本地回环的IP地址并没有对应的域名,这将使逆向查询它们域名的操作消耗不少时间
该选项直接将这些服务器的域名设置为其IP地址,从而跳过不必要的DNS反查操作
取决于具体环境,这能为这类服务器地址带来1s~5s的提速。影响场景:服务器列表刷新、服务器连接
windowSizeApply:
.: 窗口大小-应用
comment: |-
调成游戏窗口大小至选项 @option#windowSizeHeight@ 和 @option#windowSizeWidth@ 的值
该选项只在非全屏的情况下可用
另见:选项 @option#windowSizeHeight@、@option#windowSizeWidth@、@option#windowSizePinned@
windowSizeWidth:
.: 窗口大小-宽度
comment: |-
设置游戏窗口的宽度
要使窗口宽度调整生效,需使用选项 @option#windowSizeApply@
另见:选项 @option#windowSizeApply@、@option#windowSizeHeight@、@option#windowSizePinned@
windowSizeHeight:
.: 窗口大小-高度
comment: |-
设置游戏窗口的高度
要使窗口高度调整生效,需使用选项 @option#windowSizeApply@
另见:选项 @option#windowSizeApply@、@option#windowSizeWidth@、@option#windowSizePinned@
windowSizePinned:
.: 窗口大小-固定
comment: |-
将游戏窗口的大小固定为 @option#windowSizeHeight@ 和 @option#windowSizeWidth@
由于技术限制,该选项的实际实现是,在玩家调整了窗口大小后,立刻把大小改回给定值,
因为在窗口创建后 GLFW 无法动态改变窗口的大小可调整性
该选项只在非全屏的情况下可用
另见:选项 option @option#windowSizeApply@、@option#windowSizeHeight@、@option#windowSizeWidth@
# ================================ Mod Tweaks ================================

Expand Down Expand Up @@ -1103,6 +1129,8 @@ tweakermore:
more: '... %1$sx'
tweakerMoreDevMixinAudit:
success: Mixin审计成功
windowSize:
full_screen_nope: 无法在全屏模式下调整窗口大小

# ================================ Misc ================================

Expand Down
1 change: 1 addition & 0 deletions src/main/resources/tweakermore.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@
"tweaks.mc_tweaks.unlimitedBlockEntityRenderDistance.BlockEntityRenderDispatcherMixin",
"tweaks.mc_tweaks.unlimitedEntityRenderDistance.EntityMixin",
"tweaks.mc_tweaks.weatherOverride.WorldMixin",
"tweaks.mc_tweaks.windowSize.WindowMixin",
"tweaks.mc_tweaks.yeetServerIpReversedDnsLookup.AddressResolverMixin",
"tweaks.mc_tweaks.yeetServerIpReversedDnsLookup.ConnectScreenThreadMixin",
"tweaks.mc_tweaks.yeetServerIpReversedDnsLookup.MultiplayerServerListPingerMixin",
Expand Down

0 comments on commit 0b474a0

Please sign in to comment.