Pretty much all of security minus the gui.

and all the stuff I did that i forgot to comment.
This commit is contained in:
AlgorithmX2
2014-01-26 22:00:36 -06:00
parent bea039c7b5
commit 0f75db5e80
61 changed files with 2058 additions and 126 deletions
+212
View File
@@ -0,0 +1,212 @@
package appeng.client.gui.implementations;
import java.io.IOException;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiTextField;
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.GuiTabButton;
import appeng.container.AEBaseContainer;
import appeng.container.implementations.ContainerPriority;
import appeng.core.localization.GuiText;
import appeng.core.sync.GuiBridge;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.core.sync.packets.PacketValueConfig;
import appeng.helpers.IPriorityHost;
import appeng.parts.misc.PartStorageBus;
import appeng.tile.storage.TileChest;
import appeng.tile.storage.TileDrive;
import cpw.mods.fml.common.network.PacketDispatcher;
public class GuiPriority extends AEBaseGui
{
GuiTextField 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();
buttonList.add( plus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 32, 22, 20, "+1" ) );
buttonList.add( plus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 32, 28, 20, "+10" ) );
buttonList.add( plus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 32, 32, 20, "+100" ) );
buttonList.add( plus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 32, 38, 20, "+1000" ) );
buttonList.add( minus1 = new GuiButton( 0, this.guiLeft + 20, this.guiTop + 69, 22, 20, "-1" ) );
buttonList.add( minus10 = new GuiButton( 0, this.guiLeft + 48, this.guiTop + 69, 28, 20, "-10" ) );
buttonList.add( minus100 = new GuiButton( 0, this.guiLeft + 82, this.guiTop + 69, 32, 20, "-100" ) );
buttonList.add( minus1000 = new GuiButton( 0, this.guiLeft + 120, this.guiTop + 69, 38, 20, "-1000" ) );
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 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 ( OriginalGui != null )
buttonList.add( originalGuiBtn = new GuiTabButton( this.guiLeft + 154, this.guiTop, myIcon, myIcon.getDisplayName(), itemRenderer ) );
priority = new GuiTextField( this.fontRenderer, this.guiLeft + 62, this.guiTop + 57, 59, this.fontRenderer.FONT_HEIGHT );
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
{
PacketDispatcher.sendPacketToServer( (new PacketSwitchGuis( OriginalGui )).getPacket() );
}
catch (IOException e)
{
e.printStackTrace();
}
}
if ( btn == plus1 )
addQty( 1 );
if ( btn == plus10 )
addQty( 10 );
if ( btn == plus100 )
addQty( 100 );
if ( btn == plus1000 )
addQty( 1000 );
if ( btn == minus1 )
addQty( -1 );
if ( btn == minus10 )
addQty( -10 );
if ( btn == minus100 )
addQty( -100 );
if ( btn == minus1000 )
addQty( -1000 );
}
private void addQty(int i)
{
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 ) );
PacketDispatcher.sendPacketToServer( (new PacketValueConfig( "PriorityHost.Priority", Out )).getPacket() );
}
catch (IOException e)
{
e.printStackTrace();
}
}
@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";
PacketDispatcher.sendPacketToServer( (new PacketValueConfig( "PriorityHost.Priority", Out )).getPacket() );
}
catch (IOException e)
{
e.printStackTrace();
}
}
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)
{
fontRenderer.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.ContainerSecurity;
import appeng.core.localization.GuiText;
import appeng.tile.misc.TileSecurity;
public class GuiSecurity extends AEBaseGui
{
public GuiSecurity(InventoryPlayer inventoryPlayer, TileSecurity te) {
super( new ContainerSecurity( inventoryPlayer, te ) );
this.ySize = 199;
}
@Override
public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY)
{
bindTexture( "guis/security.png" );
this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize );
}
@Override
public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY)
{
fontRenderer.drawString( GuiText.Security.getLocal(), 8, 6, 4210752 );
fontRenderer.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 );
}
}
+131
View File
@@ -0,0 +1,131 @@
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.ExtraTextures;
public class GuiTabButton extends GuiButton implements ITooltip
{
RenderItem itemRenderer;
int myIcon = -1;
ItemStack myItem;
String Msg;
public void setVisibility(boolean vis)
{
drawButton = 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 drawButton;
}
@Override
public void drawButton(Minecraft par1Minecraft, int par2, int par3)
{
if ( this.drawButton )
{
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
par1Minecraft.renderEngine.bindTexture( ExtraTextures.GuiTexture( "guis/states.png" ) );
this.field_82253_i = 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 = 13 - uv_y * 16;
this.drawTexturedModalRect( this.xPosition, this.yPosition, uv_x * 16, uv_y * 16, 22, 22 );
if ( myIcon >= 0 )
{
uv_y = (int) Math.floor( myIcon / 16 );
uv_x = myIcon - uv_y * 16;
this.drawTexturedModalRect( 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, 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;
}
}