Skip to content

Commit

Permalink
Add fixConfigWidgetWidthExpand
Browse files Browse the repository at this point in the history
Signed-off-by: Hendrix-Shen <[email protected]>
  • Loading branch information
Hendrix-Shen committed Jul 15, 2024
1 parent 96c49d7 commit 97826a4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
6 changes: 5 additions & 1 deletion src/main/java/com/plusls/MasaGadget/game/Configs.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<GuiConfigsBase.ConfigOptionWrapper, WidgetConfigOption> {
@Unique
Expand Down Expand Up @@ -65,8 +66,9 @@ private void fixWidth(List<GuiConfigsBase.ConfigOptionWrapper> 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));
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/masa_gadget_mod/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/assets/masa_gadget_mod/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "修复搜索框按键输入",
Expand Down

0 comments on commit 97826a4

Please sign in to comment.