Skip to content

Commit

Permalink
prevent keybinds from overflowing left side of GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
WaitingIdly committed Apr 6, 2024
1 parent 54f6d1e commit a874f9d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1242,6 +1242,11 @@ public static class MiscCategory
@Config.Comment("Enhance the vanilla 'Open to LAN' GUI for listening port customization, removal of enforced authentication and more")
public boolean utLANServerProperties = true;

@Config.RequiresMcRestart
@Config.Name("Prevent Keybinds from Overflowing Screen")
@Config.Comment("Always indent keybind entries from the screen edge, preventing them from overflowing off the left side when particularly long keybind names are present")
public boolean utPreventKeybindingEntryOverflow = true;

@Config.RequiresMcRestart
@Config.Name("Compact Messages")
@Config.Comment("Removes duplicate messages and instead put a number behind the message how often it was repeated")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ public List<String> getMixinConfigs()
configs.add("mixins.tweaks.misc.commands.seed.json");
configs.add("mixins.tweaks.misc.credits.json");
configs.add("mixins.tweaks.misc.difficulty.client.json");
configs.add("mixins.tweaks.misc.gui.keybindlistentry.json");
configs.add("mixins.tweaks.misc.gui.lanserverproperties.json");
configs.add("mixins.tweaks.misc.gui.overlaymessage.json");
configs.add("mixins.tweaks.misc.gui.potionduration.json");
Expand Down Expand Up @@ -312,6 +313,8 @@ public boolean shouldMixinConfigQueue(String mixinConfig)
return UTConfigTweaks.MISC.utCopyWorldSeedToggle;
case "mixins.tweaks.misc.credits.json":
return UTConfigTweaks.MISC.utSkipCreditsToggle;
case "mixins.tweaks.misc.gui.keybindlistentry.json":
return UTConfigTweaks.MISC.utPreventKeybindingEntryOverflow;
case "mixins.tweaks.misc.gui.lanserverproperties.json":
return UTConfigTweaks.MISC.utLANServerProperties;
case "mixins.tweaks.misc.gui.overlaymessage.json":
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package mod.acgaming.universaltweaks.tweaks.misc.gui.keybindlist.mixin;

import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.GuiKeyBindingList;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(value = GuiKeyBindingList.KeyEntry.class)
public abstract class UTKeyEntryMixin
{
@Redirect(method = "drawEntry", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/FontRenderer;drawString(Ljava/lang/String;III)I"))
public int utIndentEntryText(FontRenderer f, String text, int x, int y, int color)
{
return f.drawString(text, Math.max(x, 5), y, color);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"package": "mod.acgaming.universaltweaks.tweaks.misc.gui.keybindlist.mixin",
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"client": ["UTKeyEntryMixin"]
}

0 comments on commit a874f9d

Please sign in to comment.