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.client.gui.widgets.GuiTabButton;
import appeng.container.AEBaseContainer; import appeng.container.AEBaseContainer;
import appeng.container.implementations.ContainerCraftAmount; import appeng.container.implementations.ContainerCraftAmount;
import appeng.core.AEConfig;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge; import appeng.core.sync.GuiBridge;
@ -45,18 +46,23 @@ public class GuiCraftAmount extends AEBaseGui
{ {
super.initGui(); 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( 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; ItemStack myIcon = null;
Object target = ((AEBaseContainer) inventorySlots).getTarget(); Object target = ((AEBaseContainer) inventorySlots).getTarget();
@ -101,47 +107,35 @@ public class GuiCraftAmount extends AEBaseGui
{ {
super.actionPerformed( btn ); super.actionPerformed( btn );
if ( btn == originalGuiBtn )
{
try try
{
if ( btn == originalGuiBtn )
{ {
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( OriginalGui ) ); NetworkHandler.instance.sendToServer( new PacketSwitchGuis( OriginalGui ) );
} }
if ( btn == next )
{
NetworkHandler.instance.sendToServer( new PacketCraftRequest( inventorySlots.getSlot( 0 ).getStack(), Integer.parseInt( this.amountToCraft
.getText() ), isShiftKeyDown() ) );
}
}
catch (IOException e) catch (IOException e)
{ {
AELog.error( e ); AELog.error( e );
} }
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 ) );
} }
if ( btn == next ) private int getQty(GuiButton btn)
{ {
try return Integer.parseInt( btn.displayString );
{
NetworkHandler.instance.sendToServer( new PacketCraftRequest( inventorySlots.getSlot( 0 ).getStack(), Integer.parseInt( this.amountToCraft
.getText() ), isShiftKeyDown() ) );
}
catch (Throwable 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 );
} }
private void addQty(int i) private void addQty(int i)

View file

@ -11,6 +11,7 @@ import appeng.client.gui.AEBaseGui;
import appeng.client.gui.widgets.GuiTabButton; import appeng.client.gui.widgets.GuiTabButton;
import appeng.container.AEBaseContainer; import appeng.container.AEBaseContainer;
import appeng.container.implementations.ContainerPriority; import appeng.container.implementations.ContainerPriority;
import appeng.core.AEConfig;
import appeng.core.AELog; import appeng.core.AELog;
import appeng.core.localization.GuiText; import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge; import appeng.core.sync.GuiBridge;
@ -45,15 +46,20 @@ public class GuiPriority extends AEBaseGui
{ {
super.initGui(); super.initGui();
buttonList.add( plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 32, 22, 20, "+1" ) ); int a = AEConfig.instance.priorityByStacksAmounts( 0 );
buttonList.add( plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 32, 28, 20, "+10" ) ); int b = AEConfig.instance.priorityByStacksAmounts( 1 );
buttonList.add( plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 32, 32, 20, "+100" ) ); int c = AEConfig.instance.priorityByStacksAmounts( 2 );
buttonList.add( plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 32, 38, 20, "+1000" ) ); int d = AEConfig.instance.priorityByStacksAmounts( 3 );
buttonList.add( minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 69, 22, 20, "-1" ) ); buttonList.add( plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 32, 22, 20, "+" + a ) );
buttonList.add( minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 69, 28, 20, "-10" ) ); buttonList.add( plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 32, 28, 20, "+" + b ) );
buttonList.add( minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 69, 32, 20, "-100" ) ); buttonList.add( plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 32, 32, 20, "+" + c ) );
buttonList.add( minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 69, 38, 20, "-1000" ) ); 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; ItemStack myIcon = null;
Object target = ((AEBaseContainer) inventorySlots).getTarget(); Object target = ((AEBaseContainer) inventorySlots).getTarget();
@ -123,22 +129,16 @@ public class GuiPriority extends AEBaseGui
} }
} }
if ( btn == plus1 ) boolean isPlus = btn == plus1 || btn == plus10 || btn == plus100 || btn == plus1000;
addQty( 1 ); boolean isMinus = btn == minus1 || btn == minus10 || btn == minus100 || btn == minus1000;
if ( btn == plus10 )
addQty( 10 ); if ( isPlus || isMinus )
if ( btn == plus100 ) addQty( getQty( btn ) );
addQty( 100 ); }
if ( btn == plus1000 )
addQty( 1000 ); private int getQty(GuiButton btn)
if ( btn == minus1 ) {
addQty( -1 ); return Integer.parseInt( btn.displayString );
if ( btn == minus10 )
addQty( -10 );
if ( btn == minus100 )
addQty( -100 );
if ( btn == minus1000 )
addQty( -1000 );
} }
private void addQty(int i) 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 enableEffects = true;
public boolean useLargeFonts = false; 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 wireless_battery = 1600000;
public int manipulator_battery = 200000; public int manipulator_battery = 200000;
@ -134,6 +136,24 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo
enableEffects = get( "Client", "enableEffects", true ).getBoolean( true ); enableEffects = get( "Client", "enableEffects", true ).getBoolean( true );
useLargeFonts = get( "Client", "useTerminalUseLargeFont", false ).getBoolean( false ); 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()) for (Enum e : settings.getSettings())
{ {
String Category = "Client"; // e.getClass().getSimpleName(); String Category = "Client"; // e.getClass().getSimpleName();
@ -388,6 +408,16 @@ public class AEConfig extends Configuration implements IConfigureableObject, ICo
return useLargeFonts; 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) public Enum getSetting(String Category, Class<? extends Enum> class1, Enum myDefault)
{ {
String name = class1.getSimpleName(); String name = class1.getSimpleName();