From 05c78126859231a68e199dc34613689bd0978e2f Mon Sep 17 00:00:00 2001 From: Foghrye4 Date: Mon, 11 Apr 2016 19:44:54 +0300 Subject: Initial commit --- ihl/flexible_cable/IronWorkbenchGui.java | 197 +++++++++++++++++++++++++++++++ 1 file changed, 197 insertions(+) create mode 100644 ihl/flexible_cable/IronWorkbenchGui.java (limited to 'ihl/flexible_cable/IronWorkbenchGui.java') diff --git a/ihl/flexible_cable/IronWorkbenchGui.java b/ihl/flexible_cable/IronWorkbenchGui.java new file mode 100644 index 0000000..131f2f7 --- /dev/null +++ b/ihl/flexible_cable/IronWorkbenchGui.java @@ -0,0 +1,197 @@ +package ihl.flexible_cable; + +import cpw.mods.fml.relauncher.Side; +import cpw.mods.fml.relauncher.SideOnly; +import ic2.core.IC2; +import net.minecraft.client.gui.inventory.GuiContainer; +import net.minecraft.inventory.Slot; +import net.minecraft.util.ResourceLocation; + +import org.lwjgl.opengl.GL11; + +import ic2.core.network.NetworkManager; +import ihl.interfaces.IItemHasMiniGUI; +import ihl.interfaces.ItemMiniGUI; +import ihl.utils.IHLRenderUtils; + +@SideOnly(Side.CLIENT) +public class IronWorkbenchGui extends GuiContainer { + private static final ResourceLocation background = new ResourceLocation("ihl", "textures/gui/GUIIronWorkbench.png"); + private IronWorkbenchContainer container; + private ItemMiniGUI miniGui; + private static final short outputslotoffset=66; + + public IronWorkbenchGui (IronWorkbenchContainer container1) { + //the container is instanciated and passed to the superclass for handling + super(container1); + this.container=container1; + this.ySize=IronWorkbenchContainer.height; + } + + @Override + public void initGui() + { + super.initGui(); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + } + + @Override + protected void drawGuiContainerForegroundLayer(int par1, int par2) + { + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + for(int row = 1;row<6;row++) + { + if(!this.container.tileEntity.workspaceElements.ready[row] && this.container.tileEntity.workspaceElements.get(row)!=null) + { + IHLRenderUtils.instance.drawWorkspaceElementTooltip(par1, par2, 8+x, 8+y+row*18, this.container.tileEntity.workspaceElements.get(row)); + } + } + if(miniGui!=null) + { + miniGui.displayGUI(); + } + } + + @Override + protected void keyTyped(char characterTyped, int keyIndex) + { + super.keyTyped(characterTyped, keyIndex); + if(miniGui!=null && miniGui.handleKeyTyped(characterTyped, keyIndex)) + { + miniGui.onGUIClosed(); + miniGui=null; + } + } + + @Override + protected void mouseClicked(int mouseX, int mouseY, int mouseButton) + { + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + if(miniGui==null || !miniGui.handleMouseClick(mouseX-x, mouseY-y, mouseButton)) + { + if(miniGui!=null) + { + miniGui.onGUIClosed(); + miniGui=null; + } + super.mouseClicked(mouseX, mouseY, mouseButton); + } + } + + @Override + protected void mouseMovedOrUp(int mouseX, int mouseY, int mouseButton) + { + super.mouseMovedOrUp(mouseX, mouseY, mouseButton); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + if(miniGui!=null) + { + miniGui.handleMouseClick(mouseX-x, mouseY-y, mouseButton); + } + } + + @Override + protected void drawGuiContainerBackgroundLayer(float par1, int par2, + int par3) { + GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); + this.mc.renderEngine.bindTexture(background); + int x = (width - xSize) / 2; + int y = (height - ySize) / 2; + this.drawTexturedModalRect(x, y, 0, 0, xSize, ySize); + if (this.container.tileEntity.progress > 0) + { + int progressLevel=Math.min(Math.round(this.container.tileEntity.progress*16.0F/this.container.tileEntity.maxProgress),16); + int frameNum=0; + short slotRecipeNum=this.container.tileEntity.output.slotRecipe[0]; + for(int row = 0;row<6;row++) + { + for (int col = 0; col<3; ++col) + { + if(slotRecipeNum!=this.container.tileEntity.output.slotRecipe[col+row*3]) + { + frameNum++; + slotRecipeNum=this.container.tileEntity.output.slotRecipe[col+row*3]; + } + if(this.container.tileEntity.currentSlot==slotRecipeNum) + { + int i1 = Math.min(this.container.tileEntity.gaugeProgressScaled(18),18); + this.drawTexturedModalRect(115+x+col*18, 7+y+row*18, 176, 72,i1,18); + this.drawTexturedModalRect(115+x+col*18, 7+y+row*18, 176+getFrameX(frameNum), getFrameY(frameNum),18,18); + } + } + } + } + else + { + int frameNum=0; + short slotRecipeNum=this.container.tileEntity.output.slotRecipe[0]; + for(int row = 0;row<6;row++) + { + for (int col = 0;col<3; ++col) + { + if(slotRecipeNum!=this.container.tileEntity.output.slotRecipe[col+row*3]) + { + frameNum++; + slotRecipeNum=this.container.tileEntity.output.slotRecipe[col+row*3]; + } + if(this.container.tileEntity.output.get(col+row*3)!=null) + { + this.drawTexturedModalRect(115+x+col*18, 7+y+row*18, 176+getFrameX(frameNum), getFrameY(frameNum),18,18); + } + } + } + } + for(int row = 1;row<6;row++) + { + if(!this.container.tileEntity.workspaceElements.ready[row]) + { + this.drawTexturedModalRect(20+x, 9+y+row*18, 194, 74,3,14); + } + } + } + + @Override + public void onGuiClosed() + { + super.onGuiClosed(); + this.container.tileEntity.isGuiScreenOpened=false; + IC2.network.get().initiateClientTileEntityEvent(this.container.tileEntity, 16); + } + + @Override + public void handleMouseClick(Slot slot,int slotNumber,int mouseButton/*0=left 1=right*/,int arg3) + { + if(miniGui==null && slot!=null && slot.slotNumber>=outputslotoffset && slot.slotNumber>2) & 3)*18; + } + +} \ No newline at end of file -- cgit v1.2.3