Skip to content

Commit

Permalink
Fix Auto-Focusing Terminals
Browse files Browse the repository at this point in the history
  • Loading branch information
IntegerLimit committed Oct 13, 2024
1 parent 76a801d commit 72058ae
Show file tree
Hide file tree
Showing 7 changed files with 199 additions and 1 deletion.
30 changes: 30 additions & 0 deletions src/main/java/com/nomiceu/nomilabs/config/LabsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
Original file line number Diff line number Diff line change
@@ -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("");
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
@@ -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("");
}
}
Original file line number Diff line number Diff line change
@@ -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);
}
}
7 changes: 7 additions & 0 deletions src/main/resources/assets/nomilabs/lang/en_us.lang
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/main/resources/mixins.nomilabs.appliedenergistics2.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
"InscriberRecipeMixin"
],
"client": [
"AEBaseGuiMixin"
"AEBaseGuiMixin",
"GuiFluidInterfaceConfigurationTerminalMixin",
"GuiFluidTerminalMixin",
"GuiInterfaceConfigurationTerminalMixin",
"GuiInterfaceTerminalMixin"
],
"server": []
}

0 comments on commit 72058ae

Please sign in to comment.