From d3c6f6074a653999f293089f2a263ba60099cac9 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Thu, 31 Jul 2014 20:59:24 -0500 Subject: [PATCH] Custom Level Emitter Buttons! --- .../gui/implementations/GuiLevelEmitter.java | 48 +++++++++---------- core/AEConfig.java | 10 ++++ 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/client/gui/implementations/GuiLevelEmitter.java b/client/gui/implementations/GuiLevelEmitter.java index 7bf8be59..c5b9a65b 100644 --- a/client/gui/implementations/GuiLevelEmitter.java +++ b/client/gui/implementations/GuiLevelEmitter.java @@ -15,6 +15,7 @@ import appeng.api.config.Settings; import appeng.api.config.Upgrades; import appeng.client.gui.widgets.GuiImgButton; import appeng.container.implementations.ContainerLevelEmitter; +import appeng.core.AEConfig; import appeng.core.AELog; import appeng.core.localization.GuiText; import appeng.core.sync.network.NetworkHandler; @@ -57,15 +58,20 @@ public class GuiLevelEmitter extends GuiUpgradeable redstoneMode = new GuiImgButton( this.guiLeft - 18, guiTop + 28, Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL ); fuzzyMode = new GuiImgButton( this.guiLeft - 18, guiTop + 48, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL ); - buttonList.add( plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 17, 22, 20, "+1" ) ); - buttonList.add( plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 17, 28, 20, "+10" ) ); - buttonList.add( plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 17, 32, 20, "+100" ) ); - buttonList.add( plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 17, 38, 20, "+1000" ) ); + int a = AEConfig.instance.levelByStackAmounts( 0 ); + int b = AEConfig.instance.levelByStackAmounts( 1 ); + int c = AEConfig.instance.levelByStackAmounts( 2 ); + int d = AEConfig.instance.levelByStackAmounts( 3 ); - buttonList.add( minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 59, 22, 20, "-1" ) ); - buttonList.add( minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 59, 28, 20, "-10" ) ); - buttonList.add( minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 59, 32, 20, "-100" ) ); - buttonList.add( minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 59, 38, 20, "-1000" ) ); + buttonList.add( plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 17, 22, 20, "+" + a ) ); + buttonList.add( plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 17, 28, 20, "+" + b ) ); + buttonList.add( plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 17, 32, 20, "+" + c ) ); + buttonList.add( plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 17, 38, 20, "+" + d ) ); + + buttonList.add( minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 59, 22, 20, "-" + a ) ); + buttonList.add( minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 59, 28, 20, "-" + b ) ); + buttonList.add( minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 59, 32, 20, "-" + c ) ); + buttonList.add( minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 59, 38, 20, "-" + d ) ); buttonList.add( levelMode ); buttonList.add( redstoneMode ); @@ -89,22 +95,16 @@ public class GuiLevelEmitter extends GuiUpgradeable AELog.error( e ); } - if ( btn == plus1 ) - addQty( 1 ); - if ( btn == plus10 ) - addQty( 10 ); - if ( btn == plus100 ) - addQty( 100 ); - if ( btn == plus1000 ) - addQty( 1000 ); - if ( btn == minus1 ) - addQty( -1 ); - if ( btn == minus10 ) - addQty( -10 ); - if ( btn == minus100 ) - addQty( -100 ); - if ( btn == minus1000 ) - addQty( -1000 ); + boolean isPlus = btn == plus1 || btn == plus10 || btn == plus100 || btn == plus1000; + boolean isMinus = btn == minus1 || btn == minus10 || btn == minus100 || btn == minus1000; + + if ( isPlus || isMinus ) + addQty( getQty( btn ) ); + } + + private int getQty(GuiButton btn) + { + return Integer.parseInt( btn.displayString ); } private void addQty(long i) diff --git a/core/AEConfig.java b/core/AEConfig.java index 08856432..8ee1b2bb 100644 --- a/core/AEConfig.java +++ b/core/AEConfig.java @@ -108,6 +108,7 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo public boolean useLargeFonts = false; public int[] craftByStacks = new int[] { 1, 10, 100, 1000 }; public int[] priorityByStacks = new int[] { 1, 10, 100, 1000 }; + public int[] levelByStacks = new int[] { 1, 10, 100, 1000 }; public int wireless_battery = 1600000; public int manipulator_battery = 200000; @@ -141,17 +142,21 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo { Property cmb = get( "Client", "craftAmtButton" + (btnNum + 1), craftByStacks[btnNum] ); Property pmb = get( "Client", "priorityAmtButton" + (btnNum + 1), priorityByStacks[btnNum] ); + Property lmb = get( "Client", "levelAmtButton" + (btnNum + 1), levelByStacks[btnNum] ); int buttonCap = (int) (Math.pow( 10, btnNum + 1 ) - 1); craftByStacks[btnNum] = Math.abs( cmb.getInt( craftByStacks[btnNum] ) ); priorityByStacks[btnNum] = Math.abs( pmb.getInt( priorityByStacks[btnNum] ) ); + levelByStacks[btnNum] = Math.abs( pmb.getInt( levelByStacks[btnNum] ) ); cmb.comment = "Controls buttons on Crafting Screen : Capped at " + buttonCap; pmb.comment = "Controls buttons on Priority Screen : Capped at " + buttonCap; + lmb.comment = "Controls buttons on Level Emitter Screen : Capped at " + buttonCap; craftByStacks[btnNum] = Math.min( craftByStacks[btnNum], buttonCap ); priorityByStacks[btnNum] = Math.min( priorityByStacks[btnNum], buttonCap ); + levelByStacks[btnNum] = Math.min( levelByStacks[btnNum], buttonCap ); } for (Enum e : settings.getSettings()) @@ -418,6 +423,11 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo return priorityByStacks[i]; } + public int levelByStackAmounts(int i) + { + return levelByStacks[i]; + } + public Enum getSetting(String Category, Class class1, Enum myDefault) { String name = class1.getSimpleName();