From 97826a49285122205458decd2a59730123f516c1 Mon Sep 17 00:00:00 2001 From: Hendrix-Shen Date: Mon, 15 Jul 2024 23:40:22 +0800 Subject: [PATCH] Add fixConfigWidgetWidthExpand Signed-off-by: Hendrix-Shen --- src/main/java/com/plusls/MasaGadget/game/Configs.java | 6 +++++- .../MixinWidgetListConfigOptions.java | 8 +++++--- src/main/resources/assets/masa_gadget_mod/lang/en_us.json | 2 ++ src/main/resources/assets/masa_gadget_mod/lang/zh_cn.json | 2 ++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/plusls/MasaGadget/game/Configs.java b/src/main/java/com/plusls/MasaGadget/game/Configs.java index cbac3e3..d75c379 100644 --- a/src/main/java/com/plusls/MasaGadget/game/Configs.java +++ b/src/main/java/com/plusls/MasaGadget/game/Configs.java @@ -111,10 +111,14 @@ public class Configs { @Config(category = ConfigCategory.MALILIB) public static MagicConfigBooleanHotkeyed favoritesSupport = Configs.cf.newConfigBooleanHotkeyed("favoritesSupport", false); - @Dependencies(require = @Dependency(value = ModId.malilib, versionPredicates = "<0.11.0")) + @Dependencies(require = @Dependency(ModId.malilib)) @Config(category = ConfigCategory.MALILIB) public static MagicConfigBoolean fixConfigWidgetWidth = Configs.cf.newConfigBoolean("fixConfigWidgetWidth", false); + @Dependencies(require = @Dependency(ModId.malilib)) + @Config(category = ConfigCategory.MALILIB) + public static MagicConfigBoolean fixConfigWidgetWidthExpand = Configs.cf.newConfigBoolean("fixConfigWidgetWidthExpand", false); + @Dependencies(require = @Dependency(value = ModId.malilib, versionPredicates = "<0.11.0")) @Config(category = ConfigCategory.MALILIB) public static MagicConfigBoolean fixGetInventoryType = Configs.cf.newConfigBoolean("fixGetInventoryType", false); diff --git a/src/main/java/com/plusls/MasaGadget/mixin/mod_tweak/malilib/fixConfigWidgetWidth/MixinWidgetListConfigOptions.java b/src/main/java/com/plusls/MasaGadget/mixin/mod_tweak/malilib/fixConfigWidgetWidth/MixinWidgetListConfigOptions.java index e34bf22..5aa5b7a 100644 --- a/src/main/java/com/plusls/MasaGadget/mixin/mod_tweak/malilib/fixConfigWidgetWidth/MixinWidgetListConfigOptions.java +++ b/src/main/java/com/plusls/MasaGadget/mixin/mod_tweak/malilib/fixConfigWidgetWidth/MixinWidgetListConfigOptions.java @@ -6,6 +6,7 @@ import fi.dy.masa.malilib.gui.widgets.WidgetConfigOption; import fi.dy.masa.malilib.gui.widgets.WidgetListConfigOptions; import fi.dy.masa.malilib.gui.widgets.WidgetListConfigOptionsBase; +import fi.dy.masa.malilib.util.StringUtils; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -22,7 +23,7 @@ import java.util.List; import java.util.Objects; -@Dependencies(require = @Dependency(value = ModId.malilib, versionPredicates = "<0.11.0")) +@Dependencies(require = @Dependency(ModId.malilib)) @Mixin(value = WidgetListConfigOptions.class, remap = false) public abstract class MixinWidgetListConfigOptions extends WidgetListConfigOptionsBase { @Unique @@ -65,8 +66,9 @@ private void fixWidth(List wrappers, Callbac for (GuiConfigsBase.ConfigOptionWrapper wrapper : wrappers) { if (wrapper.getType() == GuiConfigsBase.ConfigOptionWrapper.Type.CONFIG) { - maxWidth = Math.max(maxWidth, this.getStringWidth( - Objects.requireNonNull(wrapper.getConfig()).getConfigGuiDisplayName())); + String label = Objects.requireNonNull(wrapper.getConfig()).getConfigGuiDisplayName(); + maxWidth = Math.max(maxWidth, this.getStringWidth(Configs.fixConfigWidgetWidthExpand.getBooleanValue() ? + StringUtils.translate(label) : label)); } } diff --git a/src/main/resources/assets/masa_gadget_mod/lang/en_us.json b/src/main/resources/assets/masa_gadget_mod/lang/en_us.json index 0b889b2..79ae089 100644 --- a/src/main/resources/assets/masa_gadget_mod/lang/en_us.json +++ b/src/main/resources/assets/masa_gadget_mod/lang/en_us.json @@ -57,6 +57,8 @@ "masa_gadget_mod.config.option.favoritesSupport.comment": "Users can favorite and filter their frequently used options.", "masa_gadget_mod.config.option.fixConfigWidgetWidth.name": "fixConfigWidgetWidth", "masa_gadget_mod.config.option.fixConfigWidgetWidth.comment": "Use the length of getTranslatedGuiDisplayName as widget width", + "masa_gadget_mod.config.option.fixConfigWidgetWidthExpand.name": "fixConfigWidgetWidthExpand", + "masa_gadget_mod.config.option.fixConfigWidgetWidthExpand.comment": "Deeper fixes for the config width label, require §6fixConfigWidgetWidth§r to be enabled.\nNote:\nMay cause additional performance overhead,\ntry enabling it only if there is a problem with config label widths,\ndisable it if it doesn't take effect", "masa_gadget_mod.config.option.fixGetInventoryType.name": "fixGetInventoryType", "masa_gadget_mod.config.option.fixGetInventoryType.comment": "Fix AbstractFurnaceBlock inventory type", "masa_gadget_mod.config.option.fixSearchbarHotkeyInput.name": "fixSearchbarHotkeyInput", diff --git a/src/main/resources/assets/masa_gadget_mod/lang/zh_cn.json b/src/main/resources/assets/masa_gadget_mod/lang/zh_cn.json index ae4f9cf..7b717c9 100644 --- a/src/main/resources/assets/masa_gadget_mod/lang/zh_cn.json +++ b/src/main/resources/assets/masa_gadget_mod/lang/zh_cn.json @@ -57,6 +57,8 @@ "masa_gadget_mod.config.option.favoritesSupport.comment": "可以收藏并过滤出自己喜欢的选项", "masa_gadget_mod.config.option.fixConfigWidgetWidth.name": "修复 Masa 配置文本的宽度", "masa_gadget_mod.config.option.fixConfigWidgetWidth.comment": "在使用汉化包后现在的界面会根据汉化后的文本长度自动调节", + "masa_gadget_mod.config.option.fixConfigWidgetWidthExpand.name": "修复 Masa 配置文本的宽度增强", + "masa_gadget_mod.config.option.fixConfigWidgetWidthExpand.comment": "更深层修复配置文本宽度, 需要启用 §6修复 Masa 配置文本的宽度§r\n注意:\n可能带来额外的性能开销,\n仅当配置文本宽度出现问题时尝试启用,\n若不生效请关闭此功能", "masa_gadget_mod.config.option.fixGetInventoryType.name": "修复容器类型", "masa_gadget_mod.config.option.fixGetInventoryType.comment": "修复对烟熏炉之类的熔炉变种的容器类型的判断", "masa_gadget_mod.config.option.fixSearchbarHotkeyInput.name": "修复搜索框按键输入",