Getting rid of NewContainerGui

This commit is contained in:
Qowyn committed 2014-09-23 23:34:30 +02:00
1 parent a0a9e222a3
commit 6d4738d2b7
5 files changed
+81 -1038

No files matched your search

@@ -1,15 +1,14 @@
package tconstruct.tools.gui;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.*;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
import tconstruct.client.gui.NewContainerGui;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.crafting.PatternBuilder;
import tconstruct.library.tools.ToolMaterial;
@@ -18,7 +17,7 @@ import tconstruct.smeltery.inventory.ActiveContainer;
import tconstruct.tools.inventory.PartCrafterChestContainer;
import tconstruct.tools.logic.PartBuilderLogic;
public class PartCrafterGui extends NewContainerGui
public class PartCrafterGui extends GuiContainer
{
PartBuilderLogic logic;
String title, otherTitle = "";
@@ -27,22 +26,64 @@ public class PartCrafterGui extends NewContainerGui
ItemStack topMaterial, bottomMaterial;
ToolMaterial topEnum, bottomEnum;
// Panel positions
int craftingLeft = 0;
int craftingTop = 0;
int descLeft = 0;
int descTop = 0;
int chestLeft = 0;
int chestTop = 0;
public PartCrafterGui(InventoryPlayer inventoryplayer, PartBuilderLogic partlogic, World world, int x, int y, int z)
{
super((ActiveContainer) partlogic.getGuiContainer(inventoryplayer, world, x, y, z));
logic = partlogic;
drawChestPart = container instanceof PartCrafterChestContainer;
drawChestPart = inventorySlots instanceof PartCrafterChestContainer;
title = "\u00A7n" + (StatCollector.translateToLocal("gui.partcrafter1"));
}
@Override
public void initGui ()
{
super.initGui();
this.xSize = 176;
this.ySize = 166;
this.guiLeft = (this.width - this.xSize) / 2;
this.guiTop = (this.height - this.ySize) / 2;
this.craftingLeft = this.guiLeft;
this.craftingTop = this.guiTop;
this.descTop = this.craftingTop;
this.descLeft = (this.width + this.xSize) / 2;
if (drawChestPart)
{
this.xSize += 122;
this.guiLeft -= 122;
this.chestLeft = this.guiLeft + 6;
this.chestTop = this.guiTop + 11;
}
}
@Override
protected void drawGuiContainerForegroundLayer (int par1, int par2)
{
this.fontRendererObj.drawString(StatCollector.translateToLocal("crafters.PartBuilder"), 6, 6, 4210752);
this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
int offsetX = 0;
if (drawChestPart)
this.fontRendererObj.drawString(StatCollector.translateToLocal("inventory.PatternChest"), -108, this.ySize - 148, 4210752);
{
this.fontRendererObj.drawString(StatCollector.translateToLocal("inventory.PatternChest"), 14, 17, 4210752);
offsetX = 122;
}
this.fontRendererObj.drawString(StatCollector.translateToLocal("crafters.PartBuilder"), offsetX + 6, 6, 4210752);
this.fontRendererObj.drawString(StatCollector.translateToLocal("container.inventory"), offsetX + 8, this.ySize - 96 + 2, 4210752);
drawMaterialInformation();
}
@@ -137,27 +178,25 @@ public class PartCrafterGui extends NewContainerGui
// Draw the background
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(background);
int cornerX = (this.width - this.xSize) / 2;
int cornerY = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(cornerX, cornerY, 0, 0, this.xSize, this.ySize);
this.drawTexturedModalRect(craftingLeft, craftingTop, 0, 0, 176, 166);
// Draw Slots
this.drawTexturedModalRect(cornerX + 39, cornerY + 26, 0, 166, 98, 36);
this.drawTexturedModalRect(craftingLeft + 39, craftingTop + 26, 0, 166, 98, 36);
if (!logic.isStackInSlot(0))
{
this.drawTexturedModalRect(cornerX + 39, cornerY + 26, 176, 0, 18, 18);
this.drawTexturedModalRect(craftingLeft + 39, craftingTop + 26, 176, 0, 18, 18);
}
if (!logic.isStackInSlot(2))
{
this.drawTexturedModalRect(cornerX + 57, cornerY + 26, 176, 18, 18, 18);
this.drawTexturedModalRect(craftingLeft + 57, craftingTop + 26, 176, 18, 18, 18);
}
if (!logic.isStackInSlot(1))
{
this.drawTexturedModalRect(cornerX + 39, cornerY + 44, 176, 0, 18, 18);
this.drawTexturedModalRect(craftingLeft + 39, craftingTop + 44, 176, 0, 18, 18);
}
if (!logic.isStackInSlot(3))
{
this.drawTexturedModalRect(cornerX + 57, cornerY + 44, 176, 36, 18, 18);
this.drawTexturedModalRect(craftingLeft + 57, craftingTop + 44, 176, 36, 18, 18);
}
// Draw chest
@@ -165,115 +204,13 @@ public class PartCrafterGui extends NewContainerGui
{
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(minichest);
this.drawTexturedModalRect(cornerX - 116, cornerY + 11, 0, 0, this.xSize, this.ySize);
this.drawTexturedModalRect(chestLeft, chestTop, 0, 0, 122, 114);
}
// Draw description
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.getTextureManager().bindTexture(description);
cornerX = (this.width + this.xSize) / 2;
cornerY = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(cornerX, cornerY, 126, 0, 126, this.ySize);
this.drawTexturedModalRect(descLeft, descTop, 126, 0, 126, this.ySize);
}
@Override
protected void mouseClicked (int mouseX, int mouseY, int clickNum)
{
boolean flag = clickNum == this.mc.gameSettings.keyBindPickBlock.getKeyCode() + 100;
Slot slot = this.getSlotAtPosition(mouseX, mouseY);
long l = Minecraft.getSystemTime();
this.field_94074_J = this.field_94072_H == slot && l - this.field_94070_G < 250L && this.field_94073_I == clickNum;
this.field_94068_E = false;
int offsetLeft = drawChestPart ? 108 : 0;
if (clickNum == 0 || clickNum == 1 || flag)
{
int i1 = this.guiLeft;
int j1 = this.guiTop;
boolean flag1 = mouseX < i1 - offsetLeft || mouseY < j1 || mouseX >= i1 + this.xSize || mouseY >= j1 + this.ySize;
int k1 = -1;
if (slot != null)
{
k1 = slot.slotNumber;
}
if (flag1)
{
k1 = -999;
}
if (this.mc.gameSettings.touchscreen && flag1 && this.mc.thePlayer.inventory.getItemStack() == null)
{
this.mc.displayGuiScreen((GuiScreen) null);
return;
}
if (k1 != -1)
{
if (this.mc.gameSettings.touchscreen)
{
if (slot != null && slot.getHasStack())
{
this.clickedSlot = slot;
this.draggedStack = null;
this.isRightMouseClick = clickNum == 1;
}
else
{
this.clickedSlot = null;
}
}
else if (!this.field_94076_q)
{
if (this.mc.thePlayer.inventory.getItemStack() == null)
{
if (clickNum == this.mc.gameSettings.keyBindPickBlock.getKeyCode() + 100)
{
this.handleMouseClick(slot, k1, clickNum, 3);
}
else
{
boolean flag2 = k1 != -999 && (Keyboard.isKeyDown(42) || Keyboard.isKeyDown(54));
byte b0 = 0;
if (flag2)
{
this.field_94075_K = slot != null && slot.getHasStack() ? slot.getStack() : null;
b0 = 1;
}
else if (k1 == -999)
{
b0 = 4;
}
this.handleMouseClick(slot, k1, clickNum, b0);
}
this.field_94068_E = true;
}
else
{
this.field_94076_q = true;
this.field_94067_D = clickNum;
this.field_94077_p.clear();
if (clickNum == 0)
{
this.field_94071_C = 0;
}
else if (clickNum == 1)
{
this.field_94071_C = 1;
}
}
}
}
}
this.field_94072_H = slot;
this.field_94070_G = l;
this.field_94073_I = clickNum;
}
}