Relocate Source to proper directory.
This commit is contained in:
@@ -0,0 +1,952 @@
|
||||
package appeng.client.gui;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.ParseException;
|
||||
import java.util.Collection;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import appeng.container.slot.*;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.input.Keyboard;
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.client.gui.widgets.ITooltip;
|
||||
import appeng.client.me.InternalSlotME;
|
||||
import appeng.client.me.SlotDisconnected;
|
||||
import appeng.client.me.SlotME;
|
||||
import appeng.client.render.AppEngRenderItem;
|
||||
import appeng.container.AEBaseContainer;
|
||||
import appeng.container.slot.AppEngSlot.hasCalculatedValidness;
|
||||
import appeng.container.slot.SlotInaccessible;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketInventoryAction;
|
||||
import appeng.core.sync.packets.PacketSwapSlots;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.integration.abstraction.INEI;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.google.common.base.Stopwatch;
|
||||
|
||||
import cpw.mods.fml.common.ObfuscationReflectionHelper;
|
||||
|
||||
public abstract class AEBaseGui extends GuiContainer
|
||||
{
|
||||
|
||||
protected List<InternalSlotME> meSlots = new LinkedList<InternalSlotME>();
|
||||
protected GuiScrollbar myScrollBar = null;
|
||||
static public boolean switchingGuis;
|
||||
private boolean subGui;
|
||||
|
||||
public AEBaseGui(Container container)
|
||||
{
|
||||
super( container );
|
||||
subGui = switchingGuis;
|
||||
switchingGuis = false;
|
||||
}
|
||||
|
||||
protected int getQty(GuiButton btn)
|
||||
{
|
||||
try
|
||||
{
|
||||
DecimalFormat df = new DecimalFormat( "+#;-#" );
|
||||
return df.parse( btn.displayString ).intValue();
|
||||
}
|
||||
catch (ParseException e)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isSubGui()
|
||||
{
|
||||
return subGui;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
Iterator<Slot> i = inventorySlots.inventorySlots.iterator();
|
||||
while (i.hasNext())
|
||||
if ( i.next() instanceof SlotME )
|
||||
i.remove();
|
||||
|
||||
for (InternalSlotME me : meSlots)
|
||||
inventorySlots.inventorySlots.add( new SlotME( me ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMouseInput()
|
||||
{
|
||||
super.handleMouseInput();
|
||||
|
||||
int i = Mouse.getEventDWheel();
|
||||
if ( i != 0 && isShiftKeyDown() )
|
||||
{
|
||||
int x = Mouse.getEventX() * this.width / this.mc.displayWidth;
|
||||
int y = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;
|
||||
mouseWheelEvent( x, y, i / Math.abs( i ) );
|
||||
}
|
||||
else if ( i != 0 && myScrollBar != null )
|
||||
myScrollBar.wheel( i );
|
||||
}
|
||||
|
||||
protected void mouseWheelEvent(int x, int y, int wheel)
|
||||
{
|
||||
Slot slot = getSlot( x, y );
|
||||
if ( slot instanceof SlotME )
|
||||
{
|
||||
IAEItemStack item = ((SlotME) slot).getAEStack();
|
||||
if ( item != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
((AEBaseContainer) inventorySlots).setTargetStack( item );
|
||||
InventoryAction direction = wheel > 0 ? InventoryAction.ROLLDOWN : InventoryAction.ROLLUP;
|
||||
int times = Math.abs( wheel );
|
||||
for (int h = 0; h < times; h++)
|
||||
{
|
||||
PacketInventoryAction p = new PacketInventoryAction( direction, inventorySlots.inventorySlots.size(), 0 );
|
||||
NetworkHandler.instance.sendToServer( p );
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed()
|
||||
{
|
||||
super.onGuiClosed();
|
||||
subGui = true; // in case the gui is reopened later ( i'm looking at you NEI )
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int xCoord, int yCoord, int btn)
|
||||
{
|
||||
drag_click.clear();
|
||||
|
||||
if ( btn == 1 )
|
||||
{
|
||||
for (Object o : this.buttonList)
|
||||
{
|
||||
GuiButton guibutton = (GuiButton) o;
|
||||
if ( guibutton.mousePressed( this.mc, xCoord, yCoord ) )
|
||||
{
|
||||
super.mouseClicked( xCoord, yCoord, 0 );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
super.mouseClicked( xCoord, yCoord, btn );
|
||||
}
|
||||
|
||||
boolean disableShiftClick = false;
|
||||
Stopwatch dbl_clickTimer = Stopwatch.createStarted();
|
||||
ItemStack dbl_whichItem;
|
||||
Slot bl_clicked;
|
||||
|
||||
// dragy
|
||||
Set<Slot> drag_click = new HashSet();
|
||||
|
||||
@Override
|
||||
protected void handleMouseClick(Slot slot, int slotIdx, int ctrlDown, int key)
|
||||
{
|
||||
EntityPlayer player = Minecraft.getMinecraft().thePlayer;
|
||||
|
||||
if ( slot instanceof SlotFake )
|
||||
{
|
||||
InventoryAction action = null;
|
||||
action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACESINGLE : InventoryAction.PICKUP_OR_SETDOWN;
|
||||
|
||||
if ( drag_click.size() > 1 )
|
||||
return;
|
||||
|
||||
if ( action != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
PacketInventoryAction p = new PacketInventoryAction( action, slotIdx, 0 );
|
||||
NetworkHandler.instance.sendToServer( p );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( slot instanceof SlotPatternTerm )
|
||||
{
|
||||
if ( key == 6 )
|
||||
return; // prevent weird double clicks..
|
||||
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( ((SlotPatternTerm) slot).getRequest( key == 1 ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
else if ( slot instanceof SlotCraftingTerm )
|
||||
{
|
||||
if ( key == 6 )
|
||||
return; // prevent weird double clicks..
|
||||
|
||||
InventoryAction action = null;
|
||||
if ( key == 1 )
|
||||
action = InventoryAction.CRAFT_SHIFT;
|
||||
else
|
||||
action = ctrlDown == 1 ? InventoryAction.CRAFT_STACK : InventoryAction.CRAFT_ITEM;
|
||||
|
||||
if ( action != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
PacketInventoryAction p = new PacketInventoryAction( action, slotIdx, 0 );
|
||||
NetworkHandler.instance.sendToServer( p );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( Keyboard.isKeyDown( Keyboard.KEY_SPACE ) )
|
||||
{
|
||||
if ( enableSpaceClicking() )
|
||||
{
|
||||
IAEItemStack stack = null;
|
||||
if ( slot instanceof SlotME )
|
||||
stack = ((SlotME) slot).getAEStack();
|
||||
|
||||
try
|
||||
{
|
||||
int slotNum = inventorySlots.inventorySlots.size();
|
||||
|
||||
if ( !(slot instanceof SlotME) && slot != null )
|
||||
slotNum = slot.slotNumber;
|
||||
|
||||
((AEBaseContainer) inventorySlots).setTargetStack( stack );
|
||||
PacketInventoryAction p = new PacketInventoryAction( InventoryAction.MOVE_REGION, slotNum, 0 );
|
||||
NetworkHandler.instance.sendToServer( p );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ( slot instanceof SlotDisconnected )
|
||||
{
|
||||
InventoryAction action = null;
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case 0: // pickup / set-down.
|
||||
action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACESINGLE : InventoryAction.PICKUP_OR_SETDOWN;
|
||||
break;
|
||||
case 1:
|
||||
action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
|
||||
break;
|
||||
|
||||
case 3: // creative dupe:
|
||||
|
||||
if ( player.capabilities.isCreativeMode )
|
||||
{
|
||||
action = InventoryAction.CREATIVE_DUPLICATE;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
case 4: // drop item:
|
||||
case 6:
|
||||
}
|
||||
|
||||
if ( action != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
PacketInventoryAction p = new PacketInventoryAction( action, slot.getSlotIndex(), ((SlotDisconnected) slot).mySlot.id );
|
||||
NetworkHandler.instance.sendToServer( p );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( slot instanceof SlotME )
|
||||
{
|
||||
InventoryAction action = null;
|
||||
IAEItemStack stack = null;
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case 0: // pickup / set-down.
|
||||
action = ctrlDown == 1 ? InventoryAction.SPLIT_OR_PLACESINGLE : InventoryAction.PICKUP_OR_SETDOWN;
|
||||
stack = ((SlotME) slot).getAEStack();
|
||||
|
||||
if ( stack != null && action == InventoryAction.PICKUP_OR_SETDOWN && stack.getStackSize() == 0 && player.inventory.getItemStack() == null )
|
||||
action = InventoryAction.AUTOCRAFT;
|
||||
|
||||
break;
|
||||
case 1:
|
||||
action = ctrlDown == 1 ? InventoryAction.PICKUP_SINGLE : InventoryAction.SHIFT_CLICK;
|
||||
stack = ((SlotME) slot).getAEStack();
|
||||
break;
|
||||
|
||||
case 3: // creative dupe:
|
||||
|
||||
stack = ((SlotME) slot).getAEStack();
|
||||
if ( stack != null && stack.isCraftable() )
|
||||
action = InventoryAction.AUTOCRAFT;
|
||||
|
||||
else if ( player.capabilities.isCreativeMode )
|
||||
{
|
||||
IAEItemStack slotItem = ((SlotME) slot).getAEStack();
|
||||
if ( slotItem != null )
|
||||
{
|
||||
action = InventoryAction.CREATIVE_DUPLICATE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
case 4: // drop item:
|
||||
case 6:
|
||||
}
|
||||
|
||||
if ( action != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
((AEBaseContainer) inventorySlots).setTargetStack( stack );
|
||||
PacketInventoryAction p = new PacketInventoryAction( action, inventorySlots.inventorySlots.size(), 0 );
|
||||
NetworkHandler.instance.sendToServer( p );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( disableShiftClick == false && isShiftKeyDown() )
|
||||
{
|
||||
disableShiftClick = true;
|
||||
|
||||
if ( dbl_whichItem == null || bl_clicked != slot || dbl_clickTimer.elapsed( TimeUnit.MILLISECONDS ) > 150 )
|
||||
{
|
||||
// some simple double click logic.
|
||||
bl_clicked = slot;
|
||||
dbl_clickTimer = Stopwatch.createStarted();
|
||||
if ( slot != null )
|
||||
dbl_whichItem = slot.getHasStack() ? slot.getStack().copy() : null;
|
||||
else
|
||||
dbl_whichItem = null;
|
||||
}
|
||||
else if ( dbl_whichItem != null )
|
||||
{
|
||||
// a replica of the weird broken vanilla feature.
|
||||
Iterator iterator = this.inventorySlots.inventorySlots.iterator();
|
||||
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
Slot targetSlot = (Slot) iterator.next();
|
||||
|
||||
if ( targetSlot != null && targetSlot.canTakeStack( this.mc.thePlayer ) && targetSlot.getHasStack()
|
||||
&& targetSlot.inventory == slot.inventory && Container.func_94527_a( targetSlot, dbl_whichItem, true ) )
|
||||
{
|
||||
this.handleMouseClick( targetSlot, targetSlot.slotNumber, ctrlDown, 1 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
disableShiftClick = false;
|
||||
}
|
||||
|
||||
super.handleMouseClick( slot, slotIdx, ctrlDown, key );
|
||||
}
|
||||
|
||||
protected void mouseClickMove(int x, int y, int c, long d)
|
||||
{
|
||||
Slot slot = this.getSlot( x, y );
|
||||
ItemStack itemstack = this.mc.thePlayer.inventory.getItemStack();
|
||||
|
||||
if ( slot instanceof SlotFake && itemstack != null )
|
||||
{
|
||||
drag_click.add( slot );
|
||||
if ( drag_click.size() > 1 )
|
||||
{
|
||||
try
|
||||
{
|
||||
for (Slot dr : drag_click)
|
||||
{
|
||||
PacketInventoryAction p = new PacketInventoryAction( c == 0 ? InventoryAction.PICKUP_OR_SETDOWN : InventoryAction.PLACE_SINGLE,
|
||||
dr.slotNumber, 0 );
|
||||
NetworkHandler.instance.sendToServer( p );
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
super.mouseClickMove( x, y, c, d );
|
||||
}
|
||||
|
||||
protected boolean enableSpaceClicking()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkHotbarKeys(int p_146983_1_)
|
||||
{
|
||||
Slot theSlot;
|
||||
|
||||
try
|
||||
{
|
||||
theSlot = ObfuscationReflectionHelper.getPrivateValue( GuiContainer.class, this, "theSlot", "field_147006_u", "f" );
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( this.mc.thePlayer.inventory.getItemStack() == null && theSlot != null )
|
||||
{
|
||||
for (int j = 0; j < 9; ++j)
|
||||
{
|
||||
if ( p_146983_1_ == this.mc.gameSettings.keyBindsHotbar[j].getKeyCode() )
|
||||
{
|
||||
for (Slot s : (List<Slot>) inventorySlots.inventorySlots)
|
||||
{
|
||||
if ( s.getSlotIndex() == j && s.inventory == ((AEBaseContainer) inventorySlots).getPlayerInv() )
|
||||
{
|
||||
if ( !s.canTakeStack( ((AEBaseContainer) inventorySlots).getPlayerInv().player ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( theSlot.getSlotStackLimit() == 64 )
|
||||
{
|
||||
this.handleMouseClick( theSlot, theSlot.slotNumber, j, 2 );
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
for (Slot s : (List<Slot>) inventorySlots.inventorySlots)
|
||||
{
|
||||
if ( s.getSlotIndex() == j && s.inventory == ((AEBaseContainer) inventorySlots).getPlayerInv() )
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketSwapSlots( s.slotNumber, theSlot.slotNumber ) );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouse_x, int mouse_y, float btn)
|
||||
{
|
||||
super.drawScreen( mouse_x, mouse_y, btn );
|
||||
|
||||
boolean hasClicked = Mouse.isButtonDown( 0 );
|
||||
if ( hasClicked && myScrollBar != null )
|
||||
myScrollBar.click( this, mouse_x - guiLeft, mouse_y - guiTop );
|
||||
|
||||
for (Object c : buttonList)
|
||||
{
|
||||
if ( c instanceof ITooltip )
|
||||
{
|
||||
ITooltip tooltip = (ITooltip) c;
|
||||
int x = tooltip.xPos(); // ((GuiImgButton) c).xPosition;
|
||||
int y = tooltip.yPos(); // ((GuiImgButton) c).yPosition;
|
||||
|
||||
if ( x < mouse_x && x + tooltip.getWidth() > mouse_x && tooltip.isVisible() )
|
||||
{
|
||||
if ( y < mouse_y && y + tooltip.getHeight() > mouse_y )
|
||||
{
|
||||
if ( y < 15 )
|
||||
y = 15;
|
||||
|
||||
String msg = tooltip.getMsg();
|
||||
if ( msg != null )
|
||||
drawTooltip( x + 11, y + 4, 0, msg );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void drawTooltip(int par2, int par3, int forceWidth, String Msg)
|
||||
{
|
||||
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
||||
GL11.glDisable( GL12.GL_RESCALE_NORMAL );
|
||||
RenderHelper.disableStandardItemLighting();
|
||||
GL11.glDisable( GL11.GL_LIGHTING );
|
||||
GL11.glDisable( GL11.GL_DEPTH_TEST );
|
||||
String[] var4 = Msg.split( "\n" );
|
||||
|
||||
if ( var4.length > 0 )
|
||||
{
|
||||
int var5 = 0;
|
||||
int var6;
|
||||
int var7;
|
||||
|
||||
for (var6 = 0; var6 < var4.length; ++var6)
|
||||
{
|
||||
var7 = fontRendererObj.getStringWidth( (String) var4[var6] );
|
||||
|
||||
if ( var7 > var5 )
|
||||
{
|
||||
var5 = var7;
|
||||
}
|
||||
}
|
||||
|
||||
var6 = par2 + 12;
|
||||
var7 = par3 - 12;
|
||||
int var9 = 8;
|
||||
|
||||
if ( var4.length > 1 )
|
||||
{
|
||||
var9 += 2 + (var4.length - 1) * 10;
|
||||
}
|
||||
|
||||
if ( this.guiTop + var7 + var9 + 6 > this.height )
|
||||
{
|
||||
var7 = this.height - var9 - this.guiTop - 6;
|
||||
}
|
||||
|
||||
if ( forceWidth > 0 )
|
||||
var5 = forceWidth;
|
||||
|
||||
this.zLevel = 300.0F;
|
||||
itemRender.zLevel = 300.0F;
|
||||
int var10 = -267386864;
|
||||
this.drawGradientRect( var6 - 3, var7 - 4, var6 + var5 + 3, var7 - 3, var10, var10 );
|
||||
this.drawGradientRect( var6 - 3, var7 + var9 + 3, var6 + var5 + 3, var7 + var9 + 4, var10, var10 );
|
||||
this.drawGradientRect( var6 - 3, var7 - 3, var6 + var5 + 3, var7 + var9 + 3, var10, var10 );
|
||||
this.drawGradientRect( var6 - 4, var7 - 3, var6 - 3, var7 + var9 + 3, var10, var10 );
|
||||
this.drawGradientRect( var6 + var5 + 3, var7 - 3, var6 + var5 + 4, var7 + var9 + 3, var10, var10 );
|
||||
int var11 = 1347420415;
|
||||
int var12 = (var11 & 16711422) >> 1 | var11 & -16777216;
|
||||
this.drawGradientRect( var6 - 3, var7 - 3 + 1, var6 - 3 + 1, var7 + var9 + 3 - 1, var11, var12 );
|
||||
this.drawGradientRect( var6 + var5 + 2, var7 - 3 + 1, var6 + var5 + 3, var7 + var9 + 3 - 1, var11, var12 );
|
||||
this.drawGradientRect( var6 - 3, var7 - 3, var6 + var5 + 3, var7 - 3 + 1, var11, var11 );
|
||||
this.drawGradientRect( var6 - 3, var7 + var9 + 2, var6 + var5 + 3, var7 + var9 + 3, var12, var12 );
|
||||
|
||||
for (int var13 = 0; var13 < var4.length; ++var13)
|
||||
{
|
||||
String var14 = (String) var4[var13];
|
||||
|
||||
if ( var13 == 0 )
|
||||
{
|
||||
var14 = "\u00a7" + Integer.toHexString( 15 ) + var14;
|
||||
}
|
||||
else
|
||||
{
|
||||
var14 = "\u00a77" + var14;
|
||||
}
|
||||
|
||||
this.fontRendererObj.drawStringWithShadow( var14, var6, var7, -1 );
|
||||
|
||||
if ( var13 == 0 )
|
||||
{
|
||||
var7 += 2;
|
||||
}
|
||||
|
||||
var7 += 10;
|
||||
}
|
||||
|
||||
this.zLevel = 0.0F;
|
||||
itemRender.zLevel = 0.0F;
|
||||
}
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
public abstract void drawBG(int offsetX, int offsetY, int mouseX, int mouseY);
|
||||
|
||||
public abstract void drawFG(int offsetX, int offsetY, int mouseX, int mouseY);
|
||||
|
||||
public void bindTexture(String base, String file)
|
||||
{
|
||||
ResourceLocation loc = new ResourceLocation( base, "textures/" + file );
|
||||
this.mc.getTextureManager().bindTexture( loc );
|
||||
}
|
||||
|
||||
public void bindTexture(String file)
|
||||
{
|
||||
ResourceLocation loc = new ResourceLocation( "appliedenergistics2", "textures/" + file );
|
||||
this.mc.getTextureManager().bindTexture( loc );
|
||||
}
|
||||
|
||||
protected void drawItem(int x, int y, ItemStack is)
|
||||
{
|
||||
this.zLevel = 100.0F;
|
||||
itemRender.zLevel = 100.0F;
|
||||
|
||||
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
||||
GL11.glEnable( GL11.GL_LIGHTING );
|
||||
GL11.glEnable( GL12.GL_RESCALE_NORMAL );
|
||||
GL11.glEnable( GL11.GL_DEPTH_TEST );
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
itemRender.renderItemAndEffectIntoGUI( this.fontRendererObj, this.mc.renderEngine, is, x, y );
|
||||
GL11.glPopAttrib();
|
||||
|
||||
itemRender.zLevel = 0.0F;
|
||||
this.zLevel = 0.0F;
|
||||
}
|
||||
|
||||
@Override
|
||||
final protected void drawGuiContainerBackgroundLayer(float f, int x, int y)
|
||||
{
|
||||
int ox = guiLeft; // (width - xSize) / 2;
|
||||
int oy = guiTop; // (height - ySize) / 2;
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
drawBG( ox, oy, x, y );
|
||||
|
||||
for (Object o : inventorySlots.inventorySlots)
|
||||
{
|
||||
if ( o instanceof OptionalSlotFake )
|
||||
{
|
||||
OptionalSlotFake fs = (OptionalSlotFake) o;
|
||||
if ( fs.renderDisabled() )
|
||||
{
|
||||
if ( fs.isEnabled() )
|
||||
{
|
||||
this.drawTexturedModalRect( ox + fs.xDisplayPosition - 1, oy + fs.yDisplayPosition - 1, fs.srcX - 1, fs.srcY - 1, 18, 18 );
|
||||
}
|
||||
else
|
||||
{
|
||||
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 0.4F );
|
||||
GL11.glEnable( GL11.GL_BLEND );
|
||||
this.drawTexturedModalRect( ox + fs.xDisplayPosition - 1, oy + fs.yDisplayPosition - 1, fs.srcX - 1, fs.srcY - 1, 18, 18 );
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
final protected void drawGuiContainerForegroundLayer(int x, int y)
|
||||
{
|
||||
int ox = guiLeft; // (width - xSize) / 2;
|
||||
int oy = guiTop; // (height - ySize) / 2;
|
||||
GL11.glColor4f( 1.0F, 1.0F, 1.0F, 1.0F );
|
||||
|
||||
if ( myScrollBar != null )
|
||||
myScrollBar.draw( this );
|
||||
|
||||
drawFG( ox, oy, x, y );
|
||||
}
|
||||
|
||||
protected String getGuiDisplayName(String in)
|
||||
{
|
||||
return hasCustomInventoryName() ? getInventoryName() : in;
|
||||
}
|
||||
|
||||
private String getInventoryName()
|
||||
{
|
||||
return ((AEBaseContainer) inventorySlots).customName;
|
||||
}
|
||||
|
||||
private boolean hasCustomInventoryName()
|
||||
{
|
||||
if ( inventorySlots instanceof AEBaseContainer )
|
||||
return ((AEBaseContainer) inventorySlots).customName != null;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected Slot getSlot(int mousex, int mousey)
|
||||
{
|
||||
for (int j1 = 0; j1 < this.inventorySlots.inventorySlots.size(); ++j1)
|
||||
{
|
||||
Slot slot = (Slot) this.inventorySlots.inventorySlots.get( j1 );
|
||||
|
||||
// isPointInRegion
|
||||
if ( func_146978_c( slot.xDisplayPosition, slot.yDisplayPosition, 16, 16, mousex, mousey ) )
|
||||
{
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected static String join(Collection<?> s, String delimiter)
|
||||
{
|
||||
StringBuilder builder = new StringBuilder();
|
||||
Iterator iter = s.iterator();
|
||||
while (iter.hasNext())
|
||||
{
|
||||
builder.append( iter.next() );
|
||||
if ( !iter.hasNext() )
|
||||
{
|
||||
break;
|
||||
}
|
||||
builder.append( delimiter );
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
boolean useNEI = false;
|
||||
|
||||
private RenderItem setItemRender(RenderItem aeri2)
|
||||
{
|
||||
if ( AppEng.instance.isIntegrationEnabled( IntegrationType.NEI ) )
|
||||
{
|
||||
return ((INEI) AppEng.instance.getIntegration( IntegrationType.NEI )).setItemRender( aeri2 );
|
||||
}
|
||||
else
|
||||
{
|
||||
RenderItem ri = itemRender;
|
||||
itemRender = aeri2;
|
||||
return ri;
|
||||
}
|
||||
}
|
||||
|
||||
private void safeDrawSlot(Slot s)
|
||||
{
|
||||
try
|
||||
{
|
||||
// drawSlotInventory
|
||||
// super.func_146977_a( s );r
|
||||
GuiContainer.class.getDeclaredMethod( "func_146977_a_original", Slot.class ).invoke( this, s );
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
if ( Platform.isDrawing( tessellator ) )
|
||||
tessellator.draw();
|
||||
}
|
||||
}
|
||||
|
||||
AppEngRenderItem aeri = new AppEngRenderItem();
|
||||
|
||||
protected boolean isPowered()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public void a(Slot s)
|
||||
{
|
||||
drawSlot( s );
|
||||
}
|
||||
|
||||
public void func_146977_a(Slot s)
|
||||
{
|
||||
drawSlot( s );
|
||||
}
|
||||
|
||||
public void drawSlot(Slot s)
|
||||
{
|
||||
if ( s instanceof SlotME )
|
||||
{
|
||||
RenderItem pIR = setItemRender( aeri );
|
||||
try
|
||||
{
|
||||
this.zLevel = 100.0F;
|
||||
itemRender.zLevel = 100.0F;
|
||||
|
||||
if ( !isPowered() )
|
||||
{
|
||||
GL11.glDisable( GL11.GL_LIGHTING );
|
||||
super.drawRect( s.xDisplayPosition, s.yDisplayPosition, 16 + s.xDisplayPosition, 16 + s.yDisplayPosition, 0x66111111 );
|
||||
GL11.glEnable( GL11.GL_LIGHTING );
|
||||
}
|
||||
|
||||
this.zLevel = 0.0F;
|
||||
itemRender.zLevel = 0.0F;
|
||||
|
||||
if ( s instanceof SlotME )
|
||||
aeri.aestack = ((SlotME) s).getAEStack();
|
||||
else
|
||||
aeri.aestack = null;
|
||||
|
||||
safeDrawSlot( s );
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
AELog.warning( "[AppEng] AE prevented crash while drawing slot: " + err.toString() );
|
||||
if ( Platform.isDrawing( Tessellator.instance ) )
|
||||
Tessellator.instance.draw();
|
||||
}
|
||||
setItemRender( pIR );
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
ItemStack is = s.getStack();
|
||||
if ( s instanceof AppEngSlot && (((AppEngSlot) s).renderIconWithItem() || is == null) && (((AppEngSlot) s).shouldDisplay()) )
|
||||
{
|
||||
AppEngSlot aes = (AppEngSlot) s;
|
||||
if ( aes.getIcon() >= 0 )
|
||||
{
|
||||
bindTexture( "guis/states.png" );
|
||||
|
||||
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
||||
Tessellator tessellator = Tessellator.instance;
|
||||
try
|
||||
{
|
||||
int uv_y = (int) Math.floor( aes.getIcon() / 16 );
|
||||
int uv_x = aes.getIcon() - uv_y * 16;
|
||||
|
||||
GL11.glEnable( GL11.GL_BLEND );
|
||||
GL11.glDisable( GL11.GL_LIGHTING );
|
||||
GL11.glEnable( GL11.GL_TEXTURE_2D );
|
||||
GL11.glBlendFunc( GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA );
|
||||
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
float par1 = aes.xDisplayPosition;
|
||||
float par2 = aes.yDisplayPosition;
|
||||
float par3 = uv_x * 16;
|
||||
float par4 = uv_y * 16;
|
||||
float par5 = 16;
|
||||
float par6 = 16;
|
||||
|
||||
float f = 0.00390625F;
|
||||
float f1 = 0.00390625F;
|
||||
tessellator.startDrawingQuads();
|
||||
tessellator.setColorRGBA_F( 1.0f, 1.0f, 1.0f, aes.getOpacityOfIcon() );
|
||||
tessellator.addVertexWithUV( (double) (par1 + 0), (double) (par2 + par6), (double) this.zLevel, (double) ((float) (par3 + 0) * f),
|
||||
(double) ((float) (par4 + par6) * f1) );
|
||||
tessellator.addVertexWithUV( (double) (par1 + par5), (double) (par2 + par6), (double) this.zLevel,
|
||||
(double) ((float) (par3 + par5) * f), (double) ((float) (par4 + par6) * f1) );
|
||||
tessellator.addVertexWithUV( (double) (par1 + par5), (double) (par2 + 0), (double) this.zLevel,
|
||||
(double) ((float) (par3 + par5) * f), (double) ((float) (par4 + 0) * f1) );
|
||||
tessellator.addVertexWithUV( (double) (par1 + 0), (double) (par2 + 0), (double) this.zLevel, (double) ((float) (par3 + 0) * f),
|
||||
(double) ((float) (par4 + 0) * f1) );
|
||||
tessellator.setColorRGBA_F( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
tessellator.draw();
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
if ( Platform.isDrawing( tessellator ) )
|
||||
tessellator.draw();
|
||||
}
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
}
|
||||
|
||||
if ( is != null && s instanceof AppEngSlot )
|
||||
{
|
||||
if ( ((AppEngSlot) s).isValid == hasCalculatedValidness.NotAvailable )
|
||||
{
|
||||
boolean isValid = s.isItemValid( is ) || s instanceof SlotOutput || s instanceof AppEngCraftingSlot || s instanceof SlotDisabled
|
||||
|| s instanceof SlotInaccessible || s instanceof SlotFake || s instanceof SlotRestrictedInput || s instanceof SlotDisconnected;
|
||||
if ( isValid && s instanceof SlotRestrictedInput )
|
||||
{
|
||||
try
|
||||
{
|
||||
isValid = ((SlotRestrictedInput) s).isValid( is, this.mc.theWorld );
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
AELog.error( err );
|
||||
}
|
||||
}
|
||||
((AppEngSlot) s).isValid = isValid ? hasCalculatedValidness.Valid : hasCalculatedValidness.Invalid;
|
||||
}
|
||||
|
||||
if ( ((AppEngSlot) s).isValid == hasCalculatedValidness.Invalid )
|
||||
{
|
||||
this.zLevel = 100.0F;
|
||||
itemRender.zLevel = 100.0F;
|
||||
|
||||
GL11.glDisable( GL11.GL_LIGHTING );
|
||||
super.drawRect( s.xDisplayPosition, s.yDisplayPosition, 16 + s.xDisplayPosition, 16 + s.yDisplayPosition, 0x66ff6666 );
|
||||
GL11.glEnable( GL11.GL_LIGHTING );
|
||||
|
||||
this.zLevel = 0.0F;
|
||||
itemRender.zLevel = 0.0F;
|
||||
}
|
||||
}
|
||||
|
||||
if ( s instanceof AppEngSlot )
|
||||
{
|
||||
((AppEngSlot) s).isDisplay = true;
|
||||
safeDrawSlot( s );
|
||||
}
|
||||
else
|
||||
safeDrawSlot( s );
|
||||
|
||||
return;
|
||||
}
|
||||
catch (Exception err)
|
||||
{
|
||||
AELog.warning( "[AppEng] AE prevented crash while drawing slot: " + err.toString() );
|
||||
}
|
||||
}
|
||||
// do the usual for non-ME Slots.
|
||||
safeDrawSlot( s );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package appeng.client.gui;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.me.SlotME;
|
||||
import appeng.core.AEConfig;
|
||||
|
||||
public abstract class AEBaseMEGui extends AEBaseGui
|
||||
{
|
||||
|
||||
public AEBaseMEGui(Container container) {
|
||||
super( container );
|
||||
}
|
||||
|
||||
public List<String> handleItemTooltip(ItemStack stack, int mousex, int mousey, List<String> currenttip)
|
||||
{
|
||||
if ( stack != null )
|
||||
{
|
||||
Slot s = getSlot( mousex, mousey );
|
||||
if ( s instanceof SlotME )
|
||||
{
|
||||
int BigNumber = AEConfig.instance.useTerminalUseLargeFont() ? 999 : 9999;
|
||||
|
||||
IAEItemStack myStack = null;
|
||||
|
||||
try
|
||||
{
|
||||
SlotME theSlotField = (SlotME) s;
|
||||
myStack = theSlotField.getAEStack();
|
||||
}
|
||||
catch (Throwable ignore)
|
||||
{
|
||||
}
|
||||
|
||||
if ( myStack != null )
|
||||
{
|
||||
if ( myStack.getStackSize() > BigNumber || (myStack.getStackSize() > 1 && stack.isItemDamaged()) )
|
||||
currenttip.add( "\u00a77Items Stored: " + NumberFormat.getNumberInstance( Locale.US ).format( myStack.getStackSize() ) );
|
||||
|
||||
if ( myStack.getCountRequestable() > 0 )
|
||||
currenttip.add( "\u00a77Items Requestable: " + NumberFormat.getNumberInstance( Locale.US ).format( myStack.getCountRequestable() ) );
|
||||
}
|
||||
else if ( stack.stackSize > BigNumber || (stack.stackSize > 1 && stack.isItemDamaged()) )
|
||||
{
|
||||
currenttip.add( "\u00a77Items Stored: " + NumberFormat.getNumberInstance( Locale.US ).format( stack.stackSize ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
// Vanilla version...
|
||||
// protected void drawItemStackTooltip(ItemStack stack, int x, int y)
|
||||
@Override
|
||||
protected void renderToolTip(ItemStack stack, int x, int y)
|
||||
{
|
||||
Slot s = getSlot( x, y );
|
||||
if ( s instanceof SlotME && stack != null )
|
||||
{
|
||||
int BigNumber = AEConfig.instance.useTerminalUseLargeFont() ? 999 : 9999;
|
||||
|
||||
IAEItemStack myStack = null;
|
||||
|
||||
try
|
||||
{
|
||||
SlotME theSlotField = (SlotME) s;
|
||||
myStack = theSlotField.getAEStack();
|
||||
}
|
||||
catch (Throwable ignore)
|
||||
{
|
||||
}
|
||||
|
||||
if ( myStack != null )
|
||||
{
|
||||
List currenttip = stack.getTooltip( this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips );
|
||||
|
||||
if ( myStack.getStackSize() > BigNumber || (myStack.getStackSize() > 1 && stack.isItemDamaged()) )
|
||||
currenttip.add( "Items Stored: " + NumberFormat.getNumberInstance( Locale.US ).format( myStack.getStackSize() ) );
|
||||
|
||||
if ( myStack.getCountRequestable() > 0 )
|
||||
currenttip.add( "Items Requestable: " + NumberFormat.getNumberInstance( Locale.US ).format( myStack.getCountRequestable() ) );
|
||||
|
||||
drawTooltip( x, y, 0, join( currenttip, "\n" ) );
|
||||
}
|
||||
else if ( stack != null && stack.stackSize > BigNumber )
|
||||
{
|
||||
List var4 = stack.getTooltip( this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips );
|
||||
var4.add( "Items Stored: " + NumberFormat.getNumberInstance( Locale.US ).format( stack.stackSize ) );
|
||||
drawTooltip( x, y, 0, join( var4, "\n" ) );
|
||||
return;
|
||||
}
|
||||
}
|
||||
super.renderToolTip( stack, x, y );
|
||||
// super.drawItemStackTooltip( stack, x, y );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package appeng.client.gui;
|
||||
|
||||
import net.minecraft.inventory.Container;
|
||||
|
||||
public class GuiNull extends AEBaseGui
|
||||
{
|
||||
|
||||
public GuiNull(Container container) {
|
||||
super( container );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package appeng.client.gui.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import net.minecraftforge.common.config.ConfigCategory;
|
||||
import net.minecraftforge.common.config.ConfigElement;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AppEng;
|
||||
import cpw.mods.fml.client.config.GuiConfig;
|
||||
import cpw.mods.fml.client.config.IConfigElement;
|
||||
|
||||
public class AEConfigGui extends GuiConfig
|
||||
{
|
||||
|
||||
private static List<IConfigElement> getConfigElements()
|
||||
{
|
||||
List<IConfigElement> list = new ArrayList<IConfigElement>();
|
||||
|
||||
for (String cat : AEConfig.instance.getCategoryNames())
|
||||
{
|
||||
if ( cat.equals( "versionchecker" ) )
|
||||
continue;
|
||||
|
||||
if ( cat.equals( "settings" ) )
|
||||
continue;
|
||||
|
||||
ConfigCategory cc = AEConfig.instance.getCategory( cat );
|
||||
|
||||
if ( cc.isChild() )
|
||||
continue;
|
||||
|
||||
ConfigElement ce = new ConfigElement( cc );
|
||||
list.add( ce );
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
public AEConfigGui(GuiScreen parent) {
|
||||
super( parent, getConfigElements(), AppEng.modid, false, false, GuiConfig.getAbridgedConfigPath( AEConfig.instance.getFilePath() ) );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package appeng.client.gui.config;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import cpw.mods.fml.client.IModGuiFactory;
|
||||
|
||||
public class AEConfigGuiFactory implements IModGuiFactory
|
||||
{
|
||||
|
||||
@Override
|
||||
public void initialize(Minecraft minecraftInstance)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends GuiScreen> mainConfigGuiClass()
|
||||
{
|
||||
return AEConfigGui.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<RuntimeOptionCategoryElement> runtimeGuiCategories()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RuntimeOptionGuiHandler getHandlerFor(RuntimeOptionCategoryElement element)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,178 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.CopyMode;
|
||||
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.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.tile.misc.TileCellWorkbench;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class GuiCellWorkbench extends GuiUpgradeable
|
||||
{
|
||||
|
||||
ContainerCellWorkbench ccwb;
|
||||
TileCellWorkbench tcw;
|
||||
|
||||
GuiImgButton clear;
|
||||
GuiImgButton partition;
|
||||
GuiToggleButton copyMode;
|
||||
|
||||
public GuiCellWorkbench(InventoryPlayer inventoryPlayer, TileCellWorkbench te) {
|
||||
super( new ContainerCellWorkbench( inventoryPlayer, te ) );
|
||||
ccwb = (ContainerCellWorkbench) inventorySlots;
|
||||
ySize = 251;
|
||||
tcw = te;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean drawUpgrades()
|
||||
{
|
||||
return ccwb.availableUpgrades() > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
handleButtonVisibility();
|
||||
|
||||
bindTexture( getBackground() );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, 211 - 34, ySize );
|
||||
if ( drawUpgrades() )
|
||||
{
|
||||
if ( ccwb.availableUpgrades() <= 8 )
|
||||
{
|
||||
this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 7 + ccwb.availableUpgrades() * 18 );
|
||||
this.drawTexturedModalRect( offsetX + 177, offsetY + (7 + (ccwb.availableUpgrades()) * 18), 177, 151, 35, 7 );
|
||||
}
|
||||
else if ( ccwb.availableUpgrades() <= 16 )
|
||||
{
|
||||
this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 7 + 8 * 18 );
|
||||
this.drawTexturedModalRect( offsetX + 177, offsetY + (7 + (8) * 18), 177, 151, 35, 7 );
|
||||
|
||||
int dx = ccwb.availableUpgrades() - 8;
|
||||
this.drawTexturedModalRect( offsetX + 177 + 27, offsetY, 186, 0, 35 - 8, 7 + dx * 18 );
|
||||
if ( dx == 8 )
|
||||
this.drawTexturedModalRect( offsetX + 177 + 27, offsetY + (7 + (dx) * 18), 186, 151, 35 - 8, 7 );
|
||||
else
|
||||
this.drawTexturedModalRect( offsetX + 177 + 27 + 4, offsetY + (7 + (dx) * 18), 186 + 4, 151, 35 - 8, 7 );
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 7 + 8 * 18 );
|
||||
this.drawTexturedModalRect( offsetX + 177, offsetY + (7 + (8) * 18), 177, 151, 35, 7 );
|
||||
|
||||
this.drawTexturedModalRect( offsetX + 177 + 27, offsetY, 186, 0, 35 - 8, 7 + 8 * 18 );
|
||||
this.drawTexturedModalRect( offsetX + 177 + 27, offsetY + (7 + (8) * 18), 186, 151, 35 - 8, 7 );
|
||||
|
||||
int dx = ccwb.availableUpgrades() - 16;
|
||||
this.drawTexturedModalRect( offsetX + 177 + 27 + 18, offsetY, 186, 0, 35 - 8, 7 + dx * 18 );
|
||||
if ( dx == 8 )
|
||||
this.drawTexturedModalRect( offsetX + 177 + 27 + 18, offsetY + (7 + (dx) * 18), 186, 151, 35 - 8, 7 );
|
||||
else
|
||||
this.drawTexturedModalRect( offsetX + 177 + 27 + 18 + 4, offsetY + (7 + (dx) * 18), 186 + 4, 151, 35 - 8, 7 );
|
||||
}
|
||||
}
|
||||
if ( hasToolbox() )
|
||||
this.drawTexturedModalRect( offsetX + 178, offsetY + ySize - 90, 178, 161, 68, 68 );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( btn == copyMode )
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "CellWorkbench.Action", "CopyMode" ) );
|
||||
}
|
||||
else if ( btn == partition )
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "CellWorkbench.Action", "Partition" ) );
|
||||
}
|
||||
else if ( btn == clear )
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "CellWorkbench.Action", "Clear" ) );
|
||||
}
|
||||
else if ( btn == fuzzyMode )
|
||||
{
|
||||
boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
FuzzyMode fz = (FuzzyMode) fuzzyMode.getCurrentValue();
|
||||
fz = Platform.rotateEnum( fz, backwards, Settings.FUZZY_MODE.getPossibleValues() );
|
||||
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "CellWorkbench.Fuzzy", fz.name() ) );
|
||||
}
|
||||
else
|
||||
super.actionPerformed( btn );
|
||||
}
|
||||
catch (IOException err)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
clear = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.ACTIONS, ActionItems.CLOSE );
|
||||
partition = new GuiImgButton( this.guiLeft - 18, guiTop + 28, Settings.ACTIONS, ActionItems.WRENCH );
|
||||
copyMode = new GuiToggleButton( this.guiLeft - 18, guiTop + 48, 11 * 16 + 5, 12 * 16 + 5, GuiText.CopyMode.getLocal(), GuiText.CopyModeDesc.getLocal() );
|
||||
fuzzyMode = new GuiImgButton( this.guiLeft - 18, guiTop + 68, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
|
||||
buttonList.add( fuzzyMode );
|
||||
buttonList.add( partition );
|
||||
buttonList.add( clear );
|
||||
buttonList.add( copyMode );
|
||||
}
|
||||
|
||||
protected void handleButtonVisibility()
|
||||
{
|
||||
copyMode.setState( ccwb.copyMode == CopyMode.CLEAR_ON_REMOVE );
|
||||
|
||||
boolean hasFuzzy = false;
|
||||
IInventory inv = ccwb.getCellUpgradeInventory();
|
||||
for (int x = 0; x < inv.getSizeInventory(); x++)
|
||||
{
|
||||
ItemStack is = inv.getStackInSlot( x );
|
||||
if ( is != null && is.getItem() instanceof IUpgradeModule )
|
||||
{
|
||||
if ( ((IUpgradeModule) is.getItem()).getType( is ) == Upgrades.FUZZY )
|
||||
hasFuzzy = true;
|
||||
}
|
||||
}
|
||||
fuzzyMode.setVisibility( hasFuzzy );
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/cellworkbench.png";
|
||||
}
|
||||
|
||||
protected GuiText getName()
|
||||
{
|
||||
return GuiText.CellWorkbench;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerChest;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.tile.storage.TileChest;
|
||||
|
||||
public class GuiChest extends AEBaseGui
|
||||
{
|
||||
|
||||
GuiTabButton priority;
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton par1GuiButton)
|
||||
{
|
||||
super.actionPerformed( par1GuiButton );
|
||||
|
||||
if ( par1GuiButton == priority )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
buttonList.add( priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), itemRender ) );
|
||||
}
|
||||
|
||||
public GuiChest(InventoryPlayer inventoryPlayer, TileChest te) {
|
||||
super( new ContainerChest( inventoryPlayer, te ) );
|
||||
this.ySize = 166;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/chest.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.Chest.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiProgressBar;
|
||||
import appeng.client.gui.widgets.GuiProgressBar.Direction;
|
||||
import appeng.container.implementations.ContainerCondenser;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import appeng.tile.misc.TileCondenser;
|
||||
|
||||
public class GuiCondenser extends AEBaseGui
|
||||
{
|
||||
|
||||
ContainerCondenser cvc;
|
||||
GuiProgressBar pb;
|
||||
GuiImgButton mode;
|
||||
|
||||
public GuiCondenser(InventoryPlayer inventoryPlayer, TileCondenser te) {
|
||||
super( new ContainerCondenser( inventoryPlayer, te ) );
|
||||
cvc = (ContainerCondenser) inventorySlots;
|
||||
this.ySize = 197;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
if ( mode == btn )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketConfigButton( Settings.CONDENSER_OUTPUT, backwards ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
pb = new GuiProgressBar( "guis/condenser.png", 120 + guiLeft, 25 + guiTop, 178, 25, 6, 18, Direction.VERTICAL );
|
||||
pb.TitleName = GuiText.StoredEnergy.getLocal();
|
||||
|
||||
mode = new GuiImgButton( 128 + guiLeft, 52 + guiTop, Settings.CONDENSER_OUTPUT, cvc.output );
|
||||
|
||||
this.buttonList.add( pb );
|
||||
this.buttonList.add( mode );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/condenser.png" );
|
||||
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.Condenser.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
|
||||
mode.set( cvc.output );
|
||||
mode.FillVar = "" + cvc.output.requiredPower;
|
||||
|
||||
pb.max = (int) cvc.requiredEnergy;
|
||||
pb.current = (int) cvc.storedPower;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,257 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiNumberBox;
|
||||
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;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketCraftRequest;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.parts.reporting.PartCraftingTerminal;
|
||||
import appeng.parts.reporting.PartPatternTerminal;
|
||||
import appeng.parts.reporting.PartTerminal;
|
||||
|
||||
public class GuiCraftAmount extends AEBaseGui
|
||||
{
|
||||
|
||||
GuiNumberBox amountToCraft;
|
||||
GuiTabButton originalGuiBtn;
|
||||
|
||||
GuiButton next;
|
||||
|
||||
GuiButton plus1, plus10, plus100, plus1000;
|
||||
GuiButton minus1, minus10, minus100, minus1000;
|
||||
|
||||
GuiBridge OriginalGui;
|
||||
|
||||
public GuiCraftAmount(InventoryPlayer inventoryPlayer, ITerminalHost te) {
|
||||
super( new ContainerCraftAmount( inventoryPlayer, te ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void 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() ) );
|
||||
|
||||
ItemStack myIcon = null;
|
||||
Object target = ((AEBaseContainer) inventorySlots).getTarget();
|
||||
|
||||
if ( target instanceof WirelessTerminalGuiObject )
|
||||
{
|
||||
myIcon = AEApi.instance().items().itemWirelessTerminal.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_WIRELESS_TERM;
|
||||
}
|
||||
|
||||
if ( target instanceof PartTerminal )
|
||||
{
|
||||
myIcon = AEApi.instance().parts().partTerminal.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_ME;
|
||||
}
|
||||
|
||||
if ( target instanceof PartCraftingTerminal )
|
||||
{
|
||||
myIcon = AEApi.instance().parts().partCraftingTerminal.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
|
||||
}
|
||||
|
||||
if ( target instanceof PartPatternTerminal )
|
||||
{
|
||||
myIcon = AEApi.instance().parts().partPatternTerminal.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
}
|
||||
|
||||
if ( OriginalGui != null )
|
||||
buttonList.add( originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender ) );
|
||||
|
||||
amountToCraft = new GuiNumberBox( fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, fontRendererObj.FONT_HEIGHT, Integer.class );
|
||||
amountToCraft.setEnableBackgroundDrawing( false );
|
||||
amountToCraft.setMaxStringLength( 16 );
|
||||
amountToCraft.setTextColor( 0xFFFFFF );
|
||||
amountToCraft.setVisible( true );
|
||||
amountToCraft.setFocused( true );
|
||||
amountToCraft.setText( "1" );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
if ( btn == originalGuiBtn )
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( OriginalGui ) );
|
||||
}
|
||||
|
||||
if ( btn == next )
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketCraftRequest( Integer.parseInt( this.amountToCraft.getText() ), isShiftKeyDown() ) );
|
||||
}
|
||||
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
// nope..
|
||||
amountToCraft.setText( "1" );
|
||||
}
|
||||
catch (IOException 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 ) );
|
||||
}
|
||||
|
||||
private void addQty(int i)
|
||||
{
|
||||
try
|
||||
{
|
||||
String Out = amountToCraft.getText();
|
||||
|
||||
boolean Fixed = false;
|
||||
while (Out.startsWith( "0" ) && Out.length() > 1)
|
||||
{
|
||||
Out = Out.substring( 1 );
|
||||
Fixed = true;
|
||||
}
|
||||
|
||||
if ( Fixed )
|
||||
amountToCraft.setText( Out );
|
||||
|
||||
if ( Out.length() == 0 )
|
||||
Out = "0";
|
||||
|
||||
long result = Integer.parseInt( Out );
|
||||
|
||||
if ( result == 1 && i > 1 )
|
||||
result = 0;
|
||||
|
||||
result += i;
|
||||
if ( result < 1 )
|
||||
result = 1;
|
||||
|
||||
Out = Long.toString( result );
|
||||
Integer.parseInt( Out );
|
||||
amountToCraft.setText( Out );
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char character, int key)
|
||||
{
|
||||
if ( !this.checkHotbarKeys( key ) )
|
||||
{
|
||||
if ( key == 28 )
|
||||
{
|
||||
actionPerformed( next );
|
||||
}
|
||||
if ( (key == 211 || key == 205 || key == 203 || key == 14 || character == '-' || Character.isDigit( character ))
|
||||
&& amountToCraft.textboxKeyTyped( character, key ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
String Out = amountToCraft.getText();
|
||||
|
||||
boolean Fixed = false;
|
||||
while (Out.startsWith( "0" ) && Out.length() > 1)
|
||||
{
|
||||
Out = Out.substring( 1 );
|
||||
Fixed = true;
|
||||
}
|
||||
|
||||
if ( Fixed )
|
||||
amountToCraft.setText( Out );
|
||||
|
||||
if ( Out.length() == 0 )
|
||||
Out = "0";
|
||||
|
||||
long result = Long.parseLong( Out );
|
||||
if ( result < 0 )
|
||||
{
|
||||
amountToCraft.setText( "1" );
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
// :P
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
super.keyTyped( character, key );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
next.displayString = isShiftKeyDown() ? GuiText.Start.getLocal() : GuiText.Next.getLocal();
|
||||
|
||||
bindTexture( "guis/craftAmt.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
|
||||
try
|
||||
{
|
||||
Long.parseLong( amountToCraft.getText() );
|
||||
next.enabled = amountToCraft.getText().length() > 0;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
next.enabled = false;
|
||||
}
|
||||
|
||||
amountToCraft.drawTextBox();
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/craftAmt.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( GuiText.SelectAmount.getLocal(), 8, 6, 4210752 );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,519 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.container.implementations.ContainerCraftConfirm;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.parts.reporting.PartCraftingTerminal;
|
||||
import appeng.parts.reporting.PartPatternTerminal;
|
||||
import appeng.parts.reporting.PartTerminal;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
public class GuiCraftConfirm extends AEBaseGui
|
||||
{
|
||||
|
||||
ContainerCraftConfirm ccc;
|
||||
|
||||
int rows = 5;
|
||||
|
||||
IItemList<IAEItemStack> storage = AEApi.instance().storage().createItemList();
|
||||
IItemList<IAEItemStack> pending = AEApi.instance().storage().createItemList();
|
||||
IItemList<IAEItemStack> missing = AEApi.instance().storage().createItemList();
|
||||
|
||||
List<IAEItemStack> visual = new ArrayList();
|
||||
|
||||
GuiBridge OriginalGui;
|
||||
|
||||
boolean isAutoStart()
|
||||
{
|
||||
return ((ContainerCraftConfirm) inventorySlots).autoStart;
|
||||
}
|
||||
|
||||
boolean isSimulation()
|
||||
{
|
||||
return ((ContainerCraftConfirm) inventorySlots).simulation;
|
||||
}
|
||||
|
||||
public GuiCraftConfirm(InventoryPlayer inventoryPlayer, ITerminalHost te) {
|
||||
super( new ContainerCraftConfirm( inventoryPlayer, te ) );
|
||||
xSize = 238;
|
||||
ySize = 206;
|
||||
myScrollBar = new GuiScrollbar();
|
||||
|
||||
ccc = (ContainerCraftConfirm) this.inventorySlots;
|
||||
|
||||
if ( te instanceof WirelessTerminalGuiObject )
|
||||
OriginalGui = GuiBridge.GUI_WIRELESS_TERM;
|
||||
|
||||
if ( te instanceof PartTerminal )
|
||||
OriginalGui = GuiBridge.GUI_ME;
|
||||
|
||||
if ( te instanceof PartCraftingTerminal )
|
||||
OriginalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
|
||||
|
||||
if ( te instanceof PartPatternTerminal )
|
||||
OriginalGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
|
||||
}
|
||||
|
||||
GuiButton cancel;
|
||||
GuiButton start;
|
||||
GuiButton selectcpu;
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
start = new GuiButton( 0, this.guiLeft + 162, this.guiTop + ySize - 25, 50, 20, GuiText.Start.getLocal() );
|
||||
start.enabled = false;
|
||||
buttonList.add( start );
|
||||
|
||||
selectcpu = new GuiButton( 0, this.guiLeft + (219 - 180) / 2, this.guiTop + ySize - 68, 180, 20, GuiText.CraftingCPU.getLocal() + ": "
|
||||
+ GuiText.Automatic );
|
||||
selectcpu.enabled = false;
|
||||
buttonList.add( selectcpu );
|
||||
|
||||
if ( OriginalGui != null )
|
||||
cancel = new GuiButton( 0, this.guiLeft + 6, this.guiTop + ySize - 25, 50, 20, GuiText.Cancel.getLocal() );
|
||||
|
||||
buttonList.add( cancel );
|
||||
}
|
||||
|
||||
private void updateCPUButtonText()
|
||||
{
|
||||
String btnTextText = GuiText.CraftingCPU.getLocal() + ": " + GuiText.Automatic.getLocal();
|
||||
if ( ccc.selectedCpu >= 0 )// && ccc.selectedCpu < ccc.cpus.size() )
|
||||
{
|
||||
if ( ccc.myName.length() > 0 )
|
||||
{
|
||||
String name = ccc.myName.substring( 0, Math.min( 20, ccc.myName.length() ) );
|
||||
btnTextText = GuiText.CraftingCPU.getLocal() + ": " + name;
|
||||
}
|
||||
else
|
||||
btnTextText = GuiText.CraftingCPU.getLocal() + ": #" + ccc.selectedCpu;
|
||||
}
|
||||
|
||||
if ( ccc.noCPU )
|
||||
btnTextText = GuiText.NoCraftingCPUs.getLocal();
|
||||
|
||||
selectcpu.displayString = btnTextText;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
if ( btn == selectcpu )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "Terminal.Cpu", backwards ? "Prev" : "Next" ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
if ( btn == cancel )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( OriginalGui ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
if ( btn == start )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "Terminal.Start", "Start" ) );
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private long getTotal(IAEItemStack is)
|
||||
{
|
||||
IAEItemStack a = storage.findPrecise( is );
|
||||
IAEItemStack c = pending.findPrecise( is );
|
||||
IAEItemStack m = missing.findPrecise( is );
|
||||
|
||||
long total = 0;
|
||||
|
||||
if ( a != null )
|
||||
total += a.getStackSize();
|
||||
|
||||
if ( c != null )
|
||||
total += c.getStackSize();
|
||||
|
||||
if ( m != null )
|
||||
total += m.getStackSize();
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
public void postUpdate(List<IAEItemStack> list, byte ref)
|
||||
{
|
||||
switch (ref)
|
||||
{
|
||||
case 0:
|
||||
for (IAEItemStack l : list)
|
||||
handleInput( storage, l );
|
||||
break;
|
||||
|
||||
case 1:
|
||||
for (IAEItemStack l : list)
|
||||
handleInput( pending, l );
|
||||
break;
|
||||
|
||||
case 2:
|
||||
for (IAEItemStack l : list)
|
||||
handleInput( missing, l );
|
||||
break;
|
||||
}
|
||||
|
||||
for (IAEItemStack l : list)
|
||||
{
|
||||
long amt = getTotal( l );
|
||||
|
||||
if ( amt <= 0 )
|
||||
deleteVisualStack( l );
|
||||
else
|
||||
{
|
||||
IAEItemStack is = findVisualStack( l );
|
||||
is.setStackSize( amt );
|
||||
}
|
||||
}
|
||||
|
||||
setScrollBar();
|
||||
}
|
||||
|
||||
private void handleInput(IItemList<IAEItemStack> s, IAEItemStack l)
|
||||
{
|
||||
IAEItemStack a = s.findPrecise( l );
|
||||
|
||||
if ( l.getStackSize() <= 0 )
|
||||
{
|
||||
if ( a != null )
|
||||
a.reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( a == null )
|
||||
{
|
||||
s.add( l.copy() );
|
||||
a = s.findPrecise( l );
|
||||
}
|
||||
|
||||
if ( a != null )
|
||||
a.setStackSize( l.getStackSize() );
|
||||
}
|
||||
}
|
||||
|
||||
private IAEItemStack findVisualStack(IAEItemStack l)
|
||||
{
|
||||
Iterator<IAEItemStack> i = visual.iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
IAEItemStack o = i.next();
|
||||
if ( o.equals( l ) )
|
||||
return o;
|
||||
}
|
||||
|
||||
IAEItemStack stack = l.copy();
|
||||
visual.add( stack );
|
||||
return stack;
|
||||
}
|
||||
|
||||
private void deleteVisualStack(IAEItemStack l)
|
||||
{
|
||||
Iterator<IAEItemStack> i = visual.iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
IAEItemStack o = i.next();
|
||||
if ( o.equals( l ) )
|
||||
{
|
||||
i.remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setScrollBar()
|
||||
{
|
||||
int size = visual.size();
|
||||
|
||||
myScrollBar.setTop( 19 ).setLeft( 218 ).setHeight( 114 );
|
||||
myScrollBar.setRange( 0, (size + 2) / 3 - rows, 1 );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char character, int key)
|
||||
{
|
||||
if ( !this.checkHotbarKeys( key ) )
|
||||
{
|
||||
if ( key == 28 )
|
||||
{
|
||||
actionPerformed( start );
|
||||
}
|
||||
super.keyTyped( character, key );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
setScrollBar();
|
||||
bindTexture( "guis/craftingreport.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
int tooltip = -1;
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouse_x, int mouse_y, float btn)
|
||||
{
|
||||
updateCPUButtonText();
|
||||
|
||||
start.enabled = ccc.noCPU || isSimulation() ? false : true;
|
||||
selectcpu.enabled = isSimulation() ? false : true;
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
int gx = (width - xSize) / 2;
|
||||
int gy = (height - ySize) / 2;
|
||||
int yoff = 23;
|
||||
|
||||
tooltip = -1;
|
||||
|
||||
for (int z = 0; z <= 4 * 5; z++)
|
||||
{
|
||||
int minX = gx + 9 + x * 67;
|
||||
int minY = gy + 22 + y * yoff;
|
||||
|
||||
if ( minX < mouse_x && minX + 67 > mouse_x )
|
||||
{
|
||||
if ( minY < mouse_y && minY + yoff - 2 > mouse_y )
|
||||
{
|
||||
tooltip = z;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
x++;
|
||||
|
||||
if ( x > 2 )
|
||||
{
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
super.drawScreen( mouse_x, mouse_y, btn );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
long BytesUsed = ccc.bytesUsed;
|
||||
String byteUsed = NumberFormat.getInstance().format( BytesUsed );
|
||||
String Add = BytesUsed > 0 ? (byteUsed + " " + GuiText.BytesUsed.getLocal()) : GuiText.CalculatingWait.getLocal();
|
||||
fontRendererObj.drawString( GuiText.CraftingPlan.getLocal() + " - " + Add, 8, 7, 4210752 );
|
||||
|
||||
String dsp = null;
|
||||
|
||||
if ( isSimulation() )
|
||||
dsp = GuiText.Simulation.getLocal();
|
||||
else
|
||||
dsp = ccc.cpuBytesAvail > 0 ? (GuiText.Bytes.getLocal() + ": " + ccc.cpuBytesAvail + " : " + GuiText.CoProcessors.getLocal() + ": " + ccc.cpuCoProcessors)
|
||||
: GuiText.Bytes.getLocal() + ": N/A : " + GuiText.CoProcessors.getLocal() + ": N/A";
|
||||
|
||||
int offset = (219 - fontRendererObj.getStringWidth( dsp )) / 2;
|
||||
fontRendererObj.drawString( dsp, offset, 165, 4210752 );
|
||||
|
||||
int sectionLength = 67;
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int xo = 0 + 9;
|
||||
int yo = 0 + 22;
|
||||
int viewStart = myScrollBar.getCurrentScroll() * 3;
|
||||
int viewEnd = viewStart + 3 * rows;
|
||||
|
||||
String dspToolTip = "";
|
||||
List<String> lineList = new LinkedList();
|
||||
int toolPosX = 0;
|
||||
int toolPosY = 0;
|
||||
|
||||
int offY = 23;
|
||||
|
||||
for (int z = viewStart; z < Math.min( viewEnd, visual.size() ); z++)
|
||||
{
|
||||
IAEItemStack refStack = visual.get( z );// repo.getReferenceItem( z );
|
||||
if ( refStack != null )
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScaled( 0.5, 0.5, 0.5 );
|
||||
|
||||
IAEItemStack stored = storage.findPrecise( refStack );
|
||||
IAEItemStack pendingStack = pending.findPrecise( refStack );
|
||||
IAEItemStack missingStack = missing.findPrecise( refStack );
|
||||
|
||||
int lines = 0;
|
||||
|
||||
if ( stored != null && stored.getStackSize() > 0 )
|
||||
lines++;
|
||||
if ( pendingStack != null && pendingStack.getStackSize() > 0 )
|
||||
lines++;
|
||||
if ( pendingStack != null && pendingStack.getStackSize() > 0 )
|
||||
lines++;
|
||||
|
||||
int negY = ((lines - 1) * 5) / 2;
|
||||
int downY = 0;
|
||||
boolean red = false;
|
||||
|
||||
if ( stored != null && stored.getStackSize() > 0 )
|
||||
{
|
||||
String str = Long.toString( stored.getStackSize() );
|
||||
if ( stored.getStackSize() >= 10000 )
|
||||
str = Long.toString( stored.getStackSize() / 1000 ) + "k";
|
||||
if ( stored.getStackSize() >= 10000000 )
|
||||
str = Long.toString( stored.getStackSize() / 1000000 ) + "m";
|
||||
|
||||
str = GuiText.FromStorage.getLocal() + ": " + str;
|
||||
int w = 4 + fontRendererObj.getStringWidth( str );
|
||||
fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - ((float) w * 0.5)) * 2), (int) ((y * offY + yo
|
||||
+ 6 - negY + downY) * 2), 4210752 );
|
||||
|
||||
if ( tooltip == z - viewStart )
|
||||
lineList.add( GuiText.FromStorage.getLocal() + ": " + Long.toString( stored.getStackSize() ) );
|
||||
|
||||
downY += 5;
|
||||
}
|
||||
|
||||
if ( missingStack != null && missingStack.getStackSize() > 0 )
|
||||
{
|
||||
String str = Long.toString( missingStack.getStackSize() );
|
||||
if ( missingStack.getStackSize() >= 10000 )
|
||||
str = Long.toString( missingStack.getStackSize() / 1000 ) + "k";
|
||||
if ( missingStack.getStackSize() >= 10000000 )
|
||||
str = Long.toString( missingStack.getStackSize() / 1000000 ) + "m";
|
||||
|
||||
str = GuiText.Missing.getLocal() + ": " + str;
|
||||
int w = 4 + fontRendererObj.getStringWidth( str );
|
||||
fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - ((float) w * 0.5)) * 2), (int) ((y * offY + yo
|
||||
+ 6 - negY + downY) * 2), 4210752 );
|
||||
|
||||
if ( tooltip == z - viewStart )
|
||||
lineList.add( GuiText.Missing.getLocal() + ": " + Long.toString( missingStack.getStackSize() ) );
|
||||
|
||||
red = true;
|
||||
downY += 5;
|
||||
}
|
||||
|
||||
if ( pendingStack != null && pendingStack.getStackSize() > 0 )
|
||||
{
|
||||
String str = Long.toString( pendingStack.getStackSize() );
|
||||
if ( pendingStack.getStackSize() >= 10000 )
|
||||
str = Long.toString( pendingStack.getStackSize() / 1000 ) + "k";
|
||||
if ( pendingStack.getStackSize() >= 10000000 )
|
||||
str = Long.toString( pendingStack.getStackSize() / 1000000 ) + "m";
|
||||
|
||||
str = GuiText.ToCraft.getLocal() + ": " + str;
|
||||
int w = 4 + fontRendererObj.getStringWidth( str );
|
||||
fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - ((float) w * 0.5)) * 2), (int) ((y * offY + yo
|
||||
+ 6 - negY + downY) * 2), 4210752 );
|
||||
|
||||
if ( tooltip == z - viewStart )
|
||||
lineList.add( GuiText.ToCraft.getLocal() + ": " + Long.toString( pendingStack.getStackSize() ) );
|
||||
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
int posX = x * (1 + sectionLength) + xo + sectionLength - 19;
|
||||
int posY = y * offY + yo;
|
||||
|
||||
ItemStack is = refStack.copy().getItemStack();
|
||||
|
||||
if ( tooltip == z - viewStart )
|
||||
{
|
||||
dspToolTip = Platform.getItemDisplayName( is );
|
||||
|
||||
if ( lineList.size() > 0 )
|
||||
dspToolTip = dspToolTip + "\n" + Joiner.on( "\n" ).join( lineList );
|
||||
|
||||
toolPosX = x * (1 + sectionLength) + xo + sectionLength - 8;
|
||||
toolPosY = y * offY + yo;
|
||||
}
|
||||
|
||||
drawItem( posX, posY, is );
|
||||
|
||||
if ( red )
|
||||
{
|
||||
int startX = x * (1 + sectionLength) + xo;
|
||||
int startY = posY - 4;
|
||||
drawRect( startX, startY, startX + sectionLength, startY + offY, 0x1AFF0000 );
|
||||
}
|
||||
|
||||
x++;
|
||||
|
||||
if ( x > 2 )
|
||||
{
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( tooltip >= 0 && dspToolTip.length() > 0 )
|
||||
{
|
||||
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
||||
drawTooltip( toolPosX, toolPosY + 10, 0, dspToolTip );
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,415 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.client.gui.widgets.ISortSource;
|
||||
import appeng.container.implementations.ContainerCraftingCPU;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.util.Platform;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
|
||||
public class GuiCraftingCPU extends AEBaseGui implements ISortSource
|
||||
{
|
||||
|
||||
int rows = 6;
|
||||
|
||||
IItemList<IAEItemStack> storage = AEApi.instance().storage().createItemList();
|
||||
IItemList<IAEItemStack> active = AEApi.instance().storage().createItemList();
|
||||
IItemList<IAEItemStack> pending = AEApi.instance().storage().createItemList();
|
||||
|
||||
List<IAEItemStack> visual = new ArrayList();
|
||||
|
||||
public void clearItems()
|
||||
{
|
||||
storage = AEApi.instance().storage().createItemList();
|
||||
active = AEApi.instance().storage().createItemList();
|
||||
pending = AEApi.instance().storage().createItemList();
|
||||
visual = new ArrayList();
|
||||
}
|
||||
|
||||
protected GuiCraftingCPU(ContainerCraftingCPU container) {
|
||||
super( container );
|
||||
this.ySize = 184;
|
||||
this.xSize = 238;
|
||||
myScrollBar = new GuiScrollbar();
|
||||
}
|
||||
|
||||
public GuiCraftingCPU(InventoryPlayer inventoryPlayer, Object te) {
|
||||
this( new ContainerCraftingCPU( inventoryPlayer, te ) );
|
||||
}
|
||||
|
||||
GuiButton cancel;
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
if ( cancel == btn )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "TileCrafting.Cancel", "Cancel" ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
setScrollBar();
|
||||
cancel = new GuiButton( 0, this.guiLeft + 163, this.guiTop + ySize - 25, 50, 20, GuiText.Cancel.getLocal() );
|
||||
buttonList.add( cancel );
|
||||
}
|
||||
|
||||
private long getTotal(IAEItemStack is)
|
||||
{
|
||||
IAEItemStack a = storage.findPrecise( is );
|
||||
IAEItemStack b = active.findPrecise( is );
|
||||
IAEItemStack c = pending.findPrecise( is );
|
||||
|
||||
long total = 0;
|
||||
|
||||
if ( a != null )
|
||||
total += a.getStackSize();
|
||||
|
||||
if ( b != null )
|
||||
total += b.getStackSize();
|
||||
|
||||
if ( c != null )
|
||||
total += c.getStackSize();
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
public void postUpdate(List<IAEItemStack> list, byte ref)
|
||||
{
|
||||
switch (ref)
|
||||
{
|
||||
case 0:
|
||||
for (IAEItemStack l : list)
|
||||
handleInput( storage, l );
|
||||
break;
|
||||
|
||||
case 1:
|
||||
for (IAEItemStack l : list)
|
||||
handleInput( active, l );
|
||||
break;
|
||||
|
||||
case 2:
|
||||
for (IAEItemStack l : list)
|
||||
handleInput( pending, l );
|
||||
break;
|
||||
}
|
||||
|
||||
for (IAEItemStack l : list)
|
||||
{
|
||||
long amt = getTotal( l );
|
||||
|
||||
if ( amt <= 0 )
|
||||
deleteVisualStack( l );
|
||||
else
|
||||
{
|
||||
IAEItemStack is = findVisualStack( l );
|
||||
is.setStackSize( amt );
|
||||
}
|
||||
}
|
||||
|
||||
setScrollBar();
|
||||
}
|
||||
|
||||
private void handleInput(IItemList<IAEItemStack> s, IAEItemStack l)
|
||||
{
|
||||
IAEItemStack a = s.findPrecise( l );
|
||||
|
||||
if ( l.getStackSize() <= 0 )
|
||||
{
|
||||
if ( a != null )
|
||||
a.reset();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( a == null )
|
||||
{
|
||||
s.add( l.copy() );
|
||||
a = s.findPrecise( l );
|
||||
}
|
||||
|
||||
if ( a != null )
|
||||
a.setStackSize( l.getStackSize() );
|
||||
}
|
||||
}
|
||||
|
||||
private IAEItemStack findVisualStack(IAEItemStack l)
|
||||
{
|
||||
Iterator<IAEItemStack> i = visual.iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
IAEItemStack o = i.next();
|
||||
if ( o.equals( l ) )
|
||||
return o;
|
||||
}
|
||||
|
||||
IAEItemStack stack = l.copy();
|
||||
visual.add( stack );
|
||||
return stack;
|
||||
}
|
||||
|
||||
private void deleteVisualStack(IAEItemStack l)
|
||||
{
|
||||
Iterator<IAEItemStack> i = visual.iterator();
|
||||
while (i.hasNext())
|
||||
{
|
||||
IAEItemStack o = i.next();
|
||||
if ( o.equals( l ) )
|
||||
{
|
||||
i.remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setScrollBar()
|
||||
{
|
||||
int size = visual.size();
|
||||
|
||||
myScrollBar.setTop( 19 ).setLeft( 218 ).setHeight( 137 );
|
||||
myScrollBar.setRange( 0, (size + 2) / 3 - rows, 1 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/craftingcpu.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
int tooltip = -1;
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouse_x, int mouse_y, float btn)
|
||||
{
|
||||
cancel.enabled = !visual.isEmpty();
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
int gx = (width - xSize) / 2;
|
||||
int gy = (height - ySize) / 2;
|
||||
int yoff = 23;
|
||||
|
||||
tooltip = -1;
|
||||
|
||||
for (int z = 0; z <= 4 * 5; z++)
|
||||
{
|
||||
int minX = gx + 9 + x * 67;
|
||||
int minY = gy + 22 + y * yoff;
|
||||
|
||||
if ( minX < mouse_x && minX + 67 > mouse_x )
|
||||
{
|
||||
if ( minY < mouse_y && minY + yoff - 2 > mouse_y )
|
||||
{
|
||||
tooltip = z;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
x++;
|
||||
|
||||
if ( x > 2 )
|
||||
{
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
super.drawScreen( mouse_x, mouse_y, btn );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.CraftingStatus.getLocal() ), 8, 7, 4210752 );
|
||||
|
||||
int sectionLength = 67;
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int xo = 0 + 9;
|
||||
int yo = 0 + 22;
|
||||
int viewStart = myScrollBar.getCurrentScroll() * 3;
|
||||
int viewEnd = viewStart + 3 * 6;
|
||||
|
||||
String dspToolTip = "";
|
||||
List<String> lineList = new LinkedList();
|
||||
int toolPosX = 0;
|
||||
int toolPosY = 0;
|
||||
|
||||
int offY = 23;
|
||||
|
||||
for (int z = viewStart; z < Math.min( viewEnd, visual.size() ); z++)
|
||||
{
|
||||
IAEItemStack refStack = visual.get( z );// repo.getReferenceItem( z );
|
||||
if ( refStack != null )
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScaled( 0.5, 0.5, 0.5 );
|
||||
|
||||
IAEItemStack stored = storage.findPrecise( refStack );
|
||||
IAEItemStack activeStack = active.findPrecise( refStack );
|
||||
IAEItemStack pendingStack = pending.findPrecise( refStack );
|
||||
|
||||
int lines = 0;
|
||||
|
||||
if ( stored != null && stored.getStackSize() > 0 )
|
||||
lines++;
|
||||
if ( activeStack != null && activeStack.getStackSize() > 0 )
|
||||
lines++;
|
||||
if ( pendingStack != null && pendingStack.getStackSize() > 0 )
|
||||
lines++;
|
||||
|
||||
int negY = ((lines - 1) * 5) / 2;
|
||||
int downY = 0;
|
||||
|
||||
if ( stored != null && stored.getStackSize() > 0 )
|
||||
{
|
||||
String str = Long.toString( stored.getStackSize() );
|
||||
if ( stored.getStackSize() >= 10000 )
|
||||
str = Long.toString( stored.getStackSize() / 1000 ) + "k";
|
||||
if ( stored.getStackSize() >= 10000000 )
|
||||
str = Long.toString( stored.getStackSize() / 1000000 ) + "m";
|
||||
|
||||
str = GuiText.Stored.getLocal() + ": " + str;
|
||||
int w = 4 + fontRendererObj.getStringWidth( str );
|
||||
fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - ((float) w * 0.5)) * 2), (int) ((y * offY + yo
|
||||
+ 6 - negY + downY) * 2), 4210752 );
|
||||
|
||||
if ( tooltip == z - viewStart )
|
||||
lineList.add( GuiText.Stored.getLocal() + ": " + Long.toString( stored.getStackSize() ) );
|
||||
|
||||
downY += 5;
|
||||
}
|
||||
|
||||
if ( activeStack != null && activeStack.getStackSize() > 0 )
|
||||
{
|
||||
String str = Long.toString( activeStack.getStackSize() );
|
||||
if ( activeStack.getStackSize() >= 10000 )
|
||||
str = Long.toString( activeStack.getStackSize() / 1000 ) + "k";
|
||||
if ( activeStack.getStackSize() >= 10000000 )
|
||||
str = Long.toString( activeStack.getStackSize() / 1000000 ) + "m";
|
||||
|
||||
str = GuiText.Crafting.getLocal() + ": " + str;
|
||||
int w = 4 + fontRendererObj.getStringWidth( str );
|
||||
fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - ((float) w * 0.5)) * 2), (int) ((y * offY + yo
|
||||
+ 6 - negY + downY) * 2), 4210752 );
|
||||
|
||||
if ( tooltip == z - viewStart )
|
||||
lineList.add( GuiText.Crafting.getLocal() + ": " + Long.toString( activeStack.getStackSize() ) );
|
||||
|
||||
downY += 5;
|
||||
}
|
||||
|
||||
if ( pendingStack != null && pendingStack.getStackSize() > 0 )
|
||||
{
|
||||
String str = Long.toString( pendingStack.getStackSize() );
|
||||
if ( pendingStack.getStackSize() >= 10000 )
|
||||
str = Long.toString( pendingStack.getStackSize() / 1000 ) + "k";
|
||||
if ( pendingStack.getStackSize() >= 10000000 )
|
||||
str = Long.toString( pendingStack.getStackSize() / 1000000 ) + "m";
|
||||
|
||||
str = GuiText.Scheduled.getLocal() + ": " + str;
|
||||
int w = 4 + fontRendererObj.getStringWidth( str );
|
||||
fontRendererObj.drawString( str, (int) ((x * (1 + sectionLength) + xo + sectionLength - 19 - ((float) w * 0.5)) * 2), (int) ((y * offY + yo
|
||||
+ 6 - negY + downY) * 2), 4210752 );
|
||||
|
||||
if ( tooltip == z - viewStart )
|
||||
lineList.add( GuiText.Scheduled.getLocal() + ": " + Long.toString( pendingStack.getStackSize() ) );
|
||||
|
||||
}
|
||||
|
||||
GL11.glPopMatrix();
|
||||
int posX = x * (1 + sectionLength) + xo + sectionLength - 19;
|
||||
int posY = y * offY + yo;
|
||||
|
||||
ItemStack is = refStack.copy().getItemStack();
|
||||
|
||||
if ( tooltip == z - viewStart )
|
||||
{
|
||||
dspToolTip = Platform.getItemDisplayName( is );
|
||||
|
||||
if ( lineList.size() > 0 )
|
||||
dspToolTip = dspToolTip + "\n" + Joiner.on( "\n" ).join( lineList );
|
||||
|
||||
toolPosX = x * (1 + sectionLength) + xo + sectionLength - 8;
|
||||
toolPosY = y * offY + yo;
|
||||
}
|
||||
|
||||
drawItem( posX, posY, is );
|
||||
|
||||
x++;
|
||||
|
||||
if ( x > 2 )
|
||||
{
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( tooltip >= 0 && dspToolTip.length() > 0 )
|
||||
{
|
||||
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
||||
drawTooltip( toolPosX, toolPosY + 10, 0, dspToolTip );
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getSortBy()
|
||||
{
|
||||
return SortOrder.NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getSortDir()
|
||||
{
|
||||
return SortDir.ASCENDING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getSortDisplay()
|
||||
{
|
||||
return ViewItems.ALL;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,151 @@
|
||||
/**
|
||||
*
|
||||
*/
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerCraftingStatus;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.parts.reporting.PartCraftingTerminal;
|
||||
import appeng.parts.reporting.PartPatternTerminal;
|
||||
import appeng.parts.reporting.PartTerminal;
|
||||
|
||||
public class GuiCraftingStatus extends GuiCraftingCPU
|
||||
{
|
||||
|
||||
ContainerCraftingStatus ccc;
|
||||
GuiButton selectcpu;
|
||||
|
||||
GuiTabButton originalGuiBtn;
|
||||
GuiBridge OriginalGui;
|
||||
ItemStack myIcon = null;
|
||||
|
||||
public GuiCraftingStatus(InventoryPlayer inventoryPlayer, ITerminalHost te) {
|
||||
super( new ContainerCraftingStatus( inventoryPlayer, te ) );
|
||||
|
||||
ccc = (ContainerCraftingStatus) inventorySlots;
|
||||
Object target = ccc.getTarget();
|
||||
|
||||
if ( target instanceof WirelessTerminalGuiObject )
|
||||
{
|
||||
myIcon = AEApi.instance().items().itemWirelessTerminal.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_WIRELESS_TERM;
|
||||
}
|
||||
|
||||
if ( target instanceof PartTerminal )
|
||||
{
|
||||
myIcon = AEApi.instance().parts().partTerminal.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_ME;
|
||||
}
|
||||
|
||||
if ( target instanceof PartCraftingTerminal )
|
||||
{
|
||||
myIcon = AEApi.instance().parts().partCraftingTerminal.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_CRAFTING_TERMINAL;
|
||||
}
|
||||
|
||||
if ( target instanceof PartPatternTerminal )
|
||||
{
|
||||
myIcon = AEApi.instance().parts().partPatternTerminal.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_PATTERN_TERMINAL;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
if ( btn == selectcpu )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "Terminal.Cpu", backwards ? "Prev" : "Next" ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
if ( btn == originalGuiBtn )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( OriginalGui ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getGuiDisplayName(String in)
|
||||
{
|
||||
return in; // the cup name is on the button
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
selectcpu = new GuiButton( 0, this.guiLeft + 8, this.guiTop + ySize - 25, 150, 20, GuiText.CraftingCPU.getLocal() + ": " + GuiText.NoCraftingCPUs );
|
||||
// selectcpu.enabled = false;
|
||||
buttonList.add( selectcpu );
|
||||
|
||||
if ( myIcon != null )
|
||||
{
|
||||
buttonList.add( originalGuiBtn = new GuiTabButton( this.guiLeft + 213, this.guiTop - 4, myIcon, myIcon.getDisplayName(), itemRender ) );
|
||||
originalGuiBtn.hideEdge = 13;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateCPUButtonText()
|
||||
{
|
||||
String btnTextText = GuiText.NoCraftingJobs.getLocal();
|
||||
|
||||
if ( ccc.selectedCpu >= 0 )// && ccc.selectedCpu < ccc.cpus.size() )
|
||||
{
|
||||
if ( ccc.myName.length() > 0 )
|
||||
{
|
||||
String name = ccc.myName.substring( 0, Math.min( 20, ccc.myName.length() ) );
|
||||
btnTextText = GuiText.CPUs.getLocal() + ": " + name;
|
||||
}
|
||||
else
|
||||
btnTextText = GuiText.CPUs.getLocal() + ": #" + ccc.selectedCpu;
|
||||
}
|
||||
|
||||
if ( ccc.noCPU )
|
||||
btnTextText = GuiText.NoCraftingJobs.getLocal();
|
||||
|
||||
selectcpu.displayString = btnTextText;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouse_x, int mouse_y, float btn)
|
||||
{
|
||||
updateCPUButtonText();
|
||||
super.drawScreen( mouse_x, mouse_y, btn );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.container.implementations.ContainerCraftingTerm;
|
||||
import appeng.container.slot.SlotCraftingMatrix;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketInventoryAction;
|
||||
import appeng.helpers.InventoryAction;
|
||||
|
||||
public class GuiCraftingTerm extends GuiMEMonitorable
|
||||
{
|
||||
|
||||
GuiImgButton clearBtn;
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
buttonList.add( clearBtn = new GuiImgButton( this.guiLeft + 92, this.guiTop + this.ySize - 156, Settings.ACTIONS, ActionItems.STASH ) );
|
||||
clearBtn.halfSize = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
if ( clearBtn == btn )
|
||||
{
|
||||
Slot s = null;
|
||||
Container c = inventorySlots;
|
||||
for (Object j : c.inventorySlots)
|
||||
{
|
||||
if ( j instanceof SlotCraftingMatrix )
|
||||
s = (Slot) j;
|
||||
}
|
||||
|
||||
if ( s != null )
|
||||
{
|
||||
PacketInventoryAction p;
|
||||
try
|
||||
{
|
||||
p = new PacketInventoryAction( InventoryAction.MOVE_REGION, s.slotNumber, 0 );
|
||||
NetworkHandler.instance.sendToServer( p );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public GuiCraftingTerm(InventoryPlayer inventoryPlayer, ITerminalHost te) {
|
||||
super( inventoryPlayer, te, new ContainerCraftingTerm( inventoryPlayer, te ) );
|
||||
reservedSpace = 73;
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/crafting.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
super.drawFG( offsetX, offsetY, mouseX, mouseY );
|
||||
fontRendererObj.drawString( GuiText.CraftingTerminal.getLocal(), 8, ySize - 96 + 1 - reservedSpace, 4210752 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerDrive;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.tile.storage.TileDrive;
|
||||
|
||||
public class GuiDrive extends AEBaseGui
|
||||
{
|
||||
|
||||
GuiTabButton priority;
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton par1GuiButton)
|
||||
{
|
||||
super.actionPerformed( par1GuiButton );
|
||||
|
||||
if ( par1GuiButton == priority )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
buttonList.add( priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), itemRender ) );
|
||||
}
|
||||
|
||||
public GuiDrive(InventoryPlayer inventoryPlayer, TileDrive te) {
|
||||
super( new ContainerDrive( inventoryPlayer, te ) );
|
||||
this.ySize = 199;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/drive.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.Drive.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerFormationPlane;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.parts.automation.PartFormationPlane;
|
||||
|
||||
public class GuiFormationPlane extends GuiUpgradeable
|
||||
{
|
||||
|
||||
GuiTabButton priority;
|
||||
|
||||
public GuiFormationPlane(InventoryPlayer inventoryPlayer, PartFormationPlane te) {
|
||||
super( new ContainerFormationPlane( inventoryPlayer, te ) );
|
||||
this.ySize = 251;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
super.drawBG( offsetX, offsetY, mouseX, mouseY );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.FormationPlane.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
|
||||
if ( fuzzyMode != null )
|
||||
fuzzyMode.set( cvb.fzMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
fuzzyMode = new GuiImgButton( this.guiLeft - 18, guiTop + 28, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
|
||||
buttonList.add( priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), itemRender ) );
|
||||
|
||||
buttonList.add( fuzzyMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
if ( btn == priority )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/storagebus.png";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.container.implementations.ContainerGrinder;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.tile.grindstone.TileGrinder;
|
||||
|
||||
public class GuiGrinder extends AEBaseGui
|
||||
{
|
||||
|
||||
public GuiGrinder(InventoryPlayer inventoryPlayer, TileGrinder te) {
|
||||
super( new ContainerGrinder( inventoryPlayer, te ) );
|
||||
this.ySize = 176;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/grinder.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.GrindStone.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.FullnessMode;
|
||||
import appeng.api.config.OperationMode;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.container.implementations.ContainerIOPort;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import appeng.tile.storage.TileIOPort;
|
||||
|
||||
public class GuiIOPort extends GuiUpgradeable
|
||||
{
|
||||
|
||||
GuiImgButton fullMode;
|
||||
GuiImgButton operationMode;
|
||||
|
||||
public GuiIOPort(InventoryPlayer inventoryPlayer, TileIOPort te) {
|
||||
super( new ContainerIOPort( inventoryPlayer, te ) );
|
||||
this.ySize = 166;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
super.drawBG( offsetX, offsetY, mouseX, mouseY );
|
||||
this.drawItem( offsetX + 66 - 8, offsetY + 17, AEApi.instance().items().itemCell1k.stack( 1 ) );
|
||||
this.drawItem( offsetX + 94 + 8, offsetY + 17, AEApi.instance().blocks().blockDrive.stack( 1 ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.IOPort.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
|
||||
if ( redstoneMode != null )
|
||||
redstoneMode.set( cvb.rsMode );
|
||||
|
||||
if ( operationMode != null )
|
||||
operationMode.set( ((ContainerIOPort) cvb).opMode );
|
||||
|
||||
if ( fullMode != null )
|
||||
fullMode.set( ((ContainerIOPort) cvb).fMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
redstoneMode = new GuiImgButton( this.guiLeft - 18, guiTop + 28, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
|
||||
fullMode = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.FULLNESS_MODE, FullnessMode.EMPTY );
|
||||
operationMode = new GuiImgButton( this.guiLeft + 80, guiTop + 17, Settings.OPERATION_MODE, OperationMode.EMPTY );
|
||||
|
||||
buttonList.add( operationMode );
|
||||
buttonList.add( redstoneMode );
|
||||
buttonList.add( fullMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
try
|
||||
{
|
||||
if ( btn == fullMode )
|
||||
NetworkHandler.instance.sendToServer( new PacketConfigButton( fullMode.getSetting(), backwards ) );
|
||||
|
||||
if ( btn == operationMode )
|
||||
NetworkHandler.instance.sendToServer( new PacketConfigButton( operationMode.getSetting(), backwards ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/ioport.png";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiProgressBar;
|
||||
import appeng.client.gui.widgets.GuiProgressBar.Direction;
|
||||
import appeng.container.implementations.ContainerInscriber;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.tile.misc.TileInscriber;
|
||||
|
||||
public class GuiInscriber extends AEBaseGui
|
||||
{
|
||||
|
||||
ContainerInscriber cvc;
|
||||
GuiProgressBar pb;
|
||||
|
||||
public GuiInscriber(InventoryPlayer inventoryPlayer, TileInscriber te) {
|
||||
super( new ContainerInscriber( inventoryPlayer, te ) );
|
||||
cvc = (ContainerInscriber) inventorySlots;
|
||||
this.ySize = 176;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
pb = new GuiProgressBar( "guis/inscriber.png", 135, 39, 179, 39, 6, 18, Direction.VERTICAL );
|
||||
this.buttonList.add( pb );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/inscriber.png" );
|
||||
pb.xPosition = 135 + guiLeft;
|
||||
pb.yPosition = 39 + guiTop;
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
pb.max = cvc.maxProcessingTime;
|
||||
pb.current = cvc.processingTime;
|
||||
pb.FullMsg = (pb.current * 100 / pb.max) + "%";
|
||||
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.Inscriber.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.client.gui.widgets.GuiToggleButton;
|
||||
import appeng.container.implementations.ContainerInterface;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
|
||||
public class GuiInterface extends GuiUpgradeable
|
||||
{
|
||||
|
||||
GuiTabButton priority;
|
||||
GuiImgButton BlockMode;
|
||||
GuiToggleButton interfaceMode;
|
||||
|
||||
public GuiInterface(InventoryPlayer inventoryPlayer, IInterfaceHost te) {
|
||||
super( new ContainerInterface( inventoryPlayer, te ) );
|
||||
this.ySize = 211;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
if ( btn == priority )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if ( btn == interfaceMode )
|
||||
NetworkHandler.instance.sendToServer( new PacketConfigButton( Settings.INTERFACE_TERMINAL, backwards ) );
|
||||
|
||||
if ( btn == BlockMode )
|
||||
NetworkHandler.instance.sendToServer( new PacketConfigButton( BlockMode.getSetting(), backwards ) );
|
||||
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), itemRender );
|
||||
buttonList.add( priority );
|
||||
|
||||
BlockMode = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.BLOCK, YesNo.NO );
|
||||
buttonList.add( BlockMode );
|
||||
|
||||
interfaceMode = new GuiToggleButton( this.guiLeft - 18, guiTop + 26, 84, 85, GuiText.InterfaceTerminal.getLocal(),
|
||||
GuiText.InterfaceTerminalHint.getLocal() );
|
||||
buttonList.add( interfaceMode );
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/interface.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
if ( BlockMode != null )
|
||||
BlockMode.set( ((ContainerInterface) cvb).bMode );
|
||||
|
||||
if ( interfaceMode != null )
|
||||
interfaceMode.setState( ((ContainerInterface) cvb).iTermMode == YesNo.YES );
|
||||
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.Interface.getLocal() ), 8, 6, 4210752 );
|
||||
|
||||
fontRendererObj.drawString( GuiText.Config.getLocal(), 18, 6 + 11 + 7, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.StoredItems.getLocal(), 18, 6 + 60 + 7, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.Patterns.getLocal(), 8, 6 + 73 + 7, 4210752 );
|
||||
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.client.me.ClientDCInternalInv;
|
||||
import appeng.client.me.SlotDisconnected;
|
||||
import appeng.container.implementations.ContainerInterfaceTerminal;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.parts.reporting.PartMonitor;
|
||||
|
||||
import com.google.common.collect.HashMultimap;
|
||||
|
||||
public class GuiInterfaceTerminal extends AEBaseGui
|
||||
{
|
||||
|
||||
HashMap<Long, ClientDCInternalInv> byId = new HashMap();
|
||||
HashMultimap<String, ClientDCInternalInv> byName = HashMultimap.create();
|
||||
ArrayList<String> names = new ArrayList();
|
||||
|
||||
ArrayList<Object> lines = new ArrayList();
|
||||
|
||||
private int getTotalRows()
|
||||
{
|
||||
return names.size() + byId.size();// unique names, and each inv row.
|
||||
}
|
||||
|
||||
public GuiInterfaceTerminal(InventoryPlayer inventoryPlayer, PartMonitor te) {
|
||||
super( new ContainerInterfaceTerminal( inventoryPlayer, te ) );
|
||||
myScrollBar = new GuiScrollbar();
|
||||
xSize = 195;
|
||||
ySize = 222;
|
||||
}
|
||||
|
||||
LinkedList<SlotDisconnected> dcSlots = new LinkedList();
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
myScrollBar.setLeft( 175 );
|
||||
myScrollBar.setHeight( 106 );
|
||||
myScrollBar.setTop( 18 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/interfaceterminal.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
|
||||
int offset = 17;
|
||||
int ex = myScrollBar.getCurrentScroll();
|
||||
int linesOnPage = 6;
|
||||
|
||||
for (int x = 0; x < linesOnPage; x++)
|
||||
{
|
||||
if ( ex + x < lines.size() )
|
||||
{
|
||||
Object lineObj = lines.get( ex + x );
|
||||
if ( lineObj instanceof ClientDCInternalInv )
|
||||
{
|
||||
ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
|
||||
|
||||
GL11.glColor4f( 1, 1, 1, 1 );
|
||||
for (int z = 0; z < inv.inv.getSizeInventory(); z++)
|
||||
this.drawTexturedModalRect( offsetX + z * 18 + 7, offsetY + offset, 7, 139, 18, 18 );
|
||||
}
|
||||
}
|
||||
offset += 18;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.InterfaceTerminal.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
|
||||
int offset = 17;
|
||||
|
||||
// for (String name : lines)
|
||||
int ex = myScrollBar.getCurrentScroll();
|
||||
int linesOnPage = 6;
|
||||
|
||||
Iterator<Object> o = inventorySlots.inventorySlots.iterator();
|
||||
while (o.hasNext())
|
||||
{
|
||||
if ( o.next() instanceof SlotDisconnected )
|
||||
o.remove();
|
||||
}
|
||||
|
||||
for (int x = 0; x < linesOnPage; x++)
|
||||
{
|
||||
if ( ex + x < lines.size() )
|
||||
{
|
||||
Object lineObj = lines.get( ex + x );
|
||||
if ( lineObj instanceof ClientDCInternalInv )
|
||||
{
|
||||
ClientDCInternalInv inv = (ClientDCInternalInv) lineObj;
|
||||
for (int z = 0; z < inv.inv.getSizeInventory(); z++)
|
||||
{
|
||||
inventorySlots.inventorySlots.add( new SlotDisconnected( inv, z, z * 18 + 8, 1 + offset ) );
|
||||
}
|
||||
}
|
||||
else if ( lineObj instanceof String )
|
||||
{
|
||||
String name = (String) lineObj;
|
||||
int rows = byName.get( name ).size();
|
||||
if ( rows > 1 )
|
||||
name = name + " (" + rows + ")";
|
||||
|
||||
while (name.length() > 2 && fontRendererObj.getStringWidth( name ) > 155)
|
||||
name = name.substring( 0, name.length() - 1 );
|
||||
|
||||
fontRendererObj.drawString( name, 10, 6 + offset, 4210752 );
|
||||
}
|
||||
offset += 18;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean refreshList = false;
|
||||
|
||||
public void postUpdate(NBTTagCompound in)
|
||||
{
|
||||
if ( in.getBoolean( "clear" ) )
|
||||
{
|
||||
byId.clear();
|
||||
refreshList = true;
|
||||
}
|
||||
|
||||
for (Object oKey : in.func_150296_c())
|
||||
{
|
||||
String key = (String) oKey;
|
||||
if ( key.startsWith( "=" ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
long id = Long.parseLong( key.substring( 1 ), Character.MAX_RADIX );
|
||||
NBTTagCompound invData = in.getCompoundTag( key );
|
||||
ClientDCInternalInv current = getById( id, invData.getLong( "sortBy" ), invData.getString( "un" ) );
|
||||
|
||||
for (int x = 0; x < current.inv.getSizeInventory(); x++)
|
||||
{
|
||||
String which = Integer.toString( x );
|
||||
if ( invData.hasKey( which ) )
|
||||
current.inv.setInventorySlotContents( x, ItemStack.loadItemStackFromNBT( invData.getCompoundTag( which ) ) );
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( refreshList )
|
||||
{
|
||||
refreshList = false;
|
||||
|
||||
byName.clear();
|
||||
for (ClientDCInternalInv o : byId.values())
|
||||
byName.put( o.getName(), o );
|
||||
|
||||
names.clear();
|
||||
names.addAll( byName.keySet() );
|
||||
|
||||
Collections.sort( names );
|
||||
|
||||
lines = new ArrayList( getTotalRows() );
|
||||
for (String n : names)
|
||||
{
|
||||
lines.add( n );
|
||||
|
||||
ArrayList<ClientDCInternalInv> lset = new ArrayList();
|
||||
lset.addAll( byName.get( n ) );
|
||||
|
||||
Collections.sort( lset );
|
||||
|
||||
for (ClientDCInternalInv i : lset)
|
||||
{
|
||||
lines.add( i );
|
||||
}
|
||||
}
|
||||
|
||||
myScrollBar.setRange( 0, getTotalRows() - 6, 2 );
|
||||
}
|
||||
}
|
||||
|
||||
private ClientDCInternalInv getById(long id, long sortBy, String string)
|
||||
{
|
||||
ClientDCInternalInv o = byId.get( id );
|
||||
|
||||
if ( o == null )
|
||||
{
|
||||
byId.put( id, o = new ClientDCInternalInv( 9, id, sortBy, string ) );
|
||||
refreshList = true;
|
||||
}
|
||||
|
||||
return o;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,238 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.LevelType;
|
||||
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.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;
|
||||
import appeng.parts.automation.PartLevelEmitter;
|
||||
|
||||
public class GuiLevelEmitter extends GuiUpgradeable
|
||||
{
|
||||
|
||||
GuiNumberBox level;
|
||||
|
||||
GuiButton plus1, plus10, plus100, plus1000;
|
||||
GuiButton minus1, minus10, minus100, minus1000;
|
||||
|
||||
GuiImgButton levelMode;
|
||||
GuiImgButton craftingMode;
|
||||
|
||||
public GuiLevelEmitter(InventoryPlayer inventoryPlayer, PartLevelEmitter te) {
|
||||
super( new ContainerLevelEmitter( inventoryPlayer, te ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
level = new GuiNumberBox( fontRendererObj, this.guiLeft + 24, this.guiTop + 43, 79, fontRendererObj.FONT_HEIGHT, Long.class );
|
||||
level.setEnableBackgroundDrawing( false );
|
||||
level.setMaxStringLength( 16 );
|
||||
level.setTextColor( 0xFFFFFF );
|
||||
level.setVisible( true );
|
||||
level.setFocused( true );
|
||||
((ContainerLevelEmitter) inventorySlots).setTextField( level );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
levelMode = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL );
|
||||
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 );
|
||||
craftingMode = new GuiImgButton( this.guiLeft - 18, guiTop + 48, Settings.CRAFT_VIA_REDSTONE, YesNo.NO );
|
||||
|
||||
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( 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 );
|
||||
buttonList.add( fuzzyMode );
|
||||
buttonList.add( craftingMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
try
|
||||
{
|
||||
if ( btn == craftingMode )
|
||||
NetworkHandler.instance.sendToServer( new PacketConfigButton( craftingMode.getSetting(), backwards ) );
|
||||
|
||||
if ( btn == levelMode )
|
||||
NetworkHandler.instance.sendToServer( new PacketConfigButton( levelMode.getSetting(), backwards ) );
|
||||
}
|
||||
catch (IOException 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 ) );
|
||||
}
|
||||
|
||||
private void addQty(long i)
|
||||
{
|
||||
try
|
||||
{
|
||||
String Out = level.getText();
|
||||
|
||||
boolean Fixed = false;
|
||||
while (Out.startsWith( "0" ) && Out.length() > 1)
|
||||
{
|
||||
Out = Out.substring( 1 );
|
||||
Fixed = true;
|
||||
}
|
||||
|
||||
if ( Fixed )
|
||||
level.setText( Out );
|
||||
|
||||
if ( Out.length() == 0 )
|
||||
Out = "0";
|
||||
|
||||
long result = Long.parseLong( Out );
|
||||
result += i;
|
||||
if ( result < 0 )
|
||||
result = 0;
|
||||
|
||||
level.setText( Out = Long.toString( result ) );
|
||||
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "LevelEmitter.Value", Out ) );
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
// nope..
|
||||
level.setText( "0" );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
protected void handleButtonVisibility()
|
||||
{
|
||||
craftingMode.setVisibility( bc.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 );
|
||||
fuzzyMode.setVisibility( bc.getInstalledUpgrades( Upgrades.FUZZY ) > 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char character, int key)
|
||||
{
|
||||
if ( !this.checkHotbarKeys( key ) )
|
||||
{
|
||||
if ( (key == 211 || key == 205 || key == 203 || key == 14 || Character.isDigit( character )) && level.textboxKeyTyped( character, key ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
String Out = level.getText();
|
||||
|
||||
boolean Fixed = false;
|
||||
while (Out.startsWith( "0" ) && Out.length() > 1)
|
||||
{
|
||||
Out = Out.substring( 1 );
|
||||
Fixed = true;
|
||||
}
|
||||
|
||||
if ( Fixed )
|
||||
level.setText( Out );
|
||||
|
||||
if ( Out.length() == 0 )
|
||||
Out = "0";
|
||||
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "LevelEmitter.Value", Out ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
super.keyTyped( character, key );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
boolean notCraftingMode = bc.getInstalledUpgrades( Upgrades.CRAFTING ) == 0;
|
||||
|
||||
// configure enabled status...
|
||||
level.setEnabled( notCraftingMode );
|
||||
plus1.enabled = notCraftingMode;
|
||||
plus10.enabled = notCraftingMode;
|
||||
plus100.enabled = notCraftingMode;
|
||||
plus1000.enabled = notCraftingMode;
|
||||
minus1.enabled = notCraftingMode;
|
||||
minus10.enabled = notCraftingMode;
|
||||
minus100.enabled = notCraftingMode;
|
||||
minus1000.enabled = notCraftingMode;
|
||||
levelMode.enabled = notCraftingMode;
|
||||
redstoneMode.enabled = notCraftingMode;
|
||||
|
||||
super.drawFG( offsetX, offsetY, mouseX, mouseY );
|
||||
|
||||
if ( craftingMode != null )
|
||||
craftingMode.set( ((ContainerLevelEmitter) cvb).cmType );
|
||||
|
||||
if ( levelMode != null )
|
||||
levelMode.set( ((ContainerLevelEmitter) cvb).lvType );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
super.drawBG( offsetX, offsetY, mouseX, mouseY );
|
||||
level.drawTextBox();
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/lvlemitter.png";
|
||||
}
|
||||
|
||||
protected GuiText getName()
|
||||
{
|
||||
return GuiText.LevelEmitter;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
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;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.tile.crafting.TileMolecularAssembler;
|
||||
|
||||
public class GuiMAC extends GuiUpgradeable
|
||||
{
|
||||
|
||||
ContainerMAC cmac;
|
||||
GuiProgressBar pb;
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
pb = new GuiProgressBar( "guis/mac.png", 139, 36, 148, 201, 6, 18, Direction.VERTICAL );
|
||||
this.buttonList.add( pb );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
pb.xPosition = 148 + guiLeft;
|
||||
pb.yPosition = 48 + guiTop;
|
||||
super.drawBG( offsetX, offsetY, mouseX, mouseY );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
pb.max = 100;
|
||||
pb.current = cmac.craftProgress;
|
||||
pb.FullMsg = pb.current + "%";
|
||||
|
||||
super.drawFG( offsetX, offsetY, mouseX, mouseY );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
redstoneMode = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
|
||||
buttonList.add( redstoneMode );
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/mac.png";
|
||||
}
|
||||
|
||||
public GuiMAC(InventoryPlayer inventoryPlayer, TileMolecularAssembler te) {
|
||||
super( new ContainerMAC( inventoryPlayer, te ) );
|
||||
this.ySize = 197;
|
||||
this.cmac = (ContainerMAC) this.inventorySlots;
|
||||
}
|
||||
|
||||
protected GuiText getName()
|
||||
{
|
||||
return GuiText.MolecularAssembler;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,472 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.config.SearchBoxMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.TerminalStyle;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.api.implementations.tiles.IMEChest;
|
||||
import appeng.api.implementations.tiles.IViewCellStorage;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
import appeng.client.gui.AEBaseMEGui;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiScrollbar;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.client.gui.widgets.ISortSource;
|
||||
import appeng.client.gui.widgets.MEGuiTextField;
|
||||
import appeng.client.me.InternalSlotME;
|
||||
import appeng.client.me.ItemRepo;
|
||||
import appeng.container.implementations.ContainerMEMonitorable;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.container.slot.SlotCraftingMatrix;
|
||||
import appeng.container.slot.SlotFakeCraftingMatrix;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.WirelessTerminalGuiObject;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.parts.reporting.PartTerminal;
|
||||
import appeng.tile.misc.TileSecurity;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class GuiMEMonitorable extends AEBaseMEGui implements ISortSource, IConfigManagerHost
|
||||
{
|
||||
|
||||
GuiTabButton craftingStatusBtn;
|
||||
|
||||
MEGuiTextField searchField;
|
||||
private static String memoryText = "";
|
||||
|
||||
public static int CraftingGridOffsetX;
|
||||
public static int CraftingGridOffsetY;
|
||||
|
||||
ItemRepo repo;
|
||||
|
||||
GuiText myName;
|
||||
|
||||
int xoffset = 9;
|
||||
int perRow = 9;
|
||||
int reservedSpace = 0;
|
||||
int lowerTextureOffset = 0;
|
||||
boolean customSortOrder = true;
|
||||
|
||||
int rows = 0;
|
||||
int maxRows = Integer.MAX_VALUE;
|
||||
|
||||
int standardSize;
|
||||
|
||||
IConfigManager configSrc;
|
||||
|
||||
GuiImgButton ViewBox;
|
||||
GuiImgButton SortByBox;
|
||||
GuiImgButton SortDirBox;
|
||||
|
||||
GuiImgButton searchBoxSettings, terminalStyleBox;
|
||||
boolean viewCell;
|
||||
|
||||
ItemStack myCurrentViewCells[] = new ItemStack[5];
|
||||
ContainerMEMonitorable mecontainer;
|
||||
|
||||
public GuiMEMonitorable(InventoryPlayer inventoryPlayer, ITerminalHost te) {
|
||||
this( inventoryPlayer, te, new ContainerMEMonitorable( inventoryPlayer, te ) );
|
||||
}
|
||||
|
||||
public GuiMEMonitorable(InventoryPlayer inventoryPlayer, ITerminalHost te, ContainerMEMonitorable c) {
|
||||
|
||||
super( c );
|
||||
myScrollBar = new GuiScrollbar();
|
||||
repo = new ItemRepo( myScrollBar, this );
|
||||
|
||||
xSize = 185;
|
||||
ySize = 204;
|
||||
|
||||
if ( te instanceof IViewCellStorage )
|
||||
xSize += 33;
|
||||
|
||||
standardSize = xSize;
|
||||
|
||||
configSrc = ((IConfigurableObject) inventorySlots).getConfigManager();
|
||||
(mecontainer = (ContainerMEMonitorable) inventorySlots).gui = this;
|
||||
|
||||
viewCell = te instanceof IViewCellStorage;
|
||||
|
||||
if ( te instanceof TileSecurity )
|
||||
myName = GuiText.Security;
|
||||
else if ( te instanceof WirelessTerminalGuiObject )
|
||||
myName = GuiText.WirelessTerminal;
|
||||
else if ( te instanceof IPortableCell )
|
||||
myName = GuiText.PortableCell;
|
||||
else if ( te instanceof IMEChest )
|
||||
myName = GuiText.Chest;
|
||||
else if ( te instanceof PartTerminal )
|
||||
myName = GuiText.Terminal;
|
||||
}
|
||||
|
||||
public void postUpdate(List<IAEItemStack> list)
|
||||
{
|
||||
for (IAEItemStack is : list)
|
||||
repo.postUpdate( is );
|
||||
|
||||
repo.updateView();
|
||||
setScrollBar();
|
||||
}
|
||||
|
||||
private void setScrollBar()
|
||||
{
|
||||
myScrollBar.setTop( 18 ).setLeft( 175 ).setHeight( rows * 18 - 2 );
|
||||
myScrollBar.setRange( 0, (repo.size() + perRow - 1) / perRow - rows, Math.max( 1, rows / 6 ) );
|
||||
}
|
||||
|
||||
public void re_init()
|
||||
{
|
||||
this.buttonList.clear();
|
||||
this.initGui();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onGuiClosed()
|
||||
{
|
||||
super.onGuiClosed();
|
||||
memoryText = searchField.getText();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
maxRows = getMaxRows();
|
||||
perRow = AEConfig.instance.getConfigManager().getSetting( Settings.TERMINAL_STYLE ) != TerminalStyle.FULL ? 9 : 9 + ((width - standardSize) / 18);
|
||||
|
||||
boolean hasNEI = AppEng.instance.isIntegrationEnabled( IntegrationType.NEI );
|
||||
|
||||
int NEI = hasNEI ? 0 : 0;
|
||||
int top = hasNEI ? 22 : 0;
|
||||
|
||||
int magicNumber = 114 + 1;
|
||||
int extraSpace = height - magicNumber - NEI - top - reservedSpace;
|
||||
|
||||
rows = (int) Math.floor( extraSpace / 18 );
|
||||
if ( rows > maxRows )
|
||||
{
|
||||
top += (rows - maxRows) * 18 / 2;
|
||||
rows = maxRows;
|
||||
}
|
||||
|
||||
if ( hasNEI )
|
||||
rows--;
|
||||
|
||||
if ( rows < 3 )
|
||||
rows = 3;
|
||||
|
||||
meSlots.clear();
|
||||
for (int y = 0; y < rows; y++)
|
||||
{
|
||||
for (int x = 0; x < perRow; x++)
|
||||
{
|
||||
meSlots.add( new InternalSlotME( repo, x + y * perRow, xoffset + x * 18, 18 + y * 18 ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( AEConfig.instance.getConfigManager().getSetting( Settings.TERMINAL_STYLE ) != TerminalStyle.FULL )
|
||||
this.xSize = standardSize + ((perRow - 9) * 18);
|
||||
else
|
||||
this.xSize = standardSize;
|
||||
|
||||
super.initGui();
|
||||
// full size : 204
|
||||
// extra slots : 72
|
||||
// slot 18
|
||||
|
||||
this.ySize = magicNumber + rows * 18 + reservedSpace;
|
||||
// this.guiTop = top;
|
||||
int unusedSpace = height - ySize;
|
||||
guiTop = (int) Math.floor( (float) unusedSpace / (unusedSpace < 0 ? 3.8f : 2.0f) );
|
||||
|
||||
int offset = guiTop + 8;
|
||||
|
||||
if ( customSortOrder )
|
||||
{
|
||||
buttonList.add( SortByBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_BY, configSrc.getSetting( Settings.SORT_BY ) ) );
|
||||
offset += 20;
|
||||
}
|
||||
|
||||
if ( viewCell || this instanceof GuiWirelessTerm )
|
||||
{
|
||||
buttonList.add( ViewBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.VIEW_MODE, configSrc.getSetting( Settings.VIEW_MODE ) ) );
|
||||
offset += 20;
|
||||
}
|
||||
|
||||
buttonList.add( SortDirBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.SORT_DIRECTION, configSrc.getSetting( Settings.SORT_DIRECTION ) ) );
|
||||
offset += 20;
|
||||
|
||||
buttonList.add( searchBoxSettings = new GuiImgButton( this.guiLeft - 18, offset, Settings.SEARCH_MODE, AEConfig.instance.settings
|
||||
.getSetting( Settings.SEARCH_MODE ) ) );
|
||||
offset += 20;
|
||||
|
||||
if ( !(this instanceof GuiMEPortableCell) || this instanceof GuiWirelessTerm )
|
||||
{
|
||||
buttonList.add( terminalStyleBox = new GuiImgButton( this.guiLeft - 18, offset, Settings.TERMINAL_STYLE, AEConfig.instance.settings
|
||||
.getSetting( Settings.TERMINAL_STYLE ) ) );
|
||||
}
|
||||
|
||||
searchField = new MEGuiTextField( fontRendererObj, this.guiLeft + Math.max( 82, xoffset ), this.guiTop + 6, 89, fontRendererObj.FONT_HEIGHT );
|
||||
searchField.setEnableBackgroundDrawing( false );
|
||||
searchField.setMaxStringLength( 25 );
|
||||
searchField.setTextColor( 0xFFFFFF );
|
||||
searchField.setVisible( true );
|
||||
|
||||
if ( viewCell || this instanceof GuiWirelessTerm )
|
||||
{
|
||||
buttonList.add( craftingStatusBtn = new GuiTabButton( this.guiLeft + 170, this.guiTop - 4, 2 + 11 * 16, GuiText.CraftingStatus.getLocal(),
|
||||
itemRender ) );
|
||||
craftingStatusBtn.hideEdge = 13;
|
||||
}
|
||||
|
||||
// Enum setting = AEConfig.instance.getSetting( "Terminal", SearchBoxMode.class, SearchBoxMode.AUTOSEARCH );
|
||||
Enum setting = AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE );
|
||||
searchField.setFocused( SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.NEI_AUTOSEARCH == setting );
|
||||
|
||||
if ( isSubGui() )
|
||||
{
|
||||
searchField.setText( memoryText );
|
||||
repo.searchString = memoryText;
|
||||
repo.updateView();
|
||||
setScrollBar();
|
||||
}
|
||||
|
||||
CraftingGridOffsetX = Integer.MAX_VALUE;
|
||||
CraftingGridOffsetY = Integer.MAX_VALUE;
|
||||
|
||||
for (Object s : inventorySlots.inventorySlots)
|
||||
{
|
||||
if ( s instanceof AppEngSlot )
|
||||
{
|
||||
if ( ((AppEngSlot) s).xDisplayPosition < 197 )
|
||||
repositionSlot( (AppEngSlot) s );
|
||||
}
|
||||
|
||||
if ( s instanceof SlotCraftingMatrix || s instanceof SlotFakeCraftingMatrix )
|
||||
{
|
||||
Slot g = (Slot) s;
|
||||
if ( g.xDisplayPosition > 0 && g.yDisplayPosition > 0 )
|
||||
{
|
||||
CraftingGridOffsetX = Math.min( CraftingGridOffsetX, g.xDisplayPosition );
|
||||
CraftingGridOffsetY = Math.min( CraftingGridOffsetY, g.yDisplayPosition );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CraftingGridOffsetX -= 25;
|
||||
CraftingGridOffsetY -= 6;
|
||||
}
|
||||
|
||||
protected void repositionSlot(AppEngSlot s)
|
||||
{
|
||||
s.yDisplayPosition = s.defY + ySize - 78 - 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
if ( btn == craftingStatusBtn )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_CRAFTING_STATUS ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
if ( btn instanceof GuiImgButton )
|
||||
{
|
||||
boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
GuiImgButton iBtn = (GuiImgButton) btn;
|
||||
if ( iBtn.getSetting() != Settings.ACTIONS )
|
||||
{
|
||||
Enum cv = iBtn.getCurrentValue();
|
||||
Enum next = Platform.rotateEnum( cv, backwards, iBtn.getSetting().getPossibleValues() );
|
||||
|
||||
if ( btn == terminalStyleBox )
|
||||
AEConfig.instance.settings.putSetting( iBtn.getSetting(), next );
|
||||
else if ( btn == searchBoxSettings )
|
||||
AEConfig.instance.settings.putSetting( iBtn.getSetting(), next );
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( iBtn.getSetting().name(), next.name() ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
iBtn.set( next );
|
||||
|
||||
if ( next.getClass() == SearchBoxMode.class || next.getClass() == TerminalStyle.class )
|
||||
re_init();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void mouseClicked(int xCoord, int yCoord, int btn)
|
||||
{
|
||||
Enum setting = AEConfig.instance.settings.getSetting( Settings.SEARCH_MODE );
|
||||
if ( !(SearchBoxMode.AUTOSEARCH == setting || SearchBoxMode.NEI_AUTOSEARCH == setting) )
|
||||
searchField.mouseClicked( xCoord, yCoord, btn );
|
||||
|
||||
if ( btn == 1 && searchField.isMouseIn( xCoord, yCoord ) )
|
||||
{
|
||||
searchField.setText( "" );
|
||||
repo.searchString = "";
|
||||
repo.updateView();
|
||||
setScrollBar();
|
||||
}
|
||||
|
||||
super.mouseClicked( xCoord, yCoord, btn );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char character, int key)
|
||||
{
|
||||
if ( !this.checkHotbarKeys( key ) )
|
||||
{
|
||||
if ( character == ' ' && this.searchField.getText().length() == 0 )
|
||||
return;
|
||||
|
||||
if ( searchField.textboxKeyTyped( character, key ) )
|
||||
{
|
||||
repo.searchString = this.searchField.getText();
|
||||
repo.updateView();
|
||||
setScrollBar();
|
||||
}
|
||||
else
|
||||
{
|
||||
super.keyTyped( character, key );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen()
|
||||
{
|
||||
repo.setPower( mecontainer.hasPower );
|
||||
super.updateScreen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
int x_width = 197;
|
||||
|
||||
bindTexture( getBackground() );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, x_width, 18 );
|
||||
|
||||
if ( viewCell || (this instanceof GuiSecurity) )
|
||||
this.drawTexturedModalRect( offsetX + x_width, offsetY, x_width, 0, 46, 128 );
|
||||
|
||||
for (int x = 0; x < rows; x++)
|
||||
this.drawTexturedModalRect( offsetX, offsetY + 18 + x * 18, 0, 18, x_width, 18 );
|
||||
|
||||
this.drawTexturedModalRect( offsetX, offsetY + 16 + rows * 18 + lowerTextureOffset, 0, 106 - 18 - 18, x_width, 99 + reservedSpace - lowerTextureOffset );
|
||||
|
||||
if ( viewCell )
|
||||
{
|
||||
boolean update = false;
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
if ( myCurrentViewCells[i] != mecontainer.cellView[i].getStack() )
|
||||
{
|
||||
update = true;
|
||||
myCurrentViewCells[i] = mecontainer.cellView[i].getStack();
|
||||
}
|
||||
}
|
||||
|
||||
if ( update )
|
||||
repo.setViewCell( myCurrentViewCells );
|
||||
}
|
||||
|
||||
if ( searchField != null )
|
||||
searchField.drawTextBox();
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/terminal.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( myName.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getSortBy()
|
||||
{
|
||||
return configSrc.getSetting( Settings.SORT_BY );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getSortDir()
|
||||
{
|
||||
return configSrc.getSetting( Settings.SORT_DIRECTION );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getSortDisplay()
|
||||
{
|
||||
return configSrc.getSetting( Settings.VIEW_MODE );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateSetting(IConfigManager manager, Enum settingName, Enum newValue)
|
||||
{
|
||||
if ( SortByBox != null )
|
||||
SortByBox.set( configSrc.getSetting( Settings.SORT_BY ) );
|
||||
|
||||
if ( SortDirBox != null )
|
||||
SortDirBox.set( configSrc.getSetting( Settings.SORT_DIRECTION ) );
|
||||
|
||||
if ( ViewBox != null )
|
||||
ViewBox.set( configSrc.getSetting( Settings.VIEW_MODE ) );
|
||||
|
||||
repo.updateView();
|
||||
}
|
||||
|
||||
protected boolean isPowered()
|
||||
{
|
||||
return repo.hasPower();
|
||||
}
|
||||
|
||||
int getMaxRows()
|
||||
{
|
||||
return AEConfig.instance.getConfigManager().getSetting( Settings.TERMINAL_STYLE ) == TerminalStyle.SMALL ? 6 : Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
import appeng.container.implementations.ContainerMEPortableCell;
|
||||
|
||||
public class GuiMEPortableCell extends GuiMEMonitorable
|
||||
{
|
||||
|
||||
public GuiMEPortableCell(InventoryPlayer inventoryPlayer, IPortableCell te) {
|
||||
super( inventoryPlayer, te, new ContainerMEPortableCell( inventoryPlayer, null ) );
|
||||
}
|
||||
|
||||
int defaultGetMaxRows()
|
||||
{
|
||||
return super.getMaxRows();
|
||||
}
|
||||
|
||||
@Override
|
||||
int getMaxRows()
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,295 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.implementations.guiobjects.INetworkTool;
|
||||
import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
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;
|
||||
|
||||
public class GuiNetworkStatus extends AEBaseGui implements ISortSource
|
||||
{
|
||||
|
||||
ItemRepo repo;
|
||||
GuiImgButton units;
|
||||
|
||||
int rows = 4;
|
||||
|
||||
public GuiNetworkStatus(InventoryPlayer inventoryPlayer, INetworkTool te) {
|
||||
super( new ContainerNetworkStatus( inventoryPlayer, te ) );
|
||||
this.ySize = 153;
|
||||
this.xSize = 195;
|
||||
myScrollBar = new GuiScrollbar();
|
||||
repo = new ItemRepo( myScrollBar, this );
|
||||
repo.rowSize = 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
if ( btn == units )
|
||||
{
|
||||
AEConfig.instance.nextPowerUnit( backwards );
|
||||
units.set( AEConfig.instance.selectedPowerUnit() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
units = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.POWER_UNITS, AEConfig.instance.selectedPowerUnit() );
|
||||
buttonList.add( units );
|
||||
}
|
||||
|
||||
public void postUpdate(List<IAEItemStack> list)
|
||||
{
|
||||
repo.clear();
|
||||
|
||||
for (IAEItemStack is : list)
|
||||
repo.postUpdate( is );
|
||||
|
||||
repo.updateView();
|
||||
setScrollBar();
|
||||
}
|
||||
|
||||
private void setScrollBar()
|
||||
{
|
||||
int size = repo.size();
|
||||
myScrollBar.setTop( 39 ).setLeft( 175 ).setHeight( 78 );
|
||||
myScrollBar.setRange( 0, (size + 4) / 5 - rows, 1 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/networkstatus.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
int tooltip = -1;
|
||||
|
||||
@Override
|
||||
public void drawScreen(int mouse_x, int mouse_y, float btn)
|
||||
{
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
int gx = (width - xSize) / 2;
|
||||
int gy = (height - ySize) / 2;
|
||||
|
||||
tooltip = -1;
|
||||
|
||||
for (int z = 0; z <= 4 * 5; z++)
|
||||
{
|
||||
int minX = gx + 14 + x * 31;
|
||||
int minY = gy + 41 + y * 18;
|
||||
|
||||
if ( minX < mouse_x && minX + 28 > mouse_x )
|
||||
{
|
||||
if ( minY < mouse_y && minY + 20 > mouse_y )
|
||||
{
|
||||
tooltip = z;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
x++;
|
||||
|
||||
if ( x > 4 )
|
||||
{
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
super.drawScreen( mouse_x, mouse_y, btn );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
ContainerNetworkStatus ns = (ContainerNetworkStatus) inventorySlots;
|
||||
|
||||
fontRendererObj.drawString( GuiText.NetworkDetails.getLocal(), 8, 6, 4210752 );
|
||||
|
||||
fontRendererObj.drawString( GuiText.StoredPower.getLocal() + ": " + Platform.formatPowerLong( ns.currentPower, false ), 13, 16, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.MaxPower.getLocal() + ": " + Platform.formatPowerLong( ns.maxPower, false ), 13, 26, 4210752 );
|
||||
|
||||
fontRendererObj.drawString( GuiText.PowerInputRate.getLocal() + ": " + Platform.formatPowerLong( ns.avgAddition, true ), 13, 143 - 10, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.PowerUsageRate.getLocal() + ": " + Platform.formatPowerLong( ns.powerUsage, true ), 13, 143 - 20, 4210752 );
|
||||
|
||||
int sectionLength = 30;
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int xo = 0 + 12;
|
||||
int yo = 0 + 42;
|
||||
int viewStart = 0;// myScrollBar.getCurrentScroll() * 5;
|
||||
int viewEnd = viewStart + 5 * 4;
|
||||
|
||||
String ToolTip = "";
|
||||
int toolPosX = 0;
|
||||
int toolPosY = 0;
|
||||
|
||||
for (int z = viewStart; z < Math.min( viewEnd, repo.size() ); z++)
|
||||
{
|
||||
IAEItemStack refStack = repo.getReferenceItem( z );
|
||||
if ( refStack != null )
|
||||
{
|
||||
GL11.glPushMatrix();
|
||||
GL11.glScaled( 0.5, 0.5, 0.5 );
|
||||
|
||||
String str = Long.toString( refStack.getStackSize() );
|
||||
if ( refStack.getStackSize() >= 10000 )
|
||||
str = Long.toString( refStack.getStackSize() / 1000 ) + "k";
|
||||
|
||||
int w = fontRendererObj.getStringWidth( str );
|
||||
fontRendererObj.drawString( str, (int) ((x * sectionLength + xo + sectionLength - 19 - ((float) w * 0.5)) * 2), (int) ((y * 18 + yo + 6) * 2),
|
||||
4210752 );
|
||||
|
||||
GL11.glPopMatrix();
|
||||
int posX = x * sectionLength + xo + sectionLength - 18;
|
||||
int posY = y * 18 + yo;
|
||||
|
||||
if ( tooltip == z - viewStart )
|
||||
{
|
||||
ToolTip = Platform.getItemDisplayName( repo.getItem( z ) );
|
||||
|
||||
ToolTip = ToolTip + ("\n" + GuiText.Installed.getLocal() + ": " + (refStack.getStackSize()));
|
||||
if ( refStack.getCountRequestable() > 0 )
|
||||
ToolTip = ToolTip + ("\n" + GuiText.EnergyDrain.getLocal() + ": " + Platform.formatPowerLong( refStack.getCountRequestable(), true ));
|
||||
|
||||
toolPosX = x * sectionLength + xo + sectionLength - 8;
|
||||
toolPosY = y * 18 + yo;
|
||||
}
|
||||
|
||||
drawItem( posX, posY, repo.getItem( z ) );
|
||||
|
||||
x++;
|
||||
|
||||
if ( x > 4 )
|
||||
{
|
||||
y++;
|
||||
x = 0;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if ( tooltip >= 0 && ToolTip.length() > 0 )
|
||||
{
|
||||
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
|
||||
drawTooltip( toolPosX, toolPosY + 10, 0, ToolTip );
|
||||
GL11.glPopAttrib();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// @Override - NEI
|
||||
public List<String> handleItemTooltip(ItemStack stack, int mousex, int mousey, List<String> currenttip)
|
||||
{
|
||||
if ( stack != null )
|
||||
{
|
||||
Slot s = getSlot( mousex, mousey );
|
||||
if ( s instanceof SlotME )
|
||||
{
|
||||
IAEItemStack myStack = null;
|
||||
|
||||
try
|
||||
{
|
||||
SlotME theSlotField = (SlotME) s;
|
||||
myStack = theSlotField.getAEStack();
|
||||
}
|
||||
catch (Throwable ignore)
|
||||
{
|
||||
}
|
||||
|
||||
if ( myStack != null )
|
||||
{
|
||||
while (currenttip.size() > 1)
|
||||
currenttip.remove( 1 );
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
return currenttip;
|
||||
}
|
||||
|
||||
// Vanilla version...
|
||||
protected void drawItemStackTooltip(ItemStack stack, int x, int y)
|
||||
{
|
||||
Slot s = getSlot( x, y );
|
||||
if ( s instanceof SlotME && stack != null )
|
||||
{
|
||||
IAEItemStack myStack = null;
|
||||
|
||||
try
|
||||
{
|
||||
SlotME theSlotField = (SlotME) s;
|
||||
myStack = theSlotField.getAEStack();
|
||||
}
|
||||
catch (Throwable ignore)
|
||||
{
|
||||
}
|
||||
|
||||
if ( myStack != null )
|
||||
{
|
||||
List currenttip = stack.getTooltip( this.mc.thePlayer, this.mc.gameSettings.advancedItemTooltips );
|
||||
|
||||
while (currenttip.size() > 1)
|
||||
currenttip.remove( 1 );
|
||||
|
||||
currenttip.add( GuiText.Installed.getLocal() + ": " + (myStack.getStackSize()) );
|
||||
currenttip.add( GuiText.EnergyDrain.getLocal() + ": " + Platform.formatPowerLong( myStack.getCountRequestable(), true ) );
|
||||
|
||||
drawTooltip( x, y, 0, join( currenttip, "\n" ) );
|
||||
}
|
||||
}
|
||||
// super.drawItemStackTooltip( stack, x, y );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getSortBy()
|
||||
{
|
||||
return SortOrder.NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getSortDir()
|
||||
{
|
||||
return SortDir.ASCENDING;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getSortDisplay()
|
||||
{
|
||||
return ViewItems.ALL;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.api.implementations.guiobjects.INetworkTool;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiToggleButton;
|
||||
import appeng.container.implementations.ContainerNetworkTool;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
|
||||
public class GuiNetworkTool extends AEBaseGui
|
||||
{
|
||||
|
||||
GuiToggleButton tFacades;
|
||||
|
||||
public GuiNetworkTool(InventoryPlayer inventoryPlayer, INetworkTool te) {
|
||||
super( new ContainerNetworkTool( inventoryPlayer, te ) );
|
||||
this.ySize = 166;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
try
|
||||
{
|
||||
if ( btn == tFacades )
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "NetworkTool", "Toggle" ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
tFacades = new GuiToggleButton( this.guiLeft - 18, guiTop + 8, 23, 22, GuiText.TransparentFacades.getLocal(), GuiText.TransparentFacadesHint.getLocal() );
|
||||
|
||||
buttonList.add( tFacades );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/toolbox.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
if ( tFacades != null )
|
||||
tFacades.setState( ((ContainerNetworkTool) inventorySlots).facadeMode );
|
||||
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.NetworkTool.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerPatternTerm;
|
||||
import appeng.container.slot.AppEngSlot;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
|
||||
public class GuiPatternTerm extends GuiMEMonitorable
|
||||
{
|
||||
|
||||
ContainerPatternTerm container;
|
||||
|
||||
GuiTabButton tabCraftButton;
|
||||
GuiTabButton tabProcessButton;
|
||||
// GuiImgButton substitutionsBtn;
|
||||
GuiImgButton encodeBtn;
|
||||
GuiImgButton clearBtn;
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
buttonList.add( tabCraftButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.crafting_table ),
|
||||
GuiText.CraftingPattern.getLocal(), itemRender ) );
|
||||
buttonList.add( tabProcessButton = new GuiTabButton( this.guiLeft + 173, this.guiTop + this.ySize - 177, new ItemStack( Blocks.furnace ),
|
||||
GuiText.ProcessingPattern.getLocal(), itemRender ) );
|
||||
|
||||
// buttonList.add( substitutionsBtn = new GuiImgButton( this.guiLeft + 84, this.guiTop + this.ySize - 163,
|
||||
// Settings.ACTIONS, ActionItems.SUBSTITUTION ) );
|
||||
// substitutionsBtn.halfSize = true;
|
||||
|
||||
buttonList.add( clearBtn = new GuiImgButton( this.guiLeft + 74, this.guiTop + this.ySize - 163, Settings.ACTIONS, ActionItems.CLOSE ) );
|
||||
clearBtn.halfSize = true;
|
||||
|
||||
buttonList.add( encodeBtn = new GuiImgButton( this.guiLeft + 147, this.guiTop + this.ySize - 142, Settings.ACTIONS, ActionItems.ENCODE ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
if ( tabCraftButton == btn || tabProcessButton == btn )
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PatternTerminal.CraftMode", tabProcessButton == btn ? "1" : "0" ) );
|
||||
}
|
||||
|
||||
if ( encodeBtn == btn )
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PatternTerminal.Encode", "1" ) );
|
||||
}
|
||||
|
||||
if ( clearBtn == btn )
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PatternTerminal.Clear", "1" ) );
|
||||
}
|
||||
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// if ( substitutionsBtn == btn )
|
||||
// {
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
protected void repositionSlot(AppEngSlot s)
|
||||
{
|
||||
if ( s.isPlayerSide() )
|
||||
s.yDisplayPosition = s.defY + ySize - 78 - 5;
|
||||
else
|
||||
s.yDisplayPosition = s.defY + ySize - 78 - 3;
|
||||
}
|
||||
|
||||
public GuiPatternTerm(InventoryPlayer inventoryPlayer, ITerminalHost te) {
|
||||
super( inventoryPlayer, te, new ContainerPatternTerm( inventoryPlayer, te ) );
|
||||
container = (ContainerPatternTerm) this.inventorySlots;
|
||||
reservedSpace = 81;
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
if ( container.craftingMode )
|
||||
return "guis/pattern.png";
|
||||
return "guis/pattern2.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
if ( !container.craftingMode )
|
||||
{
|
||||
tabCraftButton.visible = false;
|
||||
tabProcessButton.visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
tabCraftButton.visible = true;
|
||||
tabProcessButton.visible = false;
|
||||
}
|
||||
|
||||
super.drawFG( offsetX, offsetY, mouseX, mouseY );
|
||||
fontRendererObj.drawString( GuiText.PatternTerminal.getLocal(), 8, ySize - 96 + 2 - reservedSpace, 4210752 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,234 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import appeng.api.AEApi;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiNumberBox;
|
||||
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;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketSwitchGuis;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.helpers.IPriorityHost;
|
||||
import appeng.parts.automation.PartFormationPlane;
|
||||
import appeng.parts.misc.PartInterface;
|
||||
import appeng.parts.misc.PartStorageBus;
|
||||
import appeng.tile.misc.TileInterface;
|
||||
import appeng.tile.storage.TileChest;
|
||||
import appeng.tile.storage.TileDrive;
|
||||
|
||||
public class GuiPriority extends AEBaseGui
|
||||
{
|
||||
|
||||
GuiNumberBox priority;
|
||||
GuiTabButton originalGuiBtn;
|
||||
|
||||
GuiButton plus1, plus10, plus100, plus1000;
|
||||
GuiButton minus1, minus10, minus100, minus1000;
|
||||
|
||||
GuiBridge OriginalGui;
|
||||
|
||||
public GuiPriority(InventoryPlayer inventoryPlayer, IPriorityHost te) {
|
||||
super( new ContainerPriority( inventoryPlayer, te ) );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
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( 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();
|
||||
|
||||
if ( target instanceof PartStorageBus )
|
||||
{
|
||||
myIcon = AEApi.instance().parts().partStorageBus.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_STORAGEBUS;
|
||||
}
|
||||
|
||||
if ( target instanceof PartFormationPlane )
|
||||
{
|
||||
myIcon = AEApi.instance().parts().partFormationPlane.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_FPLANE;
|
||||
}
|
||||
|
||||
if ( target instanceof TileDrive )
|
||||
{
|
||||
myIcon = AEApi.instance().blocks().blockDrive.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_DRIVE;
|
||||
}
|
||||
|
||||
if ( target instanceof TileChest )
|
||||
{
|
||||
myIcon = AEApi.instance().blocks().blockChest.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_CHEST;
|
||||
}
|
||||
|
||||
if ( target instanceof TileInterface )
|
||||
{
|
||||
myIcon = AEApi.instance().blocks().blockInterface.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_INTERFACE;
|
||||
}
|
||||
|
||||
if ( target instanceof PartInterface )
|
||||
{
|
||||
myIcon = AEApi.instance().parts().partInterface.stack( 1 );
|
||||
OriginalGui = GuiBridge.GUI_INTERFACE;
|
||||
}
|
||||
|
||||
if ( OriginalGui != null )
|
||||
buttonList.add( originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRender ) );
|
||||
|
||||
priority = new GuiNumberBox( fontRendererObj, this.guiLeft + 62, this.guiTop + 57, 59, fontRendererObj.FONT_HEIGHT, Long.class );
|
||||
priority.setEnableBackgroundDrawing( false );
|
||||
priority.setMaxStringLength( 16 );
|
||||
priority.setTextColor( 0xFFFFFF );
|
||||
priority.setVisible( true );
|
||||
priority.setFocused( true );
|
||||
((ContainerPriority) inventorySlots).setTextField( priority );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
if ( btn == originalGuiBtn )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( OriginalGui ) );
|
||||
}
|
||||
catch (IOException 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 ) );
|
||||
}
|
||||
|
||||
private void addQty(int i)
|
||||
{
|
||||
try
|
||||
{
|
||||
String Out = priority.getText();
|
||||
|
||||
boolean Fixed = false;
|
||||
while (Out.startsWith( "0" ) && Out.length() > 1)
|
||||
{
|
||||
Out = Out.substring( 1 );
|
||||
Fixed = true;
|
||||
}
|
||||
|
||||
if ( Fixed )
|
||||
priority.setText( Out );
|
||||
|
||||
if ( Out.length() == 0 )
|
||||
Out = "0";
|
||||
|
||||
long result = Long.parseLong( Out );
|
||||
result += i;
|
||||
|
||||
priority.setText( Out = Long.toString( result ) );
|
||||
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PriorityHost.Priority", Out ) );
|
||||
}
|
||||
catch(NumberFormatException e )
|
||||
{
|
||||
// nope..
|
||||
priority.setText( "0" );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char character, int key)
|
||||
{
|
||||
if ( !this.checkHotbarKeys( key ) )
|
||||
{
|
||||
if ( (key == 211 || key == 205 || key == 203 || key == 14 || character == '-' || Character.isDigit( character ))
|
||||
&& priority.textboxKeyTyped( character, key ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
String Out = priority.getText();
|
||||
|
||||
boolean Fixed = false;
|
||||
while (Out.startsWith( "0" ) && Out.length() > 1)
|
||||
{
|
||||
Out = Out.substring( 1 );
|
||||
Fixed = true;
|
||||
}
|
||||
|
||||
if ( Fixed )
|
||||
priority.setText( Out );
|
||||
|
||||
if ( Out.length() == 0 )
|
||||
Out = "0";
|
||||
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "PriorityHost.Priority", Out ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
super.keyTyped( character, key );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/priority.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
|
||||
priority.drawTextBox();
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/priority.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( GuiText.Priority.getLocal(), 8, 6, 4210752 );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.container.implementations.ContainerQNB;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.tile.qnb.TileQuantumBridge;
|
||||
|
||||
public class GuiQNB extends AEBaseGui
|
||||
{
|
||||
|
||||
public GuiQNB(InventoryPlayer inventoryPlayer, TileQuantumBridge te) {
|
||||
super( new ContainerQNB( inventoryPlayer, te ) );
|
||||
this.ySize = 166;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/chest.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.QuantumLinkChamber.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.container.implementations.ContainerQuartzKnife;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.items.contents.QuartzKnifeObj;
|
||||
|
||||
public class GuiQuartzKnife extends AEBaseGui
|
||||
{
|
||||
|
||||
GuiTextField name;
|
||||
|
||||
public GuiQuartzKnife(InventoryPlayer inventoryPlayer, QuartzKnifeObj te) {
|
||||
super( new ContainerQuartzKnife( inventoryPlayer, te ) );
|
||||
this.ySize = 184;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
name = new GuiTextField( fontRendererObj, this.guiLeft + 24, this.guiTop + 32, 79, fontRendererObj.FONT_HEIGHT );
|
||||
name.setEnableBackgroundDrawing( false );
|
||||
name.setMaxStringLength( 32 );
|
||||
name.setTextColor( 0xFFFFFF );
|
||||
name.setVisible( true );
|
||||
name.setFocused( true );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/quartzknife.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
name.drawTextBox();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void keyTyped(char character, int key)
|
||||
{
|
||||
if ( name.textboxKeyTyped( character, key ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
String Out = name.getText();
|
||||
((ContainerQuartzKnife) inventorySlots).setName( Out );
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "QuartzKnife.Name", Out ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
super.keyTyped( character, key );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.QuartzCuttingKnife.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,110 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.api.config.SecurityPermissions;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.client.gui.widgets.GuiToggleButton;
|
||||
import appeng.container.implementations.ContainerSecurity;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
|
||||
public class GuiSecurity extends GuiMEMonitorable
|
||||
{
|
||||
|
||||
public GuiSecurity(InventoryPlayer inventoryPlayer, ITerminalHost te) {
|
||||
super( inventoryPlayer, te, new ContainerSecurity( inventoryPlayer, te ) );
|
||||
customSortOrder = false;
|
||||
reservedSpace = 33;
|
||||
|
||||
// increase size so that the slot is over the gui.
|
||||
xSize += 56;
|
||||
standardSize = xSize;
|
||||
}
|
||||
|
||||
GuiToggleButton inject, extract, craft, build, security;
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
int top = this.guiTop + this.ySize - 116;
|
||||
buttonList.add( inject = new GuiToggleButton( this.guiLeft + 56 + 18 * 0, top, 11 * 16 + 0, 12 * 16 + 0, SecurityPermissions.INJECT
|
||||
.getUnlocalizedName(), SecurityPermissions.INJECT.getUnlocalizedTip() ) );
|
||||
|
||||
buttonList.add( extract = new GuiToggleButton( this.guiLeft + 56 + 18 * 1, top, 11 * 16 + 1, 12 * 16 + 1, SecurityPermissions.EXTRACT
|
||||
.getUnlocalizedName(), SecurityPermissions.EXTRACT.getUnlocalizedTip() ) );
|
||||
|
||||
buttonList.add( craft = new GuiToggleButton( this.guiLeft + 56 + 18 * 2, top, 11 * 16 + 2, 12 * 16 + 2, SecurityPermissions.CRAFT.getUnlocalizedName(),
|
||||
SecurityPermissions.CRAFT.getUnlocalizedTip() ) );
|
||||
|
||||
buttonList.add( build = new GuiToggleButton( this.guiLeft + 56 + 18 * 3, top, 11 * 16 + 3, 12 * 16 + 3, SecurityPermissions.BUILD.getUnlocalizedName(),
|
||||
SecurityPermissions.BUILD.getUnlocalizedTip() ) );
|
||||
|
||||
buttonList.add( security = new GuiToggleButton( this.guiLeft + 56 + 18 * 4, top, 11 * 16 + 4, 12 * 16 + 4, SecurityPermissions.SECURITY
|
||||
.getUnlocalizedName(), SecurityPermissions.SECURITY.getUnlocalizedTip() ) );
|
||||
}
|
||||
|
||||
protected void actionPerformed(net.minecraft.client.gui.GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
SecurityPermissions toggleSetting = null;
|
||||
|
||||
if ( btn == inject )
|
||||
toggleSetting = SecurityPermissions.INJECT;
|
||||
if ( btn == extract )
|
||||
toggleSetting = SecurityPermissions.EXTRACT;
|
||||
if ( btn == craft )
|
||||
toggleSetting = SecurityPermissions.CRAFT;
|
||||
if ( btn == build )
|
||||
toggleSetting = SecurityPermissions.BUILD;
|
||||
if ( btn == security )
|
||||
toggleSetting = SecurityPermissions.SECURITY;
|
||||
|
||||
if ( toggleSetting != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "TileSecurity.ToggleOption", toggleSetting.name() ) );
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
ContainerSecurity cs = (ContainerSecurity) inventorySlots;
|
||||
|
||||
inject.setState( (cs.security & (1 << SecurityPermissions.INJECT.ordinal())) > 0 );
|
||||
extract.setState( (cs.security & (1 << SecurityPermissions.EXTRACT.ordinal())) > 0 );
|
||||
craft.setState( (cs.security & (1 << SecurityPermissions.CRAFT.ordinal())) > 0 );
|
||||
build.setState( (cs.security & (1 << SecurityPermissions.BUILD.ordinal())) > 0 );
|
||||
security.setState( (cs.security & (1 << SecurityPermissions.SECURITY.ordinal())) > 0 );
|
||||
|
||||
return "guis/security.png";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
super.drawFG( offsetX, offsetY, mouseX, mouseY );
|
||||
fontRendererObj.drawString( GuiText.SecurityCardEditor.getLocal(), 8, ySize - 96 + 1 - reservedSpace, 4210752 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enum getSortBy()
|
||||
{
|
||||
return SortOrder.NAME;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.container.implementations.ContainerSkyChest;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.integration.IntegrationType;
|
||||
import appeng.tile.storage.TileSkyChest;
|
||||
|
||||
public class GuiSkyChest extends AEBaseGui
|
||||
{
|
||||
|
||||
public GuiSkyChest(InventoryPlayer inventoryPlayer, TileSkyChest te) {
|
||||
super( new ContainerSkyChest( inventoryPlayer, te ) );
|
||||
this.ySize = 195;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/skychest.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.SkyChest.getLocal() ), 8, 8, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 2, 4210752 );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean enableSpaceClicking()
|
||||
{
|
||||
return !AppEng.instance.isIntegrationEnabled( IntegrationType.InvTweaks );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.container.implementations.ContainerSpatialIOPort;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.tile.spatial.TileSpatialIOPort;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class GuiSpatialIOPort extends AEBaseGui
|
||||
{
|
||||
|
||||
ContainerSpatialIOPort csiop;
|
||||
GuiImgButton units;
|
||||
|
||||
public GuiSpatialIOPort(InventoryPlayer inventoryPlayer, TileSpatialIOPort te) {
|
||||
super( new ContainerSpatialIOPort( inventoryPlayer, te ) );
|
||||
this.ySize = 199;
|
||||
csiop = (ContainerSpatialIOPort) inventorySlots;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
if ( btn == units )
|
||||
{
|
||||
AEConfig.instance.nextPowerUnit( backwards );
|
||||
units.set( AEConfig.instance.selectedPowerUnit() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
units = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.POWER_UNITS, AEConfig.instance.selectedPowerUnit() );
|
||||
buttonList.add( units );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/spatialio.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( GuiText.StoredPower.getLocal() + ": " + Platform.formatPowerLong( csiop.currentPower, false ), 13, 21, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.MaxPower.getLocal() + ": " + Platform.formatPowerLong( csiop.maxPower, false ), 13, 31, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.RequiredPower.getLocal() + ": " + Platform.formatPowerLong( csiop.reqPower, false ), 13, 78, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.Efficiency.getLocal() + ": " + (((float) csiop.eff) / 100) + "%", 13, 88, 4210752 );
|
||||
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.SpatialIOPort.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96, 4210752 );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.StorageFilter;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.client.gui.widgets.GuiTabButton;
|
||||
import appeng.container.implementations.ContainerStorageBus;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
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 appeng.parts.misc.PartStorageBus;
|
||||
|
||||
public class GuiStorageBus extends GuiUpgradeable
|
||||
{
|
||||
|
||||
GuiImgButton rwMode;
|
||||
GuiImgButton storageFilter;
|
||||
GuiTabButton priority;
|
||||
GuiImgButton partition;
|
||||
GuiImgButton clear;
|
||||
|
||||
public GuiStorageBus(InventoryPlayer inventoryPlayer, PartStorageBus te) {
|
||||
super( new ContainerStorageBus( inventoryPlayer, te ) );
|
||||
this.ySize = 251;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
super.drawBG( offsetX, offsetY, mouseX, mouseY );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.StorageBus.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
|
||||
if ( fuzzyMode != null )
|
||||
fuzzyMode.set( cvb.fzMode );
|
||||
|
||||
if ( storageFilter != null )
|
||||
storageFilter.set( ((ContainerStorageBus) cvb).storageFilter );
|
||||
|
||||
if ( rwMode != null )
|
||||
rwMode.set( ((ContainerStorageBus) cvb).rwMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void addButtons()
|
||||
{
|
||||
clear = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.ACTIONS, ActionItems.CLOSE );
|
||||
partition = new GuiImgButton( this.guiLeft - 18, guiTop + 28, Settings.ACTIONS, ActionItems.WRENCH );
|
||||
rwMode = new GuiImgButton( this.guiLeft - 18, guiTop + 48, Settings.ACCESS, AccessRestriction.READ_WRITE );
|
||||
storageFilter = new GuiImgButton( this.guiLeft - 18, guiTop + 68, Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY );
|
||||
fuzzyMode = new GuiImgButton( this.guiLeft - 18, guiTop + 88, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
|
||||
buttonList.add( priority = new GuiTabButton( this.guiLeft + 154, this.guiTop, 2 + 4 * 16, GuiText.Priority.getLocal(), itemRender ) );
|
||||
|
||||
buttonList.add( storageFilter );
|
||||
buttonList.add( fuzzyMode );
|
||||
buttonList.add( rwMode );
|
||||
buttonList.add( partition );
|
||||
buttonList.add( clear );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
try
|
||||
{
|
||||
if ( btn == partition )
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "StorageBus.Action", "Partition" ) );
|
||||
|
||||
else if ( btn == clear )
|
||||
NetworkHandler.instance.sendToServer( new PacketValueConfig( "StorageBus.Action", "Clear" ) );
|
||||
|
||||
else if ( btn == priority )
|
||||
NetworkHandler.instance.sendToServer( new PacketSwitchGuis( GuiBridge.GUI_PRIORITY ) );
|
||||
|
||||
else if ( btn == fuzzyMode )
|
||||
NetworkHandler.instance.sendToServer( new PacketConfigButton( fuzzyMode.getSetting(), backwards ) );
|
||||
|
||||
else if ( btn == rwMode )
|
||||
NetworkHandler.instance.sendToServer( new PacketConfigButton( rwMode.getSetting(), backwards ) );
|
||||
|
||||
else if ( btn == storageFilter )
|
||||
NetworkHandler.instance.sendToServer( new PacketConfigButton( storageFilter.getSetting(), backwards ) );
|
||||
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/storagebus.png";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,150 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.Settings;
|
||||
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.container.implementations.ContainerUpgradeable;
|
||||
import appeng.core.AELog;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import appeng.parts.automation.PartImportBus;
|
||||
|
||||
public class GuiUpgradeable extends AEBaseGui
|
||||
{
|
||||
|
||||
ContainerUpgradeable cvb;
|
||||
IUpgradeableHost bc;
|
||||
|
||||
GuiImgButton redstoneMode;
|
||||
GuiImgButton fuzzyMode;
|
||||
GuiImgButton craftMode;
|
||||
|
||||
public GuiUpgradeable(InventoryPlayer inventoryPlayer, IUpgradeableHost te) {
|
||||
this( new ContainerUpgradeable( inventoryPlayer, te ) );
|
||||
}
|
||||
|
||||
public GuiUpgradeable(ContainerUpgradeable te) {
|
||||
super( te );
|
||||
cvb = (ContainerUpgradeable) te;
|
||||
|
||||
bc = (IUpgradeableHost) te.getTarget();
|
||||
this.xSize = hasToolbox() ? 246 : 211;
|
||||
this.ySize = 184;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
addButtons();
|
||||
}
|
||||
|
||||
protected void addButtons()
|
||||
{
|
||||
redstoneMode = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE );
|
||||
fuzzyMode = new GuiImgButton( this.guiLeft - 18, guiTop + 28, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL );
|
||||
craftMode = new GuiImgButton( this.guiLeft - 18, guiTop + 48, Settings.CRAFT_ONLY, YesNo.NO );
|
||||
|
||||
buttonList.add( craftMode );
|
||||
buttonList.add( redstoneMode );
|
||||
buttonList.add( fuzzyMode );
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
try
|
||||
{
|
||||
if ( btn == redstoneMode )
|
||||
NetworkHandler.instance.sendToServer( new PacketConfigButton( redstoneMode.getSetting(), backwards ) );
|
||||
|
||||
if ( btn == craftMode )
|
||||
NetworkHandler.instance.sendToServer( new PacketConfigButton( craftMode.getSetting(), backwards ) );
|
||||
|
||||
if ( btn == fuzzyMode )
|
||||
NetworkHandler.instance.sendToServer( new PacketConfigButton( fuzzyMode.getSetting(), backwards ) );
|
||||
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
AELog.error( e );
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean hasToolbox()
|
||||
{
|
||||
return ((ContainerUpgradeable) inventorySlots).hasToolbox();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
handleButtonVisibility();
|
||||
|
||||
bindTexture( getBackground() );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, 211 - 34, ySize );
|
||||
if ( drawUpgrades() )
|
||||
this.drawTexturedModalRect( offsetX + 177, offsetY, 177, 0, 35, 14 + cvb.availableUpgrades() * 18 );
|
||||
if ( hasToolbox() )
|
||||
this.drawTexturedModalRect( offsetX + 178, offsetY + ySize - 90, 178, ySize - 90, 68, 68 );
|
||||
}
|
||||
|
||||
protected boolean drawUpgrades()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
protected String getBackground()
|
||||
{
|
||||
return "guis/bus.png";
|
||||
}
|
||||
|
||||
protected void handleButtonVisibility()
|
||||
{
|
||||
if ( redstoneMode != null )
|
||||
redstoneMode.setVisibility( bc.getInstalledUpgrades( Upgrades.REDSTONE ) > 0 );
|
||||
if ( fuzzyMode != null )
|
||||
fuzzyMode.setVisibility( bc.getInstalledUpgrades( Upgrades.FUZZY ) > 0 );
|
||||
if ( craftMode != null )
|
||||
craftMode.setVisibility( bc.getInstalledUpgrades( Upgrades.CRAFTING ) > 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( getName().getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
|
||||
if ( redstoneMode != null )
|
||||
redstoneMode.set( cvb.rsMode );
|
||||
|
||||
if ( fuzzyMode != null )
|
||||
fuzzyMode.set( cvb.fzMode );
|
||||
|
||||
if ( craftMode != null )
|
||||
craftMode.set( cvb.cMode );
|
||||
}
|
||||
|
||||
protected GuiText getName()
|
||||
{
|
||||
return bc instanceof PartImportBus ? GuiText.ImportBus : GuiText.ExportBus;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiProgressBar;
|
||||
import appeng.client.gui.widgets.GuiProgressBar.Direction;
|
||||
import appeng.container.implementations.ContainerVibrationChamber;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.tile.misc.TileVibrationChamber;
|
||||
|
||||
public class GuiVibrationChamber extends AEBaseGui
|
||||
{
|
||||
|
||||
ContainerVibrationChamber cvc;
|
||||
GuiProgressBar pb;
|
||||
|
||||
public GuiVibrationChamber(InventoryPlayer inventoryPlayer, TileVibrationChamber te) {
|
||||
super( new ContainerVibrationChamber( inventoryPlayer, te ) );
|
||||
cvc = (ContainerVibrationChamber) inventorySlots;
|
||||
this.ySize = 166;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
pb = new GuiProgressBar( "guis/vibchamber.png", 99, 36, 176, 14, 6, 18, Direction.VERTICAL );
|
||||
this.buttonList.add( pb );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/vibchamber.png" );
|
||||
pb.xPosition = 99 + guiLeft;
|
||||
pb.yPosition = 36 + guiTop;
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.VibrationChamber.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
|
||||
int k = 25;
|
||||
int l = -15;
|
||||
|
||||
pb.max = 200;
|
||||
pb.current = cvc.burnProgress > 0 ? cvc.burnSpeed : 0;
|
||||
pb.FullMsg = (cvc.aePerTick * pb.current / 100) + " ae/t";
|
||||
|
||||
if ( cvc.burnProgress > 0 )
|
||||
{
|
||||
int i1 = cvc.burnProgress;
|
||||
bindTexture( "guis/vibchamber.png" );
|
||||
GL11.glColor3f( 1, 1, 1 );
|
||||
this.drawTexturedModalRect( k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 2 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
import org.lwjgl.input.Mouse;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
import appeng.container.implementations.ContainerWireless;
|
||||
import appeng.core.AEConfig;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.tile.networking.TileWireless;
|
||||
import appeng.util.Platform;
|
||||
|
||||
public class GuiWireless extends AEBaseGui
|
||||
{
|
||||
|
||||
GuiImgButton units;
|
||||
|
||||
@Override
|
||||
protected void actionPerformed(GuiButton btn)
|
||||
{
|
||||
super.actionPerformed( btn );
|
||||
|
||||
boolean backwards = Mouse.isButtonDown( 1 );
|
||||
|
||||
if ( btn == units )
|
||||
{
|
||||
AEConfig.instance.nextPowerUnit( backwards );
|
||||
units.set( AEConfig.instance.selectedPowerUnit() );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initGui()
|
||||
{
|
||||
super.initGui();
|
||||
|
||||
units = new GuiImgButton( this.guiLeft - 18, guiTop + 8, Settings.POWER_UNITS, AEConfig.instance.selectedPowerUnit() );
|
||||
buttonList.add( units );
|
||||
}
|
||||
|
||||
public GuiWireless(InventoryPlayer inventoryPlayer, TileWireless te) {
|
||||
super( new ContainerWireless( inventoryPlayer, te ) );
|
||||
this.ySize = 166;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
bindTexture( "guis/wireless.png" );
|
||||
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
|
||||
{
|
||||
fontRendererObj.drawString( getGuiDisplayName( GuiText.Wireless.getLocal() ), 8, 6, 4210752 );
|
||||
fontRendererObj.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
|
||||
|
||||
ContainerWireless cw = (ContainerWireless) inventorySlots;
|
||||
|
||||
if ( cw.range > 0 )
|
||||
{
|
||||
String msga = GuiText.Range.getLocal() + ": " + ((double) cw.range / 10.0) + " m";
|
||||
String msgb = GuiText.PowerUsageRate.getLocal() + ": " + Platform.formatPowerLong( cw.drain, true );
|
||||
|
||||
int strWidth = Math.max( fontRendererObj.getStringWidth( msga ), fontRendererObj.getStringWidth( msgb ) );
|
||||
int cOffset = (this.xSize / 2) - (strWidth / 2);
|
||||
fontRendererObj.drawString( msga, cOffset, 20, 4210752 );
|
||||
fontRendererObj.drawString( msgb, cOffset, 20 + 12, 4210752 );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package appeng.client.gui.implementations;
|
||||
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
import appeng.api.implementations.guiobjects.IPortableCell;
|
||||
|
||||
public class GuiWirelessTerm extends GuiMEPortableCell
|
||||
{
|
||||
|
||||
public GuiWirelessTerm(InventoryPlayer inventoryPlayer, IPortableCell te) {
|
||||
super( inventoryPlayer, te );
|
||||
maxRows = Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
int getMaxRows()
|
||||
{
|
||||
return defaultGetMaxRows();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,352 @@
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.api.config.AccessRestriction;
|
||||
import appeng.api.config.ActionItems;
|
||||
import appeng.api.config.CondenserOutput;
|
||||
import appeng.api.config.FullnessMode;
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.LevelType;
|
||||
import appeng.api.config.OperationMode;
|
||||
import appeng.api.config.PowerUnits;
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.RelativeDirection;
|
||||
import appeng.api.config.SearchBoxMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.StorageFilter;
|
||||
import appeng.api.config.TerminalStyle;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
import appeng.core.localization.ButtonToolTips;
|
||||
|
||||
public class GuiImgButton extends GuiButton implements ITooltip
|
||||
{
|
||||
|
||||
class EnumPair
|
||||
{
|
||||
|
||||
Enum setting;
|
||||
Enum value;
|
||||
|
||||
EnumPair(Enum a, Enum b) {
|
||||
setting = a;
|
||||
value = b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
return setting.hashCode() ^ value.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
EnumPair d = (EnumPair) obj;
|
||||
return d.setting.equals( setting ) && d.value.equals( value );
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
class BtnAppearance
|
||||
{
|
||||
|
||||
public int index;
|
||||
public String DisplayName;
|
||||
public String DisplayValue;
|
||||
};
|
||||
|
||||
public boolean halfSize = false;
|
||||
public String FillVar;
|
||||
|
||||
private final Enum buttonSetting;
|
||||
private Enum currentValue;
|
||||
|
||||
static private Map<EnumPair, BtnAppearance> Appearances;
|
||||
|
||||
private void registerApp(int IIcon, Settings setting, Enum val, ButtonToolTips title, Object hint)
|
||||
{
|
||||
BtnAppearance a = new BtnAppearance();
|
||||
a.DisplayName = title.getUnlocalized();
|
||||
a.DisplayValue = (String) (hint instanceof String ? hint : ((ButtonToolTips) hint).getUnlocalized());
|
||||
a.index = IIcon;
|
||||
Appearances.put( new EnumPair( setting, val ), a );
|
||||
}
|
||||
|
||||
public void setVisibility(boolean vis)
|
||||
{
|
||||
visible = vis;
|
||||
enabled = vis;
|
||||
}
|
||||
|
||||
public GuiImgButton(int x, int y, Enum idx, Enum val) {
|
||||
super( 0, 0, 16, "" );
|
||||
buttonSetting = idx;
|
||||
currentValue = val;
|
||||
xPosition = x;
|
||||
yPosition = y;
|
||||
width = 16;
|
||||
height = 16;
|
||||
|
||||
if ( Appearances == null )
|
||||
{
|
||||
Appearances = new HashMap();
|
||||
registerApp( 16 * 7 + 0, Settings.CONDENSER_OUTPUT, CondenserOutput.TRASH, ButtonToolTips.CondenserOutput, ButtonToolTips.Trash );
|
||||
registerApp( 16 * 7 + 1, Settings.CONDENSER_OUTPUT, CondenserOutput.MATTER_BALLS, ButtonToolTips.CondenserOutput, ButtonToolTips.MatterBalls );
|
||||
registerApp( 16 * 7 + 2, Settings.CONDENSER_OUTPUT, CondenserOutput.SINGULARITY, ButtonToolTips.CondenserOutput, ButtonToolTips.Singularity );
|
||||
|
||||
registerApp( 16 * 9 + 1, Settings.ACCESS, AccessRestriction.READ, ButtonToolTips.IOMode, ButtonToolTips.Read );
|
||||
registerApp( 16 * 9 + 0, Settings.ACCESS, AccessRestriction.WRITE, ButtonToolTips.IOMode, ButtonToolTips.Write );
|
||||
registerApp( 16 * 9 + 2, Settings.ACCESS, AccessRestriction.READ_WRITE, ButtonToolTips.IOMode, ButtonToolTips.ReadWrite );
|
||||
|
||||
registerApp( 16 * 10 + 0, Settings.POWER_UNITS, PowerUnits.AE, ButtonToolTips.PowerUnits, PowerUnits.AE.unlocalizedName );
|
||||
registerApp( 16 * 10 + 1, Settings.POWER_UNITS, PowerUnits.EU, ButtonToolTips.PowerUnits, PowerUnits.EU.unlocalizedName );
|
||||
registerApp( 16 * 10 + 2, Settings.POWER_UNITS, PowerUnits.MJ, ButtonToolTips.PowerUnits, PowerUnits.MJ.unlocalizedName );
|
||||
registerApp( 16 * 10 + 3, Settings.POWER_UNITS, PowerUnits.MK, ButtonToolTips.PowerUnits, PowerUnits.MK.unlocalizedName );
|
||||
registerApp( 16 * 10 + 4, Settings.POWER_UNITS, PowerUnits.WA, ButtonToolTips.PowerUnits, PowerUnits.WA.unlocalizedName );
|
||||
registerApp( 16 * 10 + 5, Settings.POWER_UNITS, PowerUnits.RF, ButtonToolTips.PowerUnits, PowerUnits.RF.unlocalizedName );
|
||||
|
||||
registerApp( 3, Settings.REDSTONE_CONTROLLED, RedstoneMode.IGNORE, ButtonToolTips.RedstoneMode, ButtonToolTips.AlwaysActive );
|
||||
registerApp( 0, Settings.REDSTONE_CONTROLLED, RedstoneMode.LOW_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.ActiveWithoutSignal );
|
||||
registerApp( 1, Settings.REDSTONE_CONTROLLED, RedstoneMode.HIGH_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.ActiveWithSignal );
|
||||
registerApp( 2, Settings.REDSTONE_CONTROLLED, RedstoneMode.SIGNAL_PULSE, ButtonToolTips.RedstoneMode, ButtonToolTips.ActiveOnPulse );
|
||||
|
||||
registerApp( 0, Settings.REDSTONE_EMITTER, RedstoneMode.LOW_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.EmitLevelsBelow );
|
||||
registerApp( 1, Settings.REDSTONE_EMITTER, RedstoneMode.HIGH_SIGNAL, ButtonToolTips.RedstoneMode, ButtonToolTips.EmitLevelAbove );
|
||||
|
||||
registerApp( 51, Settings.OPERATION_MODE, OperationMode.FILL, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToStorageCell );
|
||||
registerApp( 50, Settings.OPERATION_MODE, OperationMode.EMPTY, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToNetwork );
|
||||
|
||||
registerApp( 51, Settings.IO_DIRECTION, RelativeDirection.LEFT, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToStorageCell );
|
||||
registerApp( 50, Settings.IO_DIRECTION, RelativeDirection.RIGHT, ButtonToolTips.TransferDirection, ButtonToolTips.TransferToNetwork );
|
||||
|
||||
registerApp( 48, Settings.SORT_DIRECTION, SortDir.ASCENDING, ButtonToolTips.SortOrder, ButtonToolTips.ToggleSortDirection );
|
||||
registerApp( 49, Settings.SORT_DIRECTION, SortDir.DESCENDING, ButtonToolTips.SortOrder, ButtonToolTips.ToggleSortDirection );
|
||||
|
||||
registerApp( 16 * 2 + 3, Settings.SEARCH_MODE, SearchBoxMode.AUTOSEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_Auto );
|
||||
registerApp( 16 * 2 + 4, Settings.SEARCH_MODE, SearchBoxMode.MANUAL_SEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_Standard );
|
||||
registerApp( 16 * 2 + 5, Settings.SEARCH_MODE, SearchBoxMode.NEI_AUTOSEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_NEIAuto );
|
||||
registerApp( 16 * 2 + 6, Settings.SEARCH_MODE, SearchBoxMode.NEI_MANUAL_SEARCH, ButtonToolTips.SearchMode, ButtonToolTips.SearchMode_NEIStandard );
|
||||
|
||||
registerApp( 16 * 5 + 3, Settings.LEVEL_TYPE, LevelType.ENERGY_LEVEL, ButtonToolTips.LevelType, ButtonToolTips.LevelType_Energy );
|
||||
registerApp( 16 * 4 + 3, Settings.LEVEL_TYPE, LevelType.ITEM_LEVEL, ButtonToolTips.LevelType, ButtonToolTips.LevelType_Item );
|
||||
|
||||
registerApp( 16 * 13 + 0, Settings.TERMINAL_STYLE, TerminalStyle.TALL, ButtonToolTips.TerminalStyle, ButtonToolTips.TerminalStyle_Tall );
|
||||
registerApp( 16 * 13 + 1, Settings.TERMINAL_STYLE, TerminalStyle.SMALL, ButtonToolTips.TerminalStyle, ButtonToolTips.TerminalStyle_Small );
|
||||
registerApp( 16 * 13 + 2, Settings.TERMINAL_STYLE, TerminalStyle.FULL, ButtonToolTips.TerminalStyle, ButtonToolTips.TerminalStyle_Full );
|
||||
|
||||
registerApp( 64, Settings.SORT_BY, SortOrder.NAME, ButtonToolTips.SortBy, ButtonToolTips.ItemName );
|
||||
registerApp( 65, Settings.SORT_BY, SortOrder.AMOUNT, ButtonToolTips.SortBy, ButtonToolTips.NumberOfItems );
|
||||
registerApp( 68, Settings.SORT_BY, SortOrder.INVTWEAKS, ButtonToolTips.SortBy, ButtonToolTips.InventoryTweaks );
|
||||
registerApp( 69, Settings.SORT_BY, SortOrder.MOD, ButtonToolTips.SortBy, ButtonToolTips.Mod );
|
||||
|
||||
registerApp( 66, Settings.ACTIONS, ActionItems.WRENCH, ButtonToolTips.PartitionStorage, ButtonToolTips.PartitionStorageHint );
|
||||
registerApp( 6, Settings.ACTIONS, ActionItems.CLOSE, ButtonToolTips.Clear, ButtonToolTips.ClearSettings );
|
||||
registerApp( 6, Settings.ACTIONS, ActionItems.STASH, ButtonToolTips.Stash, ButtonToolTips.StashDesc );
|
||||
|
||||
registerApp( 8, Settings.ACTIONS, ActionItems.ENCODE, ButtonToolTips.Encode, ButtonToolTips.EncodeDescription );
|
||||
registerApp( 4 + 3 * 16, Settings.ACTIONS, ActionItems.SUBSTITUTION, ButtonToolTips.Substitutions, ButtonToolTips.SubstitutionsDesc );
|
||||
|
||||
registerApp( 16, Settings.VIEW_MODE, ViewItems.STORED, ButtonToolTips.View, ButtonToolTips.StoredItems );
|
||||
registerApp( 18, Settings.VIEW_MODE, ViewItems.ALL, ButtonToolTips.View, ButtonToolTips.StoredCraftable );
|
||||
registerApp( 19, Settings.VIEW_MODE, ViewItems.CRAFTABLE, ButtonToolTips.View, ButtonToolTips.Craftable );
|
||||
|
||||
registerApp( 16 * 6 + 0, Settings.FUZZY_MODE, FuzzyMode.PERCENT_25, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_25 );
|
||||
registerApp( 16 * 6 + 1, Settings.FUZZY_MODE, FuzzyMode.PERCENT_50, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_50 );
|
||||
registerApp( 16 * 6 + 2, Settings.FUZZY_MODE, FuzzyMode.PERCENT_75, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_75 );
|
||||
registerApp( 16 * 6 + 3, Settings.FUZZY_MODE, FuzzyMode.PERCENT_99, ButtonToolTips.FuzzyMode, ButtonToolTips.FZPercent_99 );
|
||||
registerApp( 16 * 6 + 4, Settings.FUZZY_MODE, FuzzyMode.IGNORE_ALL, ButtonToolTips.FuzzyMode, ButtonToolTips.FZIgnoreAll );
|
||||
|
||||
registerApp( 80, Settings.FULLNESS_MODE, FullnessMode.EMPTY, ButtonToolTips.OperationMode, ButtonToolTips.MoveWhenEmpty );
|
||||
registerApp( 81, Settings.FULLNESS_MODE, FullnessMode.HALF, ButtonToolTips.OperationMode, ButtonToolTips.MoveWhenWorkIsDone );
|
||||
registerApp( 82, Settings.FULLNESS_MODE, FullnessMode.FULL, ButtonToolTips.OperationMode, ButtonToolTips.MoveWhenFull );
|
||||
|
||||
registerApp( 16 * 1 + 5, Settings.BLOCK, YesNo.YES, ButtonToolTips.InterfaceBlockingMode, ButtonToolTips.Blocking );
|
||||
registerApp( 16 * 1 + 4, Settings.BLOCK, YesNo.NO, ButtonToolTips.InterfaceBlockingMode, ButtonToolTips.NonBlocking );
|
||||
|
||||
registerApp( 16 * 1 + 3, Settings.CRAFT_ONLY, YesNo.YES, ButtonToolTips.Craft, ButtonToolTips.CraftOnly );
|
||||
registerApp( 16 * 1 + 2, Settings.CRAFT_ONLY, YesNo.NO, ButtonToolTips.Craft, ButtonToolTips.CraftEither );
|
||||
|
||||
registerApp( 16 * 11 + 2, Settings.CRAFT_VIA_REDSTONE, YesNo.YES, ButtonToolTips.EmitterMode, ButtonToolTips.CraftViaRedstone );
|
||||
registerApp( 16 * 11 + 1, Settings.CRAFT_VIA_REDSTONE, YesNo.NO, ButtonToolTips.EmitterMode, ButtonToolTips.EmitWhenCrafting );
|
||||
|
||||
registerApp( 16 * 3 + 5, Settings.STORAGE_FILTER, StorageFilter.EXTRACTABLE_ONLY, ButtonToolTips.ReportInaccessibleItems,
|
||||
ButtonToolTips.ReportInaccessibleItemsNo );
|
||||
registerApp( 16 * 3 + 6, Settings.STORAGE_FILTER, StorageFilter.NONE, ButtonToolTips.ReportInaccessibleItems,
|
||||
ButtonToolTips.ReportInaccessibleItemsYes );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible()
|
||||
{
|
||||
return visible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft par1Minecraft, int par2, int par3)
|
||||
{
|
||||
if ( this.visible )
|
||||
{
|
||||
int iconIndex = getIconIndex();
|
||||
|
||||
if ( halfSize )
|
||||
{
|
||||
width = 8;
|
||||
height = 8;
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef( this.xPosition, this.yPosition, 0.0F );
|
||||
GL11.glScalef( 0.5f, 0.5f, 0.5f );
|
||||
|
||||
if ( enabled )
|
||||
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
else
|
||||
GL11.glColor4f( 0.5f, 0.5f, 0.5f, 1.0f );
|
||||
|
||||
par1Minecraft.renderEngine.bindTexture( ExtraBlockTextures.GuiTexture( "guis/states.png" ) );
|
||||
this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width
|
||||
&& par3 < this.yPosition + this.height;
|
||||
|
||||
int uv_y = (int) Math.floor( iconIndex / 16 );
|
||||
int uv_x = iconIndex - uv_y * 16;
|
||||
|
||||
this.drawTexturedModalRect( 0, 0, 256 - 16, 256 - 16, 16, 16 );
|
||||
this.drawTexturedModalRect( 0, 0, uv_x * 16, uv_y * 16, 16, 16 );
|
||||
this.mouseDragged( par1Minecraft, par2, par3 );
|
||||
|
||||
GL11.glPopMatrix();
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( enabled )
|
||||
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
else
|
||||
GL11.glColor4f( 0.5f, 0.5f, 0.5f, 1.0f );
|
||||
|
||||
par1Minecraft.renderEngine.bindTexture( ExtraBlockTextures.GuiTexture( "guis/states.png" ) );
|
||||
this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width
|
||||
&& par3 < this.yPosition + this.height;
|
||||
|
||||
int uv_y = (int) Math.floor( iconIndex / 16 );
|
||||
int uv_x = iconIndex - uv_y * 16;
|
||||
|
||||
this.drawTexturedModalRect( this.xPosition, this.yPosition, 256 - 16, 256 - 16, 16, 16 );
|
||||
this.drawTexturedModalRect( this.xPosition, this.yPosition, uv_x * 16, uv_y * 16, 16, 16 );
|
||||
this.mouseDragged( par1Minecraft, par2, par3 );
|
||||
}
|
||||
}
|
||||
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
}
|
||||
|
||||
private int getIconIndex()
|
||||
{
|
||||
if ( buttonSetting != null && currentValue != null )
|
||||
{
|
||||
BtnAppearance app = Appearances.get( new EnumPair( buttonSetting, currentValue ) );
|
||||
if ( app == null )
|
||||
return 256 - 1;
|
||||
return app.index;
|
||||
}
|
||||
return 256 - 1;
|
||||
}
|
||||
|
||||
public Settings getSetting()
|
||||
{
|
||||
return (Settings) buttonSetting;
|
||||
}
|
||||
|
||||
public Enum getCurrentValue()
|
||||
{
|
||||
return currentValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMsg()
|
||||
{
|
||||
String DisplayName = null;
|
||||
String DisplayValue = null;
|
||||
|
||||
if ( buttonSetting != null && currentValue != null )
|
||||
{
|
||||
BtnAppearance ba = Appearances.get( new EnumPair( buttonSetting, currentValue ) );
|
||||
if ( ba == null )
|
||||
return "No Such Message";
|
||||
|
||||
DisplayName = ba.DisplayName;
|
||||
DisplayValue = ba.DisplayValue;
|
||||
}
|
||||
|
||||
if ( DisplayName != null )
|
||||
{
|
||||
String Name = StatCollector.translateToLocal( DisplayName );
|
||||
String Value = StatCollector.translateToLocal( DisplayValue );
|
||||
|
||||
if ( Name == null || Name.equals( "" ) )
|
||||
Name = DisplayName;
|
||||
if ( Value == null || Value.equals( "" ) )
|
||||
Value = DisplayValue;
|
||||
|
||||
if ( FillVar != null )
|
||||
Value = Value.replaceFirst( "%s", FillVar );
|
||||
|
||||
Value = Value.replace( "\\n", "\n" );
|
||||
StringBuilder sb = new StringBuilder( Value );
|
||||
|
||||
int i = sb.lastIndexOf( "\n" );
|
||||
if ( i <= 0 )
|
||||
i = 0;
|
||||
while (i + 30 < sb.length() && (i = sb.lastIndexOf( " ", i + 30 )) != -1)
|
||||
{
|
||||
sb.replace( i, i + 1, "\n" );
|
||||
}
|
||||
|
||||
return Name + "\n" + sb.toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos()
|
||||
{
|
||||
return xPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos()
|
||||
{
|
||||
return yPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth()
|
||||
{
|
||||
return halfSize ? 8 : 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight()
|
||||
{
|
||||
return halfSize ? 8 : 16;
|
||||
}
|
||||
|
||||
public void set(Enum e)
|
||||
{
|
||||
if ( currentValue != e )
|
||||
{
|
||||
currentValue = e;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
|
||||
|
||||
public class GuiNumberBox extends GuiTextField
|
||||
{
|
||||
|
||||
final Class type;
|
||||
|
||||
public GuiNumberBox(FontRenderer p_i1032_1_, int p_i1032_2_, int p_i1032_3_, int p_i1032_4_, int p_i1032_5_,Class type) {
|
||||
super( p_i1032_1_, p_i1032_2_, p_i1032_3_, p_i1032_4_, p_i1032_5_ );
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeText(String p_146191_1_)
|
||||
{
|
||||
String original = getText();
|
||||
super.writeText( p_146191_1_ );
|
||||
|
||||
try
|
||||
{
|
||||
if ( type == int.class || type == Integer.class )
|
||||
Integer.parseInt( getText() );
|
||||
else if ( type == long.class || type == Long.class )
|
||||
Long.parseLong( getText() );
|
||||
else if ( type == double.class || type == Double.class )
|
||||
Double.parseDouble( getText() );
|
||||
}
|
||||
catch(NumberFormatException e )
|
||||
{
|
||||
setText( original );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
public class GuiProgressBar extends GuiButton implements ITooltip
|
||||
{
|
||||
|
||||
public enum Direction
|
||||
{
|
||||
HORIZONTAL, VERTICAL
|
||||
};
|
||||
|
||||
private ResourceLocation texture;
|
||||
private int fill_u;
|
||||
private int fill_v;
|
||||
private Direction layout;
|
||||
|
||||
public String FullMsg;
|
||||
|
||||
public String TitleName;
|
||||
public int current;
|
||||
public int max;
|
||||
|
||||
public GuiProgressBar(String string, int posX, int posY, int u, int y, int _width, int _height, Direction dir) {
|
||||
super( posX, posY, _width, "" );
|
||||
this.xPosition = posX;
|
||||
this.yPosition = posY;
|
||||
texture = new ResourceLocation( "appliedenergistics2", "textures/" + string );
|
||||
width = _width;
|
||||
height = _height;
|
||||
fill_u = u;
|
||||
fill_v = y;
|
||||
current = 0;
|
||||
max = 100;
|
||||
layout = dir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft par1Minecraft, int par2, int par3)
|
||||
{
|
||||
if ( this.visible )
|
||||
{
|
||||
par1Minecraft.getTextureManager().bindTexture( texture );
|
||||
|
||||
if ( layout == Direction.VERTICAL )
|
||||
{
|
||||
int diff = height - (max > 0 ? (height * current) / max : 0);
|
||||
this.drawTexturedModalRect( this.xPosition, this.yPosition + diff, fill_u, fill_v + diff, width, height - diff );
|
||||
}
|
||||
else
|
||||
{
|
||||
int diff = width - (max > 0 ? (width * current) / max : 0);
|
||||
this.drawTexturedModalRect( this.xPosition, this.yPosition, fill_u + diff, fill_v, width - diff, height );
|
||||
}
|
||||
|
||||
this.mouseDragged( par1Minecraft, par2, par3 );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMsg()
|
||||
{
|
||||
if ( FullMsg != null )
|
||||
return FullMsg;
|
||||
|
||||
return (TitleName != null ? TitleName : "") + "\n" + current + " " + GuiText.Of.getLocal() + " " + max;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos()
|
||||
{
|
||||
return xPosition - 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos()
|
||||
{
|
||||
return yPosition - 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth()
|
||||
{
|
||||
return width + 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight()
|
||||
{
|
||||
return height + 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.client.gui.AEBaseGui;
|
||||
|
||||
public class GuiScrollbar implements IScrollSource
|
||||
{
|
||||
|
||||
private int displayX = 0;
|
||||
private int displayY = 0;
|
||||
private int width = 12;
|
||||
private int height = 16;
|
||||
private int pageSize = 1;
|
||||
|
||||
private int maxScroll = 0;
|
||||
private int minScroll = 0;
|
||||
private int currentScroll = 0;
|
||||
|
||||
private void applyRange()
|
||||
{
|
||||
currentScroll = Math.max( Math.min( currentScroll, maxScroll ), minScroll );
|
||||
}
|
||||
|
||||
public void draw(AEBaseGui g)
|
||||
{
|
||||
g.bindTexture( "minecraft", "gui/container/creative_inventory/tabs.png" );
|
||||
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
|
||||
if ( getRange() == 0 )
|
||||
{
|
||||
g.drawTexturedModalRect( displayX, displayY, 232 + width, 0, width, 15 );
|
||||
}
|
||||
else
|
||||
{
|
||||
int offset = (currentScroll - minScroll) * (height - 15) / getRange();
|
||||
g.drawTexturedModalRect( displayX, offset + displayY, 232, 0, width, 15 );
|
||||
}
|
||||
}
|
||||
|
||||
public int getRange()
|
||||
{
|
||||
return maxScroll - minScroll;
|
||||
}
|
||||
|
||||
public int getLeft()
|
||||
{
|
||||
return displayX;
|
||||
}
|
||||
|
||||
public int getTop()
|
||||
{
|
||||
return displayY;
|
||||
}
|
||||
|
||||
public int getWidth()
|
||||
{
|
||||
return width;
|
||||
}
|
||||
|
||||
public int getHeight()
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
public GuiScrollbar setLeft(int v)
|
||||
{
|
||||
displayX = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GuiScrollbar setTop(int v)
|
||||
{
|
||||
displayY = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GuiScrollbar setWidth(int v)
|
||||
{
|
||||
width = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
public GuiScrollbar setHeight(int v)
|
||||
{
|
||||
height = v;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setRange(int min, int max, int pageSize)
|
||||
{
|
||||
minScroll = min;
|
||||
maxScroll = max;
|
||||
this.pageSize = pageSize;
|
||||
|
||||
if ( minScroll > maxScroll )
|
||||
maxScroll = minScroll;
|
||||
|
||||
applyRange();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCurrentScroll()
|
||||
{
|
||||
return currentScroll;
|
||||
}
|
||||
|
||||
public void click(AEBaseGui aeBaseGui, int x, int y)
|
||||
{
|
||||
if ( getRange() == 0 )
|
||||
return;
|
||||
|
||||
if ( x > displayX && x <= displayX + width )
|
||||
{
|
||||
if ( y > displayY && y <= displayY + height )
|
||||
{
|
||||
currentScroll = (y - displayY);
|
||||
currentScroll = minScroll + ((currentScroll * 2 * getRange() / height));
|
||||
currentScroll = (currentScroll + 1) >> 1;
|
||||
applyRange();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void wheel(int delta)
|
||||
{
|
||||
delta = Math.max( Math.min( -delta, 1 ), -1 );
|
||||
currentScroll += delta * pageSize;
|
||||
applyRange();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.client.renderer.RenderHelper;
|
||||
import net.minecraft.client.renderer.entity.RenderItem;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.opengl.GL12;
|
||||
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
|
||||
public class GuiTabButton extends GuiButton implements ITooltip
|
||||
{
|
||||
|
||||
RenderItem itemRenderer;
|
||||
|
||||
int myIcon = -1;
|
||||
public int hideEdge = 0;
|
||||
|
||||
ItemStack myItem;
|
||||
|
||||
String Msg;
|
||||
|
||||
public void setVisibility(boolean vis)
|
||||
{
|
||||
visible = vis;
|
||||
enabled = vis;
|
||||
}
|
||||
|
||||
public GuiTabButton(int x, int y, int ico, String Msg, RenderItem ir) {
|
||||
super( 0, 0, 16, "" );
|
||||
xPosition = x;
|
||||
yPosition = y;
|
||||
width = 22;
|
||||
height = 22;
|
||||
myIcon = ico;
|
||||
this.Msg = Msg;
|
||||
this.itemRenderer = ir;
|
||||
}
|
||||
|
||||
public GuiTabButton(int x, int y, ItemStack ico, String Msg, RenderItem ir) {
|
||||
super( 0, 0, 16, "" );
|
||||
xPosition = x;
|
||||
yPosition = y;
|
||||
width = 22;
|
||||
height = 22;
|
||||
myItem = ico;
|
||||
this.Msg = Msg;
|
||||
this.itemRenderer = ir;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible()
|
||||
{
|
||||
return visible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft par1Minecraft, int par2, int par3)
|
||||
{
|
||||
if ( this.visible )
|
||||
{
|
||||
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
par1Minecraft.renderEngine.bindTexture( ExtraBlockTextures.GuiTexture( "guis/states.png" ) );
|
||||
this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height;
|
||||
|
||||
int uv_y = (int) Math.floor( 13 / 16 );
|
||||
int uv_x = (hideEdge > 0 ? 11 : 13) - uv_y * 16;
|
||||
|
||||
int offsetX = hideEdge > 0 ? 1 : 0;
|
||||
|
||||
this.drawTexturedModalRect( this.xPosition, this.yPosition, uv_x * 16, uv_y * 16, 25, 22 );
|
||||
|
||||
if ( myIcon >= 0 )
|
||||
{
|
||||
uv_y = (int) Math.floor( myIcon / 16 );
|
||||
uv_x = myIcon - uv_y * 16;
|
||||
|
||||
this.drawTexturedModalRect( offsetX + this.xPosition + 3, this.yPosition + 3, uv_x * 16, uv_y * 16, 16, 16 );
|
||||
}
|
||||
|
||||
this.mouseDragged( par1Minecraft, par2, par3 );
|
||||
|
||||
if ( myItem != null )
|
||||
{
|
||||
this.zLevel = 100.0F;
|
||||
itemRenderer.zLevel = 100.0F;
|
||||
|
||||
GL11.glEnable( GL11.GL_LIGHTING );
|
||||
GL11.glEnable( GL12.GL_RESCALE_NORMAL );
|
||||
RenderHelper.enableGUIStandardItemLighting();
|
||||
FontRenderer fontrenderer = par1Minecraft.fontRenderer;
|
||||
itemRenderer.renderItemAndEffectIntoGUI( fontrenderer, par1Minecraft.renderEngine, myItem, offsetX + this.xPosition + 3, this.yPosition + 3 );
|
||||
GL11.glDisable( GL11.GL_LIGHTING );
|
||||
|
||||
itemRenderer.zLevel = 0.0F;
|
||||
this.zLevel = 0.0F;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMsg()
|
||||
{
|
||||
return Msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos()
|
||||
{
|
||||
return xPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos()
|
||||
{
|
||||
return yPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth()
|
||||
{
|
||||
return 22;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight()
|
||||
{
|
||||
return 22;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiButton;
|
||||
import net.minecraft.util.StatCollector;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import appeng.client.texture.ExtraBlockTextures;
|
||||
|
||||
public class GuiToggleButton extends GuiButton implements ITooltip
|
||||
{
|
||||
|
||||
int iconIdxOn;
|
||||
int iconIdxOff;
|
||||
|
||||
String Name;
|
||||
String Hint;
|
||||
|
||||
boolean on;
|
||||
|
||||
public void setState(boolean isOn)
|
||||
{
|
||||
on = isOn;
|
||||
}
|
||||
|
||||
public void setVisibility(boolean vis)
|
||||
{
|
||||
visible = vis;
|
||||
enabled = vis;
|
||||
}
|
||||
|
||||
public GuiToggleButton(int x, int y, int on, int off, String Name, String Hint) {
|
||||
super( 0, 0, 16, "" );
|
||||
iconIdxOn = on;
|
||||
iconIdxOff = off;
|
||||
this.Name = Name;
|
||||
this.Hint = Hint;
|
||||
xPosition = x;
|
||||
yPosition = y;
|
||||
width = 16;
|
||||
height = 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible()
|
||||
{
|
||||
return visible;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawButton(Minecraft par1Minecraft, int par2, int par3)
|
||||
{
|
||||
if ( this.visible )
|
||||
{
|
||||
int iconIndex = getIconIndex();
|
||||
|
||||
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
|
||||
par1Minecraft.renderEngine.bindTexture( ExtraBlockTextures.GuiTexture( "guis/states.png" ) );
|
||||
this.field_146123_n = par2 >= this.xPosition && par3 >= this.yPosition && par2 < this.xPosition + this.width && par3 < this.yPosition + this.height;
|
||||
|
||||
int uv_y = (int) Math.floor( iconIndex / 16 );
|
||||
int uv_x = iconIndex - uv_y * 16;
|
||||
|
||||
this.drawTexturedModalRect( this.xPosition, this.yPosition, 256 - 16, 256 - 16, 16, 16 );
|
||||
this.drawTexturedModalRect( this.xPosition, this.yPosition, uv_x * 16, uv_y * 16, 16, 16 );
|
||||
this.mouseDragged( par1Minecraft, par2, par3 );
|
||||
}
|
||||
}
|
||||
|
||||
private int getIconIndex()
|
||||
{
|
||||
return on ? iconIdxOn : iconIdxOff;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMsg()
|
||||
{
|
||||
String DisplayName = Name;
|
||||
String DisplayValue = Hint;
|
||||
|
||||
if ( DisplayName != null )
|
||||
{
|
||||
String Name = StatCollector.translateToLocal( DisplayName );
|
||||
String Value = StatCollector.translateToLocal( DisplayValue );
|
||||
|
||||
if ( Name == null || Name.equals( "" ) )
|
||||
Name = DisplayName;
|
||||
if ( Value == null || Value.equals( "" ) )
|
||||
Value = DisplayValue;
|
||||
|
||||
Value = Value.replace( "\\n", "\n" );
|
||||
StringBuilder sb = new StringBuilder( Value );
|
||||
|
||||
int i = sb.lastIndexOf( "\n" );
|
||||
if ( i <= 0 )
|
||||
i = 0;
|
||||
while (i + 30 < sb.length() && (i = sb.lastIndexOf( " ", i + 30 )) != -1)
|
||||
{
|
||||
sb.replace( i, i + 1, "\n" );
|
||||
}
|
||||
|
||||
return Name + "\n" + sb.toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int xPos()
|
||||
{
|
||||
return xPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int yPos()
|
||||
{
|
||||
return yPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth()
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight()
|
||||
{
|
||||
return 16;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
public interface IScrollSource
|
||||
{
|
||||
|
||||
int getCurrentScroll();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
import appeng.api.config.SortDir;
|
||||
import appeng.api.config.ViewItems;
|
||||
|
||||
public interface ISortSource
|
||||
{
|
||||
|
||||
/**
|
||||
* @return Sor
|
||||
*/
|
||||
Enum getSortBy();
|
||||
|
||||
/**
|
||||
* @return {@link SortDir}
|
||||
*/
|
||||
Enum getSortDir();
|
||||
|
||||
/**
|
||||
* @return {@link ViewItems}
|
||||
*/
|
||||
Enum getSortDisplay();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
/**
|
||||
* AEBaseGui controlled Tooltip Interface.
|
||||
*
|
||||
*/
|
||||
public interface ITooltip
|
||||
{
|
||||
|
||||
/**
|
||||
* returns the tooltip message.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
String getMsg();
|
||||
|
||||
/**
|
||||
* x Location for the object that triggers the tooltip.
|
||||
*
|
||||
* @return xPosition
|
||||
*/
|
||||
int xPos();
|
||||
|
||||
/**
|
||||
* y Location for the object that triggers the tooltip.
|
||||
*
|
||||
* @return yPosition
|
||||
*/
|
||||
int yPos();
|
||||
|
||||
/**
|
||||
* Width of the object that triggers the tooltip.
|
||||
*
|
||||
* @return width
|
||||
*/
|
||||
int getWidth();
|
||||
|
||||
/**
|
||||
* Height for the object that triggers the tooltip.
|
||||
*
|
||||
* @return height
|
||||
*/
|
||||
int getHeight();
|
||||
|
||||
/**
|
||||
* @return true if button being drawn
|
||||
*/
|
||||
boolean isVisible();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package appeng.client.gui.widgets;
|
||||
|
||||
import net.minecraft.client.gui.FontRenderer;
|
||||
import net.minecraft.client.gui.GuiTextField;
|
||||
|
||||
public class MEGuiTextField extends GuiTextField
|
||||
{
|
||||
|
||||
int posX;
|
||||
int posY;
|
||||
|
||||
int myWidth;
|
||||
int myHeight;
|
||||
|
||||
public MEGuiTextField(FontRenderer par1FontRenderer, int xPos, int yPos, int width, int height) {
|
||||
super( par1FontRenderer, xPos, yPos, width, height );
|
||||
posX = xPos;
|
||||
posY = yPos;
|
||||
myWidth = width;
|
||||
myHeight = height;
|
||||
}
|
||||
|
||||
public boolean isMouseIn(int xCoord, int yCoord)
|
||||
{
|
||||
return xCoord >= posX && xCoord < posX + myWidth && yCoord >= posY && yCoord < posY + myHeight;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user