From ad1b341ecf08a44c4beae31c4922c0079afb9d25 Mon Sep 17 00:00:00 2001 From: AlgorithmX2 Date: Sat, 28 Dec 2013 15:03:20 -0600 Subject: [PATCH] Interface Gui mostly done. --- client/gui/implementations/GuiInterface.java | 36 +++++++++++++++++++ .../implementations/ContainerInterface.java | 32 +++++++++++++++++ core/localization/GuiText.java | 2 +- core/sync/GuiBridge.java | 31 +++++++++------- 4 files changed, 87 insertions(+), 14 deletions(-) create mode 100644 client/gui/implementations/GuiInterface.java create mode 100644 container/implementations/ContainerInterface.java diff --git a/client/gui/implementations/GuiInterface.java b/client/gui/implementations/GuiInterface.java new file mode 100644 index 00000000..d72c654b --- /dev/null +++ b/client/gui/implementations/GuiInterface.java @@ -0,0 +1,36 @@ +package appeng.client.gui.implementations; + +import net.minecraft.entity.player.InventoryPlayer; +import appeng.client.gui.AEBaseGui; +import appeng.container.implementations.ContainerInterface; +import appeng.core.localization.GuiText; +import appeng.tile.misc.TileInterface; + +public class GuiInterface extends AEBaseGui +{ + + public GuiInterface(InventoryPlayer inventoryPlayer, TileInterface te) { + super( new ContainerInterface( inventoryPlayer, te ) ); + this.ySize = 211; + } + + @Override + public void drawBG(int offsetX, int offsetY, int mouseX, int mouseY) + { + bindTexture( "guis/interface.png" ); + this.drawTexturedModalRect( offsetX, offsetY, 0, 0, xSize, ySize ); + } + + @Override + public void drawFG(int offsetX, int offsetY, int mouseX, int mouseY) + { + fontRenderer.drawString( GuiText.Interface.getLocal(), 8, 6, 4210752 ); + + fontRenderer.drawString( GuiText.Config.getLocal(), 8, 6 + 11 + 7, 4210752 ); + fontRenderer.drawString( GuiText.StoredItems.getLocal(), 8 + 18, 6 + 60 + 7, 4210752 ); + fontRenderer.drawString( GuiText.Patterns.getLocal(), 8, 6 + 73 + 7, 4210752 ); + + fontRenderer.drawString( GuiText.inventory.getLocal(), 8, ySize - 96 + 3, 4210752 ); + } + +} diff --git a/container/implementations/ContainerInterface.java b/container/implementations/ContainerInterface.java new file mode 100644 index 00000000..b8ee504a --- /dev/null +++ b/container/implementations/ContainerInterface.java @@ -0,0 +1,32 @@ +package appeng.container.implementations; + +import net.minecraft.entity.player.InventoryPlayer; +import appeng.container.AEBaseContainer; +import appeng.container.slot.SlotFake; +import appeng.container.slot.SlotNormal; +import appeng.container.slot.SlotRestrictedInput; +import appeng.container.slot.SlotRestrictedInput.PlaceableItemType; +import appeng.tile.misc.TileInterface; + +public class ContainerInterface extends AEBaseContainer +{ + + TileInterface myte; + + public ContainerInterface(InventoryPlayer ip, TileInterface te) { + super( ip, te ); + myte = te; + + for (int x = 0; x < 8; x++) + addSlotToContainer( new SlotFake( myte.getConfig(), x, 8 + 18 * x, 28 + 7 ) ); + + for (int x = 0; x < 8; x++) + addSlotToContainer( new SlotNormal( myte, x, 26 + 18 * x, 46 + 7 ) ); + + for (int x = 0; x < 9; x++) + addSlotToContainer( new SlotRestrictedInput( PlaceableItemType.ENCODED_PATTERN, myte.getPatterns(), x, 8 + 18 * x, 90 + 7 ) ); + + bindPlayerInventory( ip, 0, 211 - /* height of playerinventory */82 ); + } + +} diff --git a/core/localization/GuiText.java b/core/localization/GuiText.java index 3d7966ab..142169bf 100644 --- a/core/localization/GuiText.java +++ b/core/localization/GuiText.java @@ -7,7 +7,7 @@ public enum GuiText { inventory("container"), // mc's default Inventory localization. - Chest, StoredEnergy, Of, Condenser, Drive, GrindStone, VibrationChamber, SpatialIOPort, NetworkStatus, LevelEmitter, Terminal; + Chest, StoredEnergy, Of, Condenser, Drive, GrindStone, VibrationChamber, SpatialIOPort, NetworkStatus, LevelEmitter, Terminal, Interface, Config, StoredItems, Patterns; String root; diff --git a/core/sync/GuiBridge.java b/core/sync/GuiBridge.java index 281898e7..9ffac9d3 100644 --- a/core/sync/GuiBridge.java +++ b/core/sync/GuiBridge.java @@ -1,6 +1,7 @@ package appeng.core.sync; import java.lang.reflect.Constructor; + import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.InventoryPlayer; import net.minecraft.tileentity.TileEntity; @@ -16,10 +17,12 @@ import appeng.container.implementations.ContainerChest; import appeng.container.implementations.ContainerCondenser; import appeng.container.implementations.ContainerDrive; import appeng.container.implementations.ContainerGrinder; +import appeng.container.implementations.ContainerInterface; import appeng.container.implementations.ContainerMEMonitorable; import appeng.container.implementations.ContainerVibrationChamber; import appeng.tile.grindstone.TileGrinder; import appeng.tile.misc.TileCondenser; +import appeng.tile.misc.TileInterface; import appeng.tile.misc.TileVibrationChamber; import appeng.tile.storage.TileChest; import appeng.tile.storage.TileDrive; @@ -41,7 +44,9 @@ public enum GuiBridge implements IGuiHandler GUI_VIBRATIONCHAMBER(ContainerVibrationChamber.class, TileVibrationChamber.class), - GUI_CONDENSER(ContainerCondenser.class, TileCondenser.class); + GUI_CONDENSER(ContainerCondenser.class, TileCondenser.class), + + GUI_INTERFACE(ContainerInterface.class, TileInterface.class); private Class Tile; private Class Gui; @@ -106,7 +111,7 @@ public enum GuiBridge implements IGuiHandler } } - public Object ConstructGui(InventoryPlayer inventory,ForgeDirection side, Object tE) + public Object ConstructGui(InventoryPlayer inventory, ForgeDirection side, Object tE) { try { @@ -124,7 +129,7 @@ public enum GuiBridge implements IGuiHandler @Override public Object getServerGuiElement(int ID_ORDINAL, EntityPlayer player, World w, int x, int y, int z) { - ForgeDirection side = ForgeDirection.getOrientation( ID_ORDINAL& 0x07 ); + ForgeDirection side = ForgeDirection.getOrientation( ID_ORDINAL & 0x07 ); GuiBridge ID = values()[ID_ORDINAL >> 3]; TileEntity TE = w.getBlockTileEntity( x, y, z ); @@ -132,32 +137,32 @@ public enum GuiBridge implements IGuiHandler if ( TE instanceof IPartHost ) { ((IPartHost) TE).getPart( side ); - IPart part = ((IPartHost) TE).getPart(side); - if ( ID.CorrectTileOrPart(part) ) + IPart part = ((IPartHost) TE).getPart( side ); + if ( ID.CorrectTileOrPart( part ) ) return ID.ConstructContainer( player.inventory, side, part ); } else { - if ( ID.CorrectTileOrPart( TE ) ) - return ID.ConstructContainer( player.inventory, side, TE ); + if ( ID.CorrectTileOrPart( TE ) ) + return ID.ConstructContainer( player.inventory, side, TE ); } - + return new ContainerNull(); } @Override public Object getClientGuiElement(int ID_ORDINAL, EntityPlayer player, World w, int x, int y, int z) { - ForgeDirection side = ForgeDirection.getOrientation( ID_ORDINAL& 0x07 ); + ForgeDirection side = ForgeDirection.getOrientation( ID_ORDINAL & 0x07 ); GuiBridge ID = values()[ID_ORDINAL >> 3]; TileEntity TE = w.getBlockTileEntity( x, y, z ); - + if ( TE instanceof IPartHost ) { ((IPartHost) TE).getPart( side ); - IPart part = ((IPartHost) TE).getPart(side); - if ( ID.CorrectTileOrPart(part) ) + IPart part = ((IPartHost) TE).getPart( side ); + if ( ID.CorrectTileOrPart( part ) ) return ID.ConstructGui( player.inventory, side, part ); } else @@ -165,7 +170,7 @@ public enum GuiBridge implements IGuiHandler if ( ID.CorrectTileOrPart( TE ) ) return ID.ConstructGui( player.inventory, side, TE ); } - + return new GuiNull( new ContainerNull() ); }