From 72058aef0085eea3dec5d7a1cbd0b834e4986d01 Mon Sep 17 00:00:00 2001 From: Integer Limit <103940576+IntegerLimit@users.noreply.github.com> Date: Sun, 13 Oct 2024 20:27:53 +1100 Subject: [PATCH] Fix Auto-Focusing Terminals --- .../nomiceu/nomilabs/config/LabsConfig.java | 30 +++++++++++++ ...idInterfaceConfigurationTerminalMixin.java | 39 +++++++++++++++++ .../mixin/ae2/GuiFluidTerminalMixin.java | 37 ++++++++++++++++ ...uiInterfaceConfigurationTerminalMixin.java | 39 +++++++++++++++++ .../mixin/ae2/GuiInterfaceTerminalMixin.java | 42 +++++++++++++++++++ .../resources/assets/nomilabs/lang/en_us.lang | 7 ++++ .../mixins.nomilabs.appliedenergistics2.json | 6 ++- 7 files changed, 199 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/nomiceu/nomilabs/mixin/ae2/GuiFluidInterfaceConfigurationTerminalMixin.java create mode 100644 src/main/java/com/nomiceu/nomilabs/mixin/ae2/GuiFluidTerminalMixin.java create mode 100644 src/main/java/com/nomiceu/nomilabs/mixin/ae2/GuiInterfaceConfigurationTerminalMixin.java create mode 100644 src/main/java/com/nomiceu/nomilabs/mixin/ae2/GuiInterfaceTerminalMixin.java diff --git a/src/main/java/com/nomiceu/nomilabs/config/LabsConfig.java b/src/main/java/com/nomiceu/nomilabs/config/LabsConfig.java index 790f19a9..75f6a6f8 100644 --- a/src/main/java/com/nomiceu/nomilabs/config/LabsConfig.java +++ b/src/main/java/com/nomiceu/nomilabs/config/LabsConfig.java @@ -272,6 +272,36 @@ public static class ModIntegration { @Config.LangKey("config.nomilabs.mod_integration.bqu_fluid_task_fixes") public boolean enableBQuFluidTaskFixes = true; + @Config.Comment("AE2 Terminal Options") + @Config.LangKey("config.nomilabs.mod_integration.ae2_terminal") + @Config.Name("ae2 terminal options") + public final AE2TerminalOptions ae2TerminalOptions = new AE2TerminalOptions(); + + public static class AE2TerminalOptions { + + @Config.Comment({ "Whether to Auto-Focus the Fluid Terminal.", "[default: true]" }) + @Config.LangKey("config.nomilabs.mod_integration.ae2_terminal.fluid") + public boolean autoFocusFluid = true; + + @Config.Comment({ "Whether to Auto-Focus the Interface Terminal.", "[default: true]" }) + @Config.LangKey("config.nomilabs.mod_integration.ae2_terminal.interface") + public boolean autoFocusInterface = true; + + @Config.Comment({ "Whether to Auto-Focus the Interface Configuration Terminal.", "[default: true]" }) + @Config.LangKey("config.nomilabs.mod_integration.ae2_terminal.cfg_interface") + public boolean autoFocusConfigInterface = true; + + @Config.Comment({ "Whether to Auto-Focus the Fluid Interface Configuration Terminal.", "[default: true]" }) + @Config.LangKey("config.nomilabs.mod_integration.ae2_terminal.cfg_fluid_interface") + public boolean autoFocusConfigFluidInterface = true; + + @Config.Comment({ + "Whether to Save Serach Strings in the Interface Configuration Terminals (Item and Fluid).", + "Default AE2 Behaviour is to Save.", "[default: false]" }) + @Config.LangKey("config.nomilabs.mod_integration.ae2_terminal.cfg_interface_save") + public boolean saveConfigInterfaceSearch = false; + } + public static class EffortlessBuildingIntegration { @Config.Comment({ "Whether to enable Effortless Building Integration, which splits the parts of reach.", diff --git a/src/main/java/com/nomiceu/nomilabs/mixin/ae2/GuiFluidInterfaceConfigurationTerminalMixin.java b/src/main/java/com/nomiceu/nomilabs/mixin/ae2/GuiFluidInterfaceConfigurationTerminalMixin.java new file mode 100644 index 00000000..b8214309 --- /dev/null +++ b/src/main/java/com/nomiceu/nomilabs/mixin/ae2/GuiFluidInterfaceConfigurationTerminalMixin.java @@ -0,0 +1,39 @@ +package com.nomiceu.nomilabs.mixin.ae2; + +import net.minecraft.inventory.Container; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import com.nomiceu.nomilabs.config.LabsConfig; + +import appeng.client.gui.AEBaseGui; +import appeng.client.gui.implementations.GuiFluidInterfaceConfigurationTerminal; +import appeng.client.gui.widgets.MEGuiTextField; + +/** + * Allows Auto-Focusing of the Fluid Interface Configuration Terminal. Allows Not Saving Searches. + */ +@Mixin(value = GuiFluidInterfaceConfigurationTerminal.class, remap = false) +public abstract class GuiFluidInterfaceConfigurationTerminalMixin extends AEBaseGui { + + @Shadow + private MEGuiTextField searchFieldInputs; + + /** + * Default Ignored Constructor + */ + public GuiFluidInterfaceConfigurationTerminalMixin(Container container) { + super(container); + } + + @Inject(method = "initGui", at = @At("RETURN"), remap = true) + private void focusGui(CallbackInfo ci) { + searchFieldInputs.setFocused(LabsConfig.modIntegration.ae2TerminalOptions.autoFocusConfigFluidInterface); + if (!LabsConfig.modIntegration.ae2TerminalOptions.saveConfigInterfaceSearch) + searchFieldInputs.setText(""); + } +} diff --git a/src/main/java/com/nomiceu/nomilabs/mixin/ae2/GuiFluidTerminalMixin.java b/src/main/java/com/nomiceu/nomilabs/mixin/ae2/GuiFluidTerminalMixin.java new file mode 100644 index 00000000..5670d687 --- /dev/null +++ b/src/main/java/com/nomiceu/nomilabs/mixin/ae2/GuiFluidTerminalMixin.java @@ -0,0 +1,37 @@ +package com.nomiceu.nomilabs.mixin.ae2; + +import net.minecraft.inventory.Container; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import com.nomiceu.nomilabs.config.LabsConfig; + +import appeng.client.gui.AEBaseGui; +import appeng.client.gui.widgets.MEGuiTextField; +import appeng.fluids.client.gui.GuiFluidTerminal; + +/** + * Allows Auto-Focusing Fluid Terminal.A + */ +@Mixin(value = GuiFluidTerminal.class, remap = false) +public abstract class GuiFluidTerminalMixin extends AEBaseGui { + + @Shadow + private MEGuiTextField searchField; + + /** + * Default Ignored Constructor + */ + public GuiFluidTerminalMixin(Container container) { + super(container); + } + + @Inject(method = "initGui", at = @At("RETURN"), remap = true) + private void focusGui(CallbackInfo ci) { + searchField.setFocused(LabsConfig.modIntegration.ae2TerminalOptions.autoFocusFluid); + } +} diff --git a/src/main/java/com/nomiceu/nomilabs/mixin/ae2/GuiInterfaceConfigurationTerminalMixin.java b/src/main/java/com/nomiceu/nomilabs/mixin/ae2/GuiInterfaceConfigurationTerminalMixin.java new file mode 100644 index 00000000..30e8348c --- /dev/null +++ b/src/main/java/com/nomiceu/nomilabs/mixin/ae2/GuiInterfaceConfigurationTerminalMixin.java @@ -0,0 +1,39 @@ +package com.nomiceu.nomilabs.mixin.ae2; + +import net.minecraft.inventory.Container; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import com.nomiceu.nomilabs.config.LabsConfig; + +import appeng.client.gui.AEBaseGui; +import appeng.client.gui.implementations.GuiInterfaceConfigurationTerminal; +import appeng.client.gui.widgets.MEGuiTextField; + +/** + * Allows Auto-Focusing of the Interface Configuration Terminal. Allows Not Saving Searches. + */ +@Mixin(value = GuiInterfaceConfigurationTerminal.class, remap = false) +public abstract class GuiInterfaceConfigurationTerminalMixin extends AEBaseGui { + + @Shadow + private MEGuiTextField searchFieldInputs; + + /** + * Default Ignored Constructor + */ + public GuiInterfaceConfigurationTerminalMixin(Container container) { + super(container); + } + + @Inject(method = "initGui", at = @At("RETURN"), remap = true) + private void focusGui(CallbackInfo ci) { + searchFieldInputs.setFocused(LabsConfig.modIntegration.ae2TerminalOptions.autoFocusConfigInterface); + if (!LabsConfig.modIntegration.ae2TerminalOptions.saveConfigInterfaceSearch) + searchFieldInputs.setText(""); + } +} diff --git a/src/main/java/com/nomiceu/nomilabs/mixin/ae2/GuiInterfaceTerminalMixin.java b/src/main/java/com/nomiceu/nomilabs/mixin/ae2/GuiInterfaceTerminalMixin.java new file mode 100644 index 00000000..558e11dd --- /dev/null +++ b/src/main/java/com/nomiceu/nomilabs/mixin/ae2/GuiInterfaceTerminalMixin.java @@ -0,0 +1,42 @@ +package com.nomiceu.nomilabs.mixin.ae2; + +import net.minecraft.inventory.Container; + +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +import com.nomiceu.nomilabs.config.LabsConfig; + +import appeng.client.gui.AEBaseGui; +import appeng.client.gui.implementations.GuiInterfaceTerminal; +import appeng.client.gui.widgets.MEGuiTooltipTextField; + +/** + * Focuses the Interface Terminal on entry, so that keybinds (like Bogosort Cfg Keybind) doesn't register. + */ +@Mixin(value = GuiInterfaceTerminal.class, remap = false) +public abstract class GuiInterfaceTerminalMixin extends AEBaseGui { + + @Shadow + @Final + private MEGuiTooltipTextField searchFieldNames; + + /** + * Default Ignored Constructor + */ + public GuiInterfaceTerminalMixin(Container container) { + super(container); + } + + @Inject(method = "initGui", at = @At("RETURN"), remap = true) + private void focusGui(CallbackInfo ci) { + searchFieldNames.setFocused(LabsConfig.modIntegration.ae2TerminalOptions.autoFocusInterface); + // Since its focused by default, we need to manually focus GUI + if (LabsConfig.modIntegration.ae2TerminalOptions.autoFocusInterface) + setFocused(true); + } +} diff --git a/src/main/resources/assets/nomilabs/lang/en_us.lang b/src/main/resources/assets/nomilabs/lang/en_us.lang index b4d796f0..54e2e744 100644 --- a/src/main/resources/assets/nomilabs/lang/en_us.lang +++ b/src/main/resources/assets/nomilabs/lang/en_us.lang @@ -62,6 +62,13 @@ config.nomilabs.mod_integration.effortlessbuilding.blocks.2=Max Blocks Placed (2 config.nomilabs.mod_integration.effortlessbuilding.blocks.3=Max Blocks Placed (3 Upgrades) config.nomilabs.mod_integration.effortlessbuilding.blocks.creative=Max Blocks Placed (Creative) +config.nomilabs.mod_integration.ae2_terminal=AE2 Terminal Options +config.nomilabs.mod_integration.ae2_terminal.fluid=Fluid Terminal Auto-Focusing +config.nomilabs.mod_integration.ae2_terminal.interface=Interface Terminal Auto-Focusing +config.nomilabs.mod_integration.ae2_terminal.cfg_interface=Interface Configuration Terminal Auto-Focusing +config.nomilabs.mod_integration.ae2_terminal.cfg_fluid_interface=Fluid Interface Configuration Terminal Auto-Focusing +config.nomilabs.mod_integration.ae2_terminal.cfg_interface_save=Save Interface Configuration Terminal Searches + config.nomilabs.groovy=GroovyScript Extensions and Script Helper Settings config.nomilabs.groovy.tooltip=GroovyScript Extensions and Script Helper Settings config.nomilabs.groovy.hand=Enable GroovyScript Hand Command Additions diff --git a/src/main/resources/mixins.nomilabs.appliedenergistics2.json b/src/main/resources/mixins.nomilabs.appliedenergistics2.json index 4293af1d..b52b064d 100644 --- a/src/main/resources/mixins.nomilabs.appliedenergistics2.json +++ b/src/main/resources/mixins.nomilabs.appliedenergistics2.json @@ -8,7 +8,11 @@ "InscriberRecipeMixin" ], "client": [ - "AEBaseGuiMixin" + "AEBaseGuiMixin", + "GuiFluidInterfaceConfigurationTerminalMixin", + "GuiFluidTerminalMixin", + "GuiInterfaceConfigurationTerminalMixin", + "GuiInterfaceTerminalMixin" ], "server": [] }