Customizable Priority and Crafting Buttons.

This commit is contained in:
AlgorithmX2 2014-07-31 12:24:08 -05:00
parent 2fb6f160de
commit c9ec498984
3 changed files with 88 additions and 64 deletions

View file

@ -12,6 +12,7 @@ import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.AEBaseContainer;
import appeng.container.implementations.ContainerCraftAmount;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge;
@ -45,18 +46,23 @@ public class GuiCraftAmount extends AEBaseGui
{
super.initGui();
int a = AEConfig.instance.craftItemsByStackAmounts( 0 );
int b = AEConfig.instance.craftItemsByStackAmounts( 1 );
int c = AEConfig.instance.craftItemsByStackAmounts( 2 );
int d = AEConfig.instance.craftItemsByStackAmounts( 3 );
buttonList.add( plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 26, 22, 20, "+" + a ) );
buttonList.add( plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 26, 28, 20, "+" + b ) );
buttonList.add( plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 26, 32, 20, "+" + c ) );
buttonList.add( plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 26, 38, 20, "+" + d ) );
buttonList.add( minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 75, 22, 20, "-" + a ) );
buttonList.add( minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 75, 28, 20, "-" + b ) );
buttonList.add( minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 75, 32, 20, "-" + c ) );
buttonList.add( minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 75, 38, 20, "-" + d ) );
buttonList.add( next = new GuiButton( 0, this.guiLeft + 128, this.guiTop + 51, 38, 20, GuiText.Next.getLocal() ) );
buttonList.add( plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 26, 22, 20, "+1" ) );
buttonList.add( plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 26, 28, 20, "+10" ) );
buttonList.add( plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 26, 32, 20, "+100" ) );
buttonList.add( plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 26, 38, 20, "+1000" ) );
buttonList.add( minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 75, 22, 20, "-1" ) );
buttonList.add( minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 75, 28, 20, "-10" ) );
buttonList.add( minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 75, 32, 20, "-100" ) );
buttonList.add( minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 75, 38, 20, "-1000" ) );
ItemStack myIcon = null;
Object target = ((AEBaseContainer) inventorySlots).getTarget();
@ -101,47 +107,35 @@ public class GuiCraftAmount extends AEBaseGui
{
super.actionPerformed( btn );
if ( btn == originalGuiBtn )
try
{
try
if ( btn == originalGuiBtn )
{
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( OriginalGui ) );
}
catch (IOException e)
{
AELog.error( e );
}
}
if ( btn == next )
{
try
if ( btn == next )
{
NetworkHandler.instance.sendToServer( new PacketCraftRequest( inventorySlots.getSlot( 0 ).getStack(), Integer.parseInt( this.amountToCraft
.getText() ), isShiftKeyDown() ) );
}
catch (Throwable e)
{
AELog.error( e );
}
}
catch (IOException e)
{
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(int i)

View file

@ -11,6 +11,7 @@ import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.AEBaseContainer;
import appeng.container.implementations.ContainerPriority;
import appeng.core.AEConfig;
import appeng.core.AELog;
import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge;
@ -45,15 +46,20 @@ public class GuiPriority extends AEBaseGui
{
super.initGui();
buttonList.add( plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 32, 22, 20, "+1" ) );
buttonList.add( plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 32, 28, 20, "+10" ) );
buttonList.add( plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 32, 32, 20, "+100" ) );
buttonList.add( plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 32, 38, 20, "+1000" ) );
int a = AEConfig.instance.priorityByStacksAmounts( 0 );
int b = AEConfig.instance.priorityByStacksAmounts( 1 );
int c = AEConfig.instance.priorityByStacksAmounts( 2 );
int d = AEConfig.instance.priorityByStacksAmounts( 3 );
buttonList.add( minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 69, 22, 20, "-1" ) );
buttonList.add( minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 69, 28, 20, "-10" ) );
buttonList.add( minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 69, 32, 20, "-100" ) );
buttonList.add( minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 69, 38, 20, "-1000" ) );
buttonList.add( plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 32, 22, 20, "+" + a ) );
buttonList.add( plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 32, 28, 20, "+" + b ) );
buttonList.add( plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 32, 32, 20, "+" + c ) );
buttonList.add( plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 32, 38, 20, "+" + d ) );
buttonList.add( minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 69, 22, 20, "-" + a ) );
buttonList.add( minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 69, 28, 20, "-" + b ) );
buttonList.add( minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 69, 32, 20, "-" + c ) );
buttonList.add( minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 69, 38, 20, "-" + d ) );
ItemStack myIcon = null;
Object target = ((AEBaseContainer) inventorySlots).getTarget();
@ -123,22 +129,16 @@ public class GuiPriority extends AEBaseGui
}
}
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(int i)

View file

@ -106,6 +106,8 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo
public boolean enableEffects = true;
public boolean useLargeFonts = false;
public int[] craftByStacks = new int[] { 1, 10, 100, 1000 };
public int[] priorityByStacks = new int[] { 1, 10, 100, 1000 };
public int wireless_battery = 1600000;
public int manipulator_battery = 200000;
@ -134,6 +136,24 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo
enableEffects = get( "Client", "enableEffects", true ).getBoolean( true );
useLargeFonts = get( "Client", "useTerminalUseLargeFont", false ).getBoolean( false );
// load buttons..
for (int btnNum = 0; btnNum < 4; btnNum++)
{
Property cmb = get( "Client", "craftAmtButton" + (btnNum + 1), craftByStacks[btnNum] );
Property pmb = get( "Client", "priorityAmtButton" + (btnNum + 1), priorityByStacks[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] ) );
cmb.comment = "Controls buttons on Crafting Screen : Capped at " + buttonCap;
pmb.comment = "Controls buttons on Priority Screen : Capped at " + buttonCap;
craftByStacks[btnNum] = Math.min( craftByStacks[btnNum], buttonCap );
priorityByStacks[btnNum] = Math.min( priorityByStacks[btnNum], buttonCap );
}
for (Enum e : settings.getSettings())
{
String Category = "Client"; // e.getClass().getSimpleName();
@ -388,6 +408,16 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo
return useLargeFonts;
}
public int craftItemsByStackAmounts(int i)
{
return craftByStacks[i];
}
public int priorityByStacksAmounts(int i)
{
return priorityByStacks[i];
}
public Enum getSetting(String Category, Class<? extends Enum> class1, Enum myDefault)
{
String name = class1.getSimpleName();