GUI Refactoring and consolidation

This commit is contained in:
Sebastian Hartte
2020-06-14 18:00:02 +02:00
parent 9b19f5b0e2
commit fd7ed5bbf0
53 changed files with 1000 additions and 974 deletions
@@ -19,9 +19,7 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.client.gui.widget.button.Button;
import appeng.client.gui.widgets.GuiActionButton;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.fml.client.gui.GuiUtils;
@@ -35,20 +33,17 @@ import appeng.api.config.FuzzyMode;
import appeng.api.config.Settings;
import appeng.api.config.Upgrades;
import appeng.api.implementations.items.IUpgradeModule;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiSettingToggleButton;
import appeng.client.gui.widgets.GuiToggleButton;
import appeng.container.implementations.ContainerCellWorkbench;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.util.Platform;
public class GuiCellWorkbench extends GuiUpgradeable<ContainerCellWorkbench>
{
private GuiImgButton clear;
private GuiImgButton partition;
private GuiToggleButton copyMode;
public GuiCellWorkbench(ContainerCellWorkbench container, PlayerInventory playerInventory, ITextComponent title) {
@@ -59,16 +54,11 @@ public class GuiCellWorkbench extends GuiUpgradeable<ContainerCellWorkbench>
@Override
protected void addButtons()
{
this.clear = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.ACTIONS, ActionItems.CLOSE, this::actionPerformed );
this.partition = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.ACTIONS, ActionItems.WRENCH, this::actionPerformed );
this.copyMode = new GuiToggleButton( this.guiLeft - 18, this.guiTop + 48, 11 * 16 + 5, 12 * 16 + 5, GuiText.CopyMode.getLocal(), GuiText.CopyModeDesc
.getLocal(), this::actionPerformed );
this.fuzzyMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 68, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL, this::actionPerformed );
this.addButton( this.fuzzyMode );
this.addButton( this.partition );
this.addButton( this.clear );
this.addButton( this.copyMode );
this.fuzzyMode = this.addButton( new GuiSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 68, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL, this::toggleFuzzyMode ) );
this.addButton(new GuiActionButton(this.guiLeft - 18, this.guiTop + 28, ActionItems.WRENCH, act1 -> action("Partition")));
this.addButton(new GuiActionButton(this.guiLeft - 18, this.guiTop + 8, ActionItems.CLOSE, act -> action("Clear")));
this.copyMode = this.addButton( new GuiToggleButton( this.guiLeft - 18, this.guiTop + 48, 11 * 16 + 5, 12 * 16 + 5, GuiText.CopyMode.getLocal(), GuiText.CopyModeDesc
.getLocal(), act -> action("CopyMode") ) );
}
@Override
@@ -166,33 +156,13 @@ public class GuiCellWorkbench extends GuiUpgradeable<ContainerCellWorkbench>
return GuiText.CellWorkbench;
}
@Override
protected void actionPerformed( final Button btn )
{
if( btn == this.copyMode )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "CellWorkbench.Action", "CopyMode" ) );
}
else if( btn == this.partition )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "CellWorkbench.Action", "Partition" ) );
}
else if( btn == this.clear )
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( "CellWorkbench.Action", "Clear" ) );
}
else if( btn == this.fuzzyMode )
{
final boolean backwards = minecraft.mouseHelper.isRightDown();
FuzzyMode fz = (FuzzyMode) this.fuzzyMode.getCurrentValue();
fz = Platform.rotateEnum( fz, backwards, Settings.FUZZY_MODE.getPossibleValues() );
NetworkHandler.instance().sendToServer( new PacketValueConfig( "CellWorkbench.Fuzzy", fz.name() ) );
}
else
{
super.actionPerformed( btn );
}
private void action(String type) {
NetworkHandler.instance().sendToServer( new PacketValueConfig( "CellWorkbench.Action", type ) );
}
private void toggleFuzzyMode(GuiSettingToggleButton<FuzzyMode> button, boolean backwards) {
FuzzyMode fz = button.getNextValue(backwards);
NetworkHandler.instance().sendToServer( new PacketValueConfig( "CellWorkbench.Fuzzy", fz.name() ) );
}
}
@@ -19,6 +19,8 @@
package appeng.client.gui.implementations;
import appeng.api.config.CondenserOutput;
import appeng.client.gui.widgets.GuiServerSettingToggleButton;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.fml.client.gui.GuiUtils;
@@ -26,20 +28,17 @@ import net.minecraft.entity.player.PlayerInventory;
import appeng.api.config.Settings;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiSettingToggleButton;
import appeng.client.gui.widgets.GuiProgressBar;
import appeng.client.gui.widgets.GuiProgressBar.Direction;
import appeng.container.implementations.ContainerCondenser;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
public class GuiCondenser extends AEBaseGui<ContainerCondenser>
{
private GuiProgressBar pb;
private GuiImgButton mode;
private GuiSettingToggleButton<CondenserOutput> mode;
public GuiCondenser(ContainerCondenser container, PlayerInventory playerInventory, ITextComponent title) {
super(container, playerInventory, title);
@@ -51,15 +50,10 @@ public class GuiCondenser extends AEBaseGui<ContainerCondenser>
{
super.init();
this.pb = new GuiProgressBar( this.container, "guis/condenser.png", 120 + this.guiLeft, 25 + this.guiTop, 178, 25, 6, 18, Direction.VERTICAL, GuiText.StoredEnergy
.getLocal() );
this.mode = new GuiServerSettingToggleButton<>( 128 + this.guiLeft, 52 + this.guiTop, Settings.CONDENSER_OUTPUT, this.container.getOutput());
this.mode = new GuiImgButton( 128 + this.guiLeft, 52 + this.guiTop, Settings.CONDENSER_OUTPUT, this.container.getOutput(), btn -> {
final boolean backwards = minecraft.mouseHelper.isRightDown();
NetworkHandler.instance().sendToServer( new PacketConfigButton( Settings.CONDENSER_OUTPUT, backwards ) );
} );
this.addButton( this.pb );
this.addButton(new GuiProgressBar(this.container, "guis/condenser.png", 120 + this.guiLeft, 25 + this.guiTop, 178, 25, 6, 18, Direction.VERTICAL, GuiText.StoredEnergy
.getLocal()));
this.addButton( this.mode );
}
@@ -19,11 +19,12 @@
package appeng.client.gui.implementations;
import appeng.client.gui.widgets.GuiActionButton;
import net.minecraft.entity.player.PlayerInventory;
import appeng.api.config.ActionItems;
import appeng.api.config.Settings;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiSettingToggleButton;
import appeng.container.implementations.ContainerCraftingTerm;
import appeng.container.slot.SlotCraftingMatrix;
import appeng.core.localization.GuiText;
@@ -63,7 +64,7 @@ public class GuiCraftingTerm extends GuiMEMonitorable<ContainerCraftingTerm>
public void init()
{
super.init();
GuiImgButton clearBtn = this.addButton( new GuiImgButton( this.guiLeft + 92, this.guiTop + this.ySize - 156, Settings.ACTIONS, ActionItems.STASH, btn -> clear() ));
GuiActionButton clearBtn = this.addButton( new GuiActionButton( this.guiLeft + 92, this.guiTop + this.ySize - 156, ActionItems.STASH, btn -> clear() ));
clearBtn.setHalfSize( true );
}
@@ -22,13 +22,13 @@ package appeng.client.gui.implementations;
import appeng.api.config.FuzzyMode;
import appeng.api.config.Settings;
import appeng.api.config.YesNo;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiServerSettingToggleButton;
import appeng.client.gui.widgets.GuiSettingToggleButton;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.implementations.ContainerFormationPlane;
import appeng.container.implementations.ContainerPriority;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.core.sync.packets.PacketSwitchGuis;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.text.ITextComponent;
@@ -37,7 +37,7 @@ import net.minecraft.util.text.ITextComponent;
public class GuiFormationPlane extends GuiUpgradeable<ContainerFormationPlane>
{
private GuiImgButton placeMode;
private GuiSettingToggleButton<YesNo> placeMode;
public GuiFormationPlane(ContainerFormationPlane container, PlayerInventory playerInventory, ITextComponent title) {
super(container, playerInventory, title);
@@ -47,8 +47,8 @@ public class GuiFormationPlane extends GuiUpgradeable<ContainerFormationPlane>
@Override
protected void addButtons()
{
this.placeMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.PLACE_BLOCK, YesNo.YES, btn -> selectNextPlaceMode() );
this.fuzzyMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 48, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL, this::actionPerformed );
this.placeMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 28, Settings.PLACE_BLOCK, YesNo.YES );
this.fuzzyMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 48, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
this.addButton( new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRenderer, btn -> openPriorityGui() ) );
@@ -83,9 +83,4 @@ public class GuiFormationPlane extends GuiUpgradeable<ContainerFormationPlane>
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( ContainerPriority.TYPE ) );
}
private void selectNextPlaceMode() {
final boolean backwards = minecraft.mouseHelper.isRightDown();
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.placeMode.getSetting(), backwards ) );
}
}
@@ -25,11 +25,10 @@ import appeng.api.config.OperationMode;
import appeng.api.config.RedstoneMode;
import appeng.api.config.Settings;
import appeng.api.definitions.IDefinitions;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiServerSettingToggleButton;
import appeng.client.gui.widgets.GuiSettingToggleButton;
import appeng.container.implementations.ContainerIOPort;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import net.minecraft.entity.player.PlayerInventory;
import net.minecraft.util.text.ITextComponent;
@@ -37,8 +36,8 @@ import net.minecraft.util.text.ITextComponent;
public class GuiIOPort extends GuiUpgradeable<ContainerIOPort>
{
private GuiImgButton fullMode;
private GuiImgButton operationMode;
private GuiSettingToggleButton<FullnessMode> fullMode;
private GuiSettingToggleButton<OperationMode> operationMode;
public GuiIOPort(ContainerIOPort container, PlayerInventory playerInventory, ITextComponent title) {
super(container, playerInventory, title);
@@ -48,13 +47,13 @@ public class GuiIOPort extends GuiUpgradeable<ContainerIOPort>
@Override
protected void addButtons()
{
this.redstoneMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE, this::actionPerformed);
this.fullMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.FULLNESS_MODE, FullnessMode.EMPTY, btn -> selectNextFullMode() );
this.operationMode = new GuiImgButton( this.guiLeft + 80, this.guiTop + 17, Settings.OPERATION_MODE, OperationMode.EMPTY, btn -> selectNextOperationMode() );
this.fullMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 8, Settings.FULLNESS_MODE, FullnessMode.EMPTY );
this.operationMode = new GuiServerSettingToggleButton<>( this.guiLeft + 80, this.guiTop + 17, Settings.OPERATION_MODE, OperationMode.EMPTY );
this.addButton( this.operationMode );
this.addButton( this.redstoneMode );
this.addButton( this.fullMode );
this.redstoneMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 28, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
addButton(this.redstoneMode);
}
@Override
@@ -97,14 +96,4 @@ public class GuiIOPort extends GuiUpgradeable<ContainerIOPort>
return "guis/io_port.png";
}
private void selectNextFullMode() {
final boolean backwards = minecraft.mouseHelper.isRightDown();
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.fullMode.getSetting(), backwards ) );
}
private void selectNextOperationMode() {
final boolean backwards = minecraft.mouseHelper.isRightDown();
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.operationMode.getSetting(), backwards ) );
}
}
@@ -21,7 +21,8 @@ package appeng.client.gui.implementations;
import appeng.api.config.Settings;
import appeng.api.config.YesNo;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiServerSettingToggleButton;
import appeng.client.gui.widgets.GuiSettingToggleButton;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.gui.widgets.GuiToggleButton;
import appeng.container.implementations.ContainerInterface;
@@ -37,7 +38,7 @@ import net.minecraft.util.text.ITextComponent;
public class GuiInterface extends GuiUpgradeable<ContainerInterface>
{
private GuiImgButton blockMode;
private GuiSettingToggleButton<YesNo> blockMode;
private GuiToggleButton interfaceMode;
public GuiInterface(ContainerInterface container, PlayerInventory playerInventory, ITextComponent title) {
@@ -50,7 +51,7 @@ public class GuiInterface extends GuiUpgradeable<ContainerInterface>
{
this.addButton( new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRenderer, btn -> openPriorityGui() ) );
this.blockMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.BLOCK, YesNo.NO, btn -> selectNextBlockMode() );
this.blockMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 8, Settings.BLOCK, YesNo.NO );
this.addButton( this.blockMode);
this.interfaceMode = new GuiToggleButton( this.guiLeft - 18, this.guiTop + 26, 84, 85, GuiText.InterfaceTerminal
@@ -90,13 +91,8 @@ public class GuiInterface extends GuiUpgradeable<ContainerInterface>
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( ContainerPriority.TYPE ) );
}
private void selectNextBlockMode() {
final boolean backwards = minecraft.mouseHelper.isRightDown();
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.blockMode.getSetting(), backwards ) );
}
private void selectNextInterfaceMode() {
final boolean backwards = minecraft.mouseHelper.isRightDown();
final boolean backwards = getMinecraft().mouseHelper.isRightDown();
NetworkHandler.instance().sendToServer( new PacketConfigButton( Settings.INTERFACE_TERMINAL, backwards ) );
}
@@ -19,8 +19,7 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import appeng.client.gui.widgets.GuiServerSettingToggleButton;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.client.util.InputMappings;
import net.minecraft.util.text.ITextComponent;
@@ -33,14 +32,12 @@ import appeng.api.config.RedstoneMode;
import appeng.api.config.Settings;
import appeng.api.config.Upgrades;
import appeng.api.config.YesNo;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiSettingToggleButton;
import appeng.client.gui.widgets.GuiNumberBox;
import appeng.container.implementations.ContainerLevelEmitter;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.core.sync.packets.PacketValueConfig;
@@ -58,8 +55,8 @@ public class GuiLevelEmitter extends GuiUpgradeable<ContainerLevelEmitter>
private Button minus100;
private Button minus1000;
private GuiImgButton levelMode;
private GuiImgButton craftingMode;
private GuiSettingToggleButton<LevelType> levelMode;
private GuiSettingToggleButton<YesNo> craftingMode;
public GuiLevelEmitter(ContainerLevelEmitter container, PlayerInventory playerInventory, ITextComponent title) {
super(container, playerInventory, title);
@@ -82,10 +79,10 @@ public class GuiLevelEmitter extends GuiUpgradeable<ContainerLevelEmitter>
@Override
protected void addButtons()
{
this.levelMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL, btn -> selectNextLevelMode() );
this.redstoneMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL, this::actionPerformed );
this.fuzzyMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 48, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL, this::actionPerformed );
this.craftingMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 48, Settings.CRAFT_VIA_REDSTONE, YesNo.NO, btn -> selectNextCraftingMode() );
this.levelMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 8, Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL );
this.redstoneMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 28, Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL );
this.fuzzyMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 48, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
this.craftingMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 48, Settings.CRAFT_VIA_REDSTONE, YesNo.NO );
final int a = AEConfig.instance().levelByStackAmounts( 0 );
final int b = AEConfig.instance().levelByStackAmounts( 1 );
@@ -104,7 +101,6 @@ public class GuiLevelEmitter extends GuiUpgradeable<ContainerLevelEmitter>
this.addButton( this.levelMode );
this.addButton( this.redstoneMode );
this.addButton( this.fuzzyMode );
this.addButton( this.craftingMode );
}
@@ -165,16 +161,6 @@ public class GuiLevelEmitter extends GuiUpgradeable<ContainerLevelEmitter>
return GuiText.LevelEmitter;
}
private void selectNextCraftingMode() {
final boolean backwards = minecraft.mouseHelper.isRightDown();
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.craftingMode.getSetting(), backwards ) );
}
private void selectNextLevelMode() {
final boolean backwards = minecraft.mouseHelper.isRightDown();
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.levelMode.getSetting(), backwards ) );
}
private void addQty( final long i )
{
try
@@ -19,11 +19,11 @@
package appeng.client.gui.implementations;
import appeng.client.gui.widgets.GuiServerSettingToggleButton;
import net.minecraft.entity.player.PlayerInventory;
import appeng.api.config.RedstoneMode;
import appeng.api.config.Settings;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiProgressBar;
import appeng.client.gui.widgets.GuiProgressBar.Direction;
import appeng.container.implementations.ContainerMAC;
@@ -53,8 +53,8 @@ public class GuiMAC extends GuiUpgradeable<ContainerMAC>
@Override
protected void addButtons()
{
this.redstoneMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE, this::actionPerformed );
this.addButton( this.redstoneMode );
this.redstoneMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 8, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
addButton(this.redstoneMode);
}
@Override
@@ -24,7 +24,7 @@ import java.util.List;
import appeng.api.config.*;
import appeng.container.implementations.ContainerCraftingStatus;
import appeng.integration.abstraction.JEIFacade;
import net.minecraft.client.gui.widget.button.Button;
import appeng.util.Platform;
import net.minecraft.client.util.InputMappings;
import net.minecraft.inventory.container.Slot;
import net.minecraft.util.text.ITextComponent;
@@ -41,7 +41,7 @@ import appeng.api.util.IConfigManager;
import appeng.api.util.IConfigurableObject;
import appeng.client.ActionKey;
import appeng.client.gui.AEBaseMEGui;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiSettingToggleButton;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.client.gui.widgets.ISortSource;
@@ -63,7 +63,6 @@ import appeng.helpers.WirelessTerminalGuiObject;
import appeng.parts.reporting.AbstractPartTerminal;
import appeng.tile.misc.TileSecurityStation;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
import org.lwjgl.glfw.GLFW;
@@ -89,11 +88,9 @@ public class GuiMEMonitorable<T extends ContainerMEMonitorable> extends AEBaseME
private int rows = 0;
private int maxRows = Integer.MAX_VALUE;
private int standardSize;
private GuiImgButton ViewBox;
private GuiImgButton SortByBox;
private GuiImgButton SortDirBox;
private GuiImgButton searchBoxSettings;
private GuiImgButton terminalStyleBox;
private GuiSettingToggleButton<ViewItems> viewModeToggle;
private GuiSettingToggleButton<SortOrder> sortByToggle;
private GuiSettingToggleButton<SortDir> sortDirToggle;
private boolean isAutoFocus = false;
private int currentMouseX = 0;
private int currentMouseY = 0;
@@ -165,62 +162,19 @@ public class GuiMEMonitorable<T extends ContainerMEMonitorable> extends AEBaseME
NetworkHandler.instance().sendToServer( new PacketSwitchGuis(ContainerCraftingStatus.TYPE) );
}
protected void actionPerformed( final Button btn )
{
if( btn instanceof GuiImgButton )
{
final boolean backwards = minecraft.mouseHelper.isRightDown();
final GuiImgButton iBtn = (GuiImgButton) btn;
if( iBtn.getSetting() != Settings.ACTIONS )
{
final Enum cv = iBtn.getCurrentValue();
final Enum next = Platform.rotateEnum( cv, backwards, iBtn.getSetting().getPossibleValues() );
if( btn == this.terminalStyleBox )
{
AEConfig.instance().getConfigManager().putSetting( iBtn.getSetting(), next );
}
else if( btn == this.searchBoxSettings )
{
AEConfig.instance().getConfigManager().putSetting( iBtn.getSetting(), next );
}
else
{
NetworkHandler.instance().sendToServer( new PacketValueConfig( iBtn.getSetting().name(), next.name() ) );
}
iBtn.set( next );
if( next.getClass() == SearchBoxMode.class || next.getClass() == TerminalStyle.class )
{
this.reinitalize();
}
}
}
}
private void reinitalize()
{
this.buttons.clear();
this.init();
}
@Override
public void init()
{
minecraft.keyboardListener.enableRepeatEvents( true );
getMinecraft().keyboardListener.enableRepeatEvents( true );
this.maxRows = this.getMaxRows();
this.perRow = AEConfig.instance()
.getConfigManager()
.getSetting(
Settings.TERMINAL_STYLE ) != TerminalStyle.FULL ? 9 : 9 + ( ( this.width - this.standardSize ) / 18 );
TerminalStyle terminalStyle = (TerminalStyle) AEConfig.instance().getConfigManager().getSetting(Settings.TERMINAL_STYLE);
this.perRow = terminalStyle != TerminalStyle.FULL ? 9 : 9 + ( ( this.width - this.standardSize ) / 18 );
final int magicNumber = 114 + 1;
final int extraSpace = this.height - magicNumber - this.reservedSpace;
this.rows = (int) Math.floor( extraSpace / 18 );
this.rows = extraSpace / 18;
if( this.rows > this.maxRows )
{
this.rows = this.maxRows;
@@ -240,7 +194,7 @@ public class GuiMEMonitorable<T extends ContainerMEMonitorable> extends AEBaseME
}
}
if( AEConfig.instance().getConfigManager().getSetting( Settings.TERMINAL_STYLE ) != TerminalStyle.FULL )
if( terminalStyle != TerminalStyle.FULL )
{
this.xSize = this.standardSize + ( ( this.perRow - 9 ) * 18 );
}
@@ -263,33 +217,27 @@ public class GuiMEMonitorable<T extends ContainerMEMonitorable> extends AEBaseME
if( this.customSortOrder )
{
this.SortByBox = this.addButton( new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_BY, this.configSrc.getSetting( Settings.SORT_BY ), this::actionPerformed ) );
this.sortByToggle = this.addButton( new GuiSettingToggleButton<>( this.guiLeft - 18, offset, Settings.SORT_BY, getSortBy(), Platform::isSortOrderAvailable, this::toggleServerSetting ) );
offset += 20;
}
if( this.viewCell || this instanceof GuiWirelessTerm )
{
this.ViewBox = this.addButton( new GuiImgButton( this.guiLeft - 18, offset, Settings.VIEW_MODE, this.configSrc.getSetting( Settings.VIEW_MODE ), this::actionPerformed ) );
this.viewModeToggle = this.addButton( new GuiSettingToggleButton<>( this.guiLeft - 18, offset, Settings.VIEW_MODE, getSortDisplay(), this::toggleServerSetting ) );
offset += 20;
}
this.addButton( this.SortDirBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_DIRECTION, this.configSrc
.getSetting( Settings.SORT_DIRECTION ), this::actionPerformed ) );
this.addButton( this.sortDirToggle = new GuiSettingToggleButton<>( this.guiLeft - 18, offset, Settings.SORT_DIRECTION, getSortDir(), this::toggleServerSetting ) );
offset += 20;
this.addButton(
this.searchBoxSettings = new GuiImgButton( this.guiLeft - 18, offset, Settings.SEARCH_MODE, AEConfig.instance()
.getConfigManager()
.getSetting(
Settings.SEARCH_MODE ), this::actionPerformed ) );
SearchBoxMode searchMode = (SearchBoxMode) AEConfig.instance().getConfigManager().getSetting(Settings.SEARCH_MODE);
this.addButton(new GuiSettingToggleButton<>( this.guiLeft - 18, offset, Settings.SEARCH_MODE, searchMode, Platform::isSearchModeAvailable, this::toggleClientSetting));
offset += 20;
if( !( this instanceof GuiMEPortableCell ) || this instanceof GuiWirelessTerm )
{
this.addButton( this.terminalStyleBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.TERMINAL_STYLE, AEConfig.instance()
.getConfigManager()
.getSetting( Settings.TERMINAL_STYLE ), this::actionPerformed ) );
this.addButton( new GuiSettingToggleButton<>( this.guiLeft - 18, offset, Settings.TERMINAL_STYLE, terminalStyle, this::toggleClientSetting) );
}
this.searchField = new MEGuiTextField( this.font, this.guiLeft + Math.max( 80, this.offsetX ), this.guiTop + 4, 90, 12 );
@@ -306,11 +254,9 @@ public class GuiMEMonitorable<T extends ContainerMEMonitorable> extends AEBaseME
this.craftingStatusBtn.setHideEdge( 13 );
}
final Enum searchModeSetting = AEConfig.instance().getConfigManager().getSetting( Settings.SEARCH_MODE );
this.isAutoFocus = SearchBoxMode.AUTOSEARCH == searchModeSetting || SearchBoxMode.JEI_AUTOSEARCH == searchModeSetting || SearchBoxMode.AUTOSEARCH_KEEP == searchModeSetting || SearchBoxMode.JEI_AUTOSEARCH_KEEP == searchModeSetting;
final boolean isKeepFilter = SearchBoxMode.AUTOSEARCH_KEEP == searchModeSetting || SearchBoxMode.JEI_AUTOSEARCH_KEEP == searchModeSetting || SearchBoxMode.MANUAL_SEARCH_KEEP == searchModeSetting || SearchBoxMode.JEI_MANUAL_SEARCH_KEEP == searchModeSetting;
final boolean isJEIEnabled = SearchBoxMode.JEI_AUTOSEARCH == searchModeSetting || SearchBoxMode.JEI_MANUAL_SEARCH == searchModeSetting;
this.isAutoFocus = SearchBoxMode.AUTOSEARCH == searchMode || SearchBoxMode.JEI_AUTOSEARCH == searchMode || SearchBoxMode.AUTOSEARCH_KEEP == searchMode || SearchBoxMode.JEI_AUTOSEARCH_KEEP == searchMode;
final boolean isKeepFilter = SearchBoxMode.AUTOSEARCH_KEEP == searchMode || SearchBoxMode.JEI_AUTOSEARCH_KEEP == searchMode || SearchBoxMode.MANUAL_SEARCH_KEEP == searchMode || SearchBoxMode.JEI_MANUAL_SEARCH_KEEP == searchMode;
final boolean isJEIEnabled = SearchBoxMode.JEI_AUTOSEARCH == searchMode || SearchBoxMode.JEI_MANUAL_SEARCH == searchMode;
this.searchField.setFocused2( this.isAutoFocus );
@@ -386,7 +332,7 @@ public class GuiMEMonitorable<T extends ContainerMEMonitorable> extends AEBaseME
public void removed()
{
super.removed();
minecraft.keyboardListener.enableRepeatEvents( false );
getMinecraft().keyboardListener.enableRepeatEvents( false );
memoryText = this.searchField.getText();
}
@@ -464,13 +410,12 @@ public class GuiMEMonitorable<T extends ContainerMEMonitorable> extends AEBaseME
return true;
}
final boolean mouseInGui = this.isMouseOver( this.currentMouseX, this.currentMouseY );
if( this.isAutoFocus && !this.searchField.isFocused() && mouseInGui )
if( this.isAutoFocus && !this.searchField.isFocused() && isHovered() )
{
this.searchField.setFocused2( true );
}
if (this.searchField.charTyped(character, p_charTyped_2_)) {
if (this.searchField.isFocused() && this.searchField.charTyped(character, p_charTyped_2_)) {
this.repo.setSearchString( this.searchField.getText() );
this.repo.updateView();
this.setScrollBar();
@@ -486,26 +431,31 @@ public class GuiMEMonitorable<T extends ContainerMEMonitorable> extends AEBaseME
InputMappings.Input input = InputMappings.getInputByCode(keyCode, scanCode);
if( !this.checkHotbarKeys(input) )
if( keyCode != GLFW.GLFW_KEY_ESCAPE && !this.checkHotbarKeys(input) )
{
if( AppEng.proxy.isActionKey( ActionKey.TOGGLE_FOCUS, input ) )
{
this.searchField.setFocused2( !this.searchField.isFocused() );
return true;
}
if( this.searchField.isFocused() && keyCode == GLFW.GLFW_KEY_ENTER )
{
this.searchField.setFocused2( false );
return true;
if (!this.searchField.isFocused() && this.isAutoFocus && isHovered()) {
this.searchField.setFocused2(true);
}
if( this.searchField.keyPressed( keyCode, scanCode, p_keyPressed_3_ ) )
{
this.repo.setSearchString( this.searchField.getText() );
this.repo.updateView();
this.setScrollBar();
// tell forge the key event is handled and should not be sent out
if (this.searchField.isFocused()) {
if (keyCode == GLFW.GLFW_KEY_ENTER) {
this.searchField.setFocused2(false);
return true;
}
if (this.searchField.keyPressed(keyCode, scanCode, p_keyPressed_3_)) {
this.repo.setSearchString(this.searchField.getText());
this.repo.updateView();
this.setScrollBar();
}
// We need to swallow key presses if the field is focused because typing 'e' would otherwise close
// the screen
return true;
}
}
@@ -513,6 +463,10 @@ public class GuiMEMonitorable<T extends ContainerMEMonitorable> extends AEBaseME
return super.keyPressed(keyCode, scanCode, p_keyPressed_3_);
}
private boolean isHovered() {
return isPointInRegion(0, 0, this.xSize, this.ySize, currentMouseX, currentMouseY);
}
@Override
public void tick()
{
@@ -539,21 +493,21 @@ public class GuiMEMonitorable<T extends ContainerMEMonitorable> extends AEBaseME
}
@Override
public void updateSetting( final IConfigManager manager, final Enum settingName, final Enum newValue )
public void updateSetting(final IConfigManager manager, final Settings settingName, final Enum<?> newValue )
{
if( this.SortByBox != null )
if( this.sortByToggle != null )
{
this.SortByBox.set( this.configSrc.getSetting( Settings.SORT_BY ) );
this.sortByToggle.set( getSortBy() );
}
if( this.SortDirBox != null )
if( this.sortDirToggle != null )
{
this.SortDirBox.set( this.configSrc.getSetting( Settings.SORT_DIRECTION ) );
this.sortDirToggle.set( getSortDir() );
}
if( this.ViewBox != null )
if( this.viewModeToggle != null )
{
this.ViewBox.set( this.configSrc.getSetting( Settings.VIEW_MODE ) );
this.viewModeToggle.set( getSortDisplay() );
}
this.repo.updateView();
@@ -588,4 +542,24 @@ public class GuiMEMonitorable<T extends ContainerMEMonitorable> extends AEBaseME
{
this.standardSize = standardSize;
}
private <S extends Enum<S>> void toggleClientSetting(GuiSettingToggleButton<S> btn, boolean backwards) {
S next = btn.getNextValue(backwards);
AEConfig.instance().getConfigManager().putSetting( btn.getSetting(), next );
btn.set( next );
this.reinitalize();
}
private <S extends Enum<S>> void toggleServerSetting(GuiSettingToggleButton<S> btn, boolean backwards) {
S next = btn.getNextValue(backwards);
NetworkHandler.instance().sendToServer( new PacketValueConfig( btn.getSetting().name(), next.name() ) );
btn.set( next );
}
private void reinitalize()
{
this.buttons.clear();
this.init();
}
}
@@ -19,19 +19,17 @@
package appeng.client.gui.implementations;
import appeng.api.config.Settings;
import appeng.api.config.SortDir;
import appeng.api.config.SortOrder;
import appeng.api.config.ViewItems;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.CommonButtons;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.gui.widgets.ISortSource;
import appeng.client.me.ItemRepo;
import appeng.client.me.SlotME;
import appeng.container.implementations.ContainerNetworkStatus;
import appeng.core.AEConfig;
import appeng.core.localization.GuiText;
import appeng.util.Platform;
import com.mojang.blaze3d.systems.RenderSystem;
@@ -49,7 +47,6 @@ public class GuiNetworkStatus extends AEBaseGui<ContainerNetworkStatus> implemen
private final ItemRepo repo;
private final int rows = 4;
private GuiImgButton units;
private int tooltip = -1;
public GuiNetworkStatus(ContainerNetworkStatus container, PlayerInventory playerInventory, ITextComponent title) {
@@ -68,14 +65,7 @@ public class GuiNetworkStatus extends AEBaseGui<ContainerNetworkStatus> implemen
{
super.init();
this.units = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.POWER_UNITS, AEConfig.instance().selectedPowerUnit(), btn -> selectNextUnit() );
this.addButton( this.units );
}
private void selectNextUnit() {
final boolean backwards = minecraft.mouseHelper.isRightDown();
AEConfig.instance().nextPowerUnit( backwards );
this.units.set( AEConfig.instance().selectedPowerUnit() );
this.addButton( CommonButtons.togglePowerUnit( this.guiLeft - 18, this.guiTop + 8 ) );
}
@Override
@@ -20,9 +20,9 @@ package appeng.client.gui.implementations;
import appeng.api.config.ActionItems;
import appeng.api.config.ItemSubstitution;
import appeng.api.config.Settings;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiActionButton;
import appeng.client.gui.widgets.GuiSettingToggleButton;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.implementations.ContainerPatternTerm;
import appeng.container.slot.AppEngSlot;
@@ -49,8 +49,8 @@ public class GuiPatternTerm extends GuiMEMonitorable<ContainerPatternTerm>
private GuiTabButton tabCraftButton;
private GuiTabButton tabProcessButton;
private GuiImgButton substitutionsEnabledBtn;
private GuiImgButton substitutionsDisabledBtn;
private GuiActionButton substitutionsEnabledBtn;
private GuiActionButton substitutionsDisabledBtn;
public GuiPatternTerm(ContainerPatternTerm container, PlayerInventory playerInventory, ITextComponent title) {
super(container, playerInventory, title);
@@ -70,19 +70,19 @@ public class GuiPatternTerm extends GuiMEMonitorable<ContainerPatternTerm>
.getLocal(), this.itemRenderer, btn -> toggleCraftMode(CRAFTMODE_CRFTING) );
this.addButton( this.tabProcessButton );
this.substitutionsEnabledBtn = new GuiImgButton( this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.ENABLED, btn -> toggleSubstitutions(SUBSITUTION_DISABLE) );
this.substitutionsEnabledBtn = new GuiActionButton( this.guiLeft + 84, this.guiTop + this.ySize - 163, ActionItems.ENABLE_SUBSTITUTION, act -> toggleSubstitutions(SUBSITUTION_DISABLE) );
this.substitutionsEnabledBtn.setHalfSize( true );
this.addButton( this.substitutionsEnabledBtn );
this.substitutionsDisabledBtn = new GuiImgButton( this.guiLeft + 84, this.guiTop + this.ySize - 163, Settings.ACTIONS, ItemSubstitution.DISABLED, btn -> toggleSubstitutions(SUBSITUTION_ENABLE) );
this.substitutionsDisabledBtn = new GuiActionButton( this.guiLeft + 84, this.guiTop + this.ySize - 163, ActionItems.DISABLE_SUBSTITUTION, act -> toggleSubstitutions(SUBSITUTION_ENABLE) );
this.substitutionsDisabledBtn.setHalfSize( true );
this.addButton( this.substitutionsDisabledBtn );
GuiImgButton clearBtn = new GuiImgButton(this.guiLeft + 74, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE, btn -> clear());
GuiActionButton clearBtn = new GuiActionButton(this.guiLeft + 74, this.guiTop + this.ySize - 163, ActionItems.CLOSE, act -> clear());
clearBtn.setHalfSize( true );
this.addButton(clearBtn);
GuiImgButton encodeBtn = new GuiImgButton(this.guiLeft + 147, this.guiTop + this.ySize - 142, Settings.ACTIONS, ActionItems.ENCODE, btn -> encode());
GuiActionButton encodeBtn = new GuiActionButton(this.guiLeft + 147, this.guiTop + this.ySize - 142, ActionItems.ENCODE, act -> encode());
this.addButton(encodeBtn);
}
@@ -19,11 +19,9 @@
package appeng.client.gui.implementations;
import appeng.api.config.Settings;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.CommonButtons;
import appeng.container.implementations.ContainerSpatialIOPort;
import appeng.core.AEConfig;
import appeng.core.localization.GuiText;
import appeng.util.Platform;
import net.minecraft.entity.player.PlayerInventory;
@@ -34,8 +32,6 @@ import net.minecraftforge.fml.client.gui.GuiUtils;
public class GuiSpatialIOPort extends AEBaseGui<ContainerSpatialIOPort>
{
private GuiImgButton units;
public GuiSpatialIOPort(ContainerSpatialIOPort container, PlayerInventory playerInventory, ITextComponent title) {
super(container, playerInventory, title);
this.ySize = 199;
@@ -45,15 +41,7 @@ public class GuiSpatialIOPort extends AEBaseGui<ContainerSpatialIOPort>
public void init()
{
super.init();
this.units = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.POWER_UNITS, AEConfig.instance().selectedPowerUnit(), btn -> selectNextUnit() );
this.addButton( this.units );
}
private void selectNextUnit() {
final boolean backwards = minecraft.mouseHelper.isRightDown();
AEConfig.instance().nextPowerUnit( backwards );
this.units.set( AEConfig.instance().selectedPowerUnit() );
this.addButton( CommonButtons.togglePowerUnit( this.guiLeft - 18, this.guiTop + 8 ) );
}
@Override
@@ -20,13 +20,14 @@ package appeng.client.gui.implementations;
import appeng.api.config.*;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiActionButton;
import appeng.client.gui.widgets.GuiServerSettingToggleButton;
import appeng.client.gui.widgets.GuiSettingToggleButton;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.implementations.ContainerPriority;
import appeng.container.implementations.ContainerStorageBus;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.core.sync.packets.PacketValueConfig;
import net.minecraft.entity.player.PlayerInventory;
@@ -36,8 +37,8 @@ import net.minecraft.util.text.ITextComponent;
public class GuiStorageBus extends GuiUpgradeable<ContainerStorageBus>
{
private GuiImgButton rwMode;
private GuiImgButton storageFilter;
private GuiSettingToggleButton<AccessRestriction> rwMode;
private GuiSettingToggleButton<StorageFilter> storageFilter;
public GuiStorageBus(ContainerStorageBus container, PlayerInventory playerInventory, ITextComponent title) {
super(container, playerInventory, title);
@@ -47,11 +48,11 @@ public class GuiStorageBus extends GuiUpgradeable<ContainerStorageBus>
@Override
protected void addButtons()
{
addButton( new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.ACTIONS, ActionItems.CLOSE, btn -> clear() ) );
addButton( new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.ACTIONS, ActionItems.WRENCH, btn -> partition() ) );
this.rwMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 48, Settings.ACCESS, AccessRestriction.READ_WRITE, btn -> toggleReadWriteMode() );
this.storageFilter = new GuiImgButton( this.guiLeft - 18, this.guiTop + 68, Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY, btn -> toggleStorageFilterMode() );
this.fuzzyMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 88, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL, this::actionPerformed );
addButton( new GuiActionButton( this.guiLeft - 18, this.guiTop + 8, ActionItems.CLOSE, btn -> clear() ) );
addButton( new GuiActionButton( this.guiLeft - 18, this.guiTop + 28, ActionItems.WRENCH, btn -> partition() ) );
this.rwMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 48, Settings.ACCESS, AccessRestriction.READ_WRITE );
this.storageFilter = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 68, Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY );
this.fuzzyMode = new GuiServerSettingToggleButton<>( this.guiLeft - 18, this.guiTop + 88, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
this.addButton( new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), this.itemRenderer, btn -> openPriorityGui() ) );
@@ -100,14 +101,4 @@ public class GuiStorageBus extends GuiUpgradeable<ContainerStorageBus>
NetworkHandler.instance().sendToServer( new PacketSwitchGuis( ContainerPriority.TYPE ) );
}
private void toggleReadWriteMode() {
final boolean backwards = minecraft.mouseHelper.isRightDown();
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.rwMode.getSetting(), backwards ) );
}
private void toggleStorageFilterMode() {
final boolean backwards = minecraft.mouseHelper.isRightDown();
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.storageFilter.getSetting(), backwards ) );
}
}
@@ -19,7 +19,7 @@
package appeng.client.gui.implementations;
import net.minecraft.client.gui.widget.button.Button;
import appeng.client.gui.widgets.GuiServerSettingToggleButton;
import net.minecraft.entity.player.PlayerInventory;
import appeng.api.config.FuzzyMode;
@@ -30,11 +30,9 @@ import appeng.api.config.Upgrades;
import appeng.api.config.YesNo;
import appeng.api.implementations.IUpgradeableHost;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiSettingToggleButton;
import appeng.container.implementations.ContainerUpgradeable;
import appeng.core.localization.GuiText;
import appeng.core.sync.network.NetworkHandler;
import appeng.core.sync.packets.PacketConfigButton;
import appeng.parts.automation.PartExportBus;
import appeng.parts.automation.PartImportBus;
import net.minecraft.util.text.ITextComponent;
@@ -47,10 +45,10 @@ public class GuiUpgradeable<T extends ContainerUpgradeable> extends AEBaseGui<T>
protected final ContainerUpgradeable cvb;
protected final IUpgradeableHost bc;
protected GuiImgButton redstoneMode;
protected GuiImgButton fuzzyMode;
protected GuiImgButton craftMode;
protected GuiImgButton schedulingMode;
protected GuiSettingToggleButton<RedstoneMode> redstoneMode;
protected GuiSettingToggleButton<FuzzyMode> fuzzyMode;
protected GuiSettingToggleButton<YesNo> craftMode;
protected GuiSettingToggleButton<SchedulingMode> schedulingMode;
public GuiUpgradeable(T container, PlayerInventory playerInventory, ITextComponent title) {
super(container, playerInventory, title);
@@ -75,15 +73,14 @@ public class GuiUpgradeable<T extends ContainerUpgradeable> extends AEBaseGui<T>
protected void addButtons()
{
this.redstoneMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE, this::actionPerformed );
this.fuzzyMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 28, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL, this::actionPerformed );
this.craftMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 48, Settings.CRAFT_ONLY, YesNo.NO, this::actionPerformed );
this.schedulingMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 68, Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT, this::actionPerformed );
this.addButton( this.craftMode );
this.addButton( this.redstoneMode );
this.addButton( this.fuzzyMode );
this.addButton( this.schedulingMode );
this.redstoneMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 8, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
addButton(this.redstoneMode);
this.fuzzyMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 28, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
addButton(this.fuzzyMode);
this.craftMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 48, Settings.CRAFT_ONLY, YesNo.NO );
addButton(this.craftMode);
this.schedulingMode = new GuiServerSettingToggleButton<>(this.guiLeft - 18, this.guiTop + 68, Settings.SCHEDULING_MODE, SchedulingMode.DEFAULT );
addButton(this.schedulingMode);
}
@Override
@@ -165,30 +162,4 @@ public class GuiUpgradeable<T extends ContainerUpgradeable> extends AEBaseGui<T>
return this.bc instanceof PartImportBus ? GuiText.ImportBus : GuiText.ExportBus;
}
// FIXME: replace with individual methods
protected void actionPerformed( final Button btn )
{
// Detect right-clicks
final boolean backwards = minecraft.mouseHelper.isRightDown();
if( btn == this.redstoneMode )
{
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.redstoneMode.getSetting(), backwards ) );
}
if( btn == this.craftMode )
{
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.craftMode.getSetting(), backwards ) );
}
if( btn == this.fuzzyMode )
{
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.fuzzyMode.getSetting(), backwards ) );
}
if( btn == this.schedulingMode )
{
NetworkHandler.instance().sendToServer( new PacketConfigButton( this.schedulingMode.getSetting(), backwards ) );
}
}
}
@@ -21,7 +21,8 @@ package appeng.client.gui.implementations;
import appeng.api.config.Settings;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.CommonButtons;
import appeng.client.gui.widgets.GuiSettingToggleButton;
import appeng.container.implementations.ContainerWireless;
import appeng.core.AEConfig;
import appeng.core.localization.GuiText;
@@ -34,8 +35,6 @@ import net.minecraftforge.fml.client.gui.GuiUtils;
public class GuiWireless extends AEBaseGui<ContainerWireless>
{
private GuiImgButton units;
public GuiWireless(ContainerWireless container, PlayerInventory playerInventory, ITextComponent title) {
super(container, playerInventory, title);
this.ySize = 166;
@@ -46,14 +45,7 @@ public class GuiWireless extends AEBaseGui<ContainerWireless>
{
super.init();
this.units = new GuiImgButton( this.guiLeft - 18, this.guiTop + 8, Settings.POWER_UNITS, AEConfig.instance().selectedPowerUnit(), btn -> toggleUnits() );
this.addButton( this.units );
}
private void toggleUnits() {
final boolean backwards = minecraft.mouseHelper.isRightDown();
AEConfig.instance().nextPowerUnit( backwards );
this.units.set( AEConfig.instance().selectedPowerUnit() );
this.addButton( CommonButtons.togglePowerUnit( this.guiLeft - 18, this.guiTop + 8 ) );
}
@Override