From 5edf734292728114d327692b9f468fe5a3af73d7 Mon Sep 17 00:00:00 2001 From: Ben Spiers Date: Fri, 11 Apr 2014 21:10:14 +0100 Subject: [PATCH] Gui work --- common/mekanism/client/gui/GuiPRC.java | 14 +- common/mekanism/client/gui/GuiSlot.java | 124 ++++++++++++++++++ common/mekanism/common/Mekanism.java | 1 + .../inventory/container/ContainerPRC.java | 4 +- .../mekanism/common/tile/TileEntityPRC.java | 6 + .../assets/mekanism/gui/elements/GuiSlot.png | Bin 879 -> 873 bytes resources/assets/mekanism/lang/en_US.lang | 1 + 7 files changed, 144 insertions(+), 6 deletions(-) create mode 100644 common/mekanism/client/gui/GuiSlot.java diff --git a/common/mekanism/client/gui/GuiPRC.java b/common/mekanism/client/gui/GuiPRC.java index fda7d204d..a7be02a0b 100644 --- a/common/mekanism/client/gui/GuiPRC.java +++ b/common/mekanism/client/gui/GuiPRC.java @@ -3,6 +3,8 @@ package mekanism.client.gui; import mekanism.api.gas.GasTank; import mekanism.client.gui.GuiFluidGauge.IFluidInfoHandler; import mekanism.client.gui.GuiGasGauge.IGasInfoHandler; +import mekanism.client.gui.GuiSlot.SlotOverlay; +import mekanism.client.gui.GuiSlot.SlotType; import mekanism.common.inventory.container.ContainerPRC; import mekanism.common.tile.TileEntityPRC; import mekanism.common.util.MekanismUtils; @@ -28,22 +30,26 @@ public class GuiPRC extends GuiMekanism { return tileEntity.inputFluidTank; } - }, GuiGauge.Type.STANDARD, this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), 5, 10)); + }, GuiGauge.Type.STANDARD, this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiPRC.png"), 5, 10)); guiElements.add(new GuiGasGauge(new IGasInfoHandler() { @Override public GasTank getTank() { return tileEntity.inputGasTank; } - }, GuiGauge.Type.SMALL, this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), 33, 18)); + }, GuiGauge.Type.STANDARD, this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiPRC.png"), 28, 10)); guiElements.add(new GuiGasGauge(new IGasInfoHandler() { @Override public GasTank getTank() { return tileEntity.outputGasTank; } - }, GuiGauge.Type.SMALL, this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"), 100, 18)); + }, GuiGauge.Type.SMALL, this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiPRC.png"), 140, 40)); guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiPRC.png"), 164, 15)); + + guiElements.add(new GuiSlot(SlotType.INPUT, this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiPRC.png"), 53, 34)); + guiElements.add(new GuiSlot(SlotType.POWER, this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiPRC.png"), 140, 18).with(SlotOverlay.POWER)); + guiElements.add(new GuiSlot(SlotType.OUTPUT, this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiPRC.png"), 115, 34)); } @Override @@ -52,7 +58,7 @@ public class GuiPRC extends GuiMekanism int xAxis = (mouseX - (width - xSize) / 2); int yAxis = (mouseY - (height - ySize) / 2); - fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040); + fontRenderer.drawString(tileEntity.getInvName(), 81, 6, 0x404040); fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); super.drawGuiContainerForegroundLayer(mouseX, mouseY); diff --git a/common/mekanism/client/gui/GuiSlot.java b/common/mekanism/client/gui/GuiSlot.java new file mode 100644 index 000000000..8e3a82b66 --- /dev/null +++ b/common/mekanism/client/gui/GuiSlot.java @@ -0,0 +1,124 @@ +package mekanism.client.gui; + +import mekanism.common.util.MekanismUtils; +import mekanism.common.util.MekanismUtils.ResourceType; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ResourceLocation; + +public class GuiSlot extends GuiElement +{ + protected int xLocation; + protected int yLocation; + + protected int textureX; + protected int textureY; + + protected int width; + protected int height; + + protected SlotOverlay overlay = null; + + public GuiSlot(SlotType type, GuiMekanism gui, TileEntity tile, ResourceLocation def, int x, int y) + { + super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiSlot.png"), gui, tile, def); + + xLocation = x; + yLocation = y; + + width = type.width; + height = type.height; + + textureX = type.textureX; + textureY = type.textureY; + } + + public GuiSlot with(SlotOverlay overlay) + { + this.overlay = overlay; + return this; + } + + @Override + public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) + { + mc.renderEngine.bindTexture(RESOURCE); + + guiObj.drawTexturedModalRect(guiWidth + xLocation, guiHeight + yLocation, textureX, textureY, width, height); + + if(overlay != null) + { + int w = overlay.width; + int h = overlay.height; + int xLocationOverlay = xLocation + (width-w)/2; + int yLocationOverlay = yLocation + (height-h)/2; + + guiObj.drawTexturedModalRect(guiWidth + xLocationOverlay, guiHeight + yLocationOverlay, overlay.textureX, overlay.textureY, w, h); + } + + mc.renderEngine.bindTexture(defaultLocation); + } + + @Override + public void renderForeground(int xAxis, int yAxis) + { + } + + @Override + public void preMouseClicked(int xAxis, int yAxis, int button) + { + } + + @Override + public void mouseClicked(int xAxis, int yAxis, int button) + { + } + + public enum SlotType + { + NORMAL(18, 18, 0, 0), + POWER(18, 18, 18, 0), + INPUT(18, 18, 36, 0), + EXTRA(18, 18, 54, 0), + OUTPUT(18, 18, 72, 0), + OUTPUT_LARGE(26, 26, 90, 0), + OUTPUT_WIDE(42, 26, 116, 0); + + public int width; + public int height; + + public int textureX; + public int textureY; + + private SlotType(int w, int h, int x, int y) + { + width = w; + height = h; + + textureX = x; + textureY = y; + } + } + + public enum SlotOverlay + { + MINUS(18, 18, 0, 18), + PLUS(18, 18, 18, 18), + POWER(18, 18, 36, 18); + + public int width; + public int height; + + public int textureX; + public int textureY; + + private SlotOverlay(int w, int h, int x, int y) + { + width = w; + height = h; + + textureX = x; + textureY = y; + } + } +} diff --git a/common/mekanism/common/Mekanism.java b/common/mekanism/common/Mekanism.java index a39fd75a4..bf62123c7 100644 --- a/common/mekanism/common/Mekanism.java +++ b/common/mekanism/common/Mekanism.java @@ -663,6 +663,7 @@ public class Mekanism CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(BlockHDPE, 4, 15), new Object[] { "SSS", "S S", "SSS", Character.valueOf('S'), new ItemStack(Polyethene, 1, 2) })); + for(int i = 0; i < EnumColor.DYES.length-1; i++) { CraftingManager.getInstance().getRecipeList().add(new MekanismRecipe(new ItemStack(BlockHDPE, 4, i), new Object[] { diff --git a/common/mekanism/common/inventory/container/ContainerPRC.java b/common/mekanism/common/inventory/container/ContainerPRC.java index 4277700a3..14d078cb4 100644 --- a/common/mekanism/common/inventory/container/ContainerPRC.java +++ b/common/mekanism/common/inventory/container/ContainerPRC.java @@ -20,8 +20,8 @@ public class ContainerPRC extends Container public ContainerPRC(InventoryPlayer inventory, TileEntityPRC tentity) { tileEntity = tentity; - addSlotToContainer(new Slot(tentity, 0, 56, 17)); - addSlotToContainer(new SlotDischarge(tentity, 1, 56, 53)); + addSlotToContainer(new Slot(tentity, 0, 54, 35)); + addSlotToContainer(new SlotDischarge(tentity, 1, 141, 19)); addSlotToContainer(new SlotOutput(tentity, 2, 116, 35)); addSlotToContainer(new SlotMachineUpgrade(tentity, 3, 180, 11)); int slotX; diff --git a/common/mekanism/common/tile/TileEntityPRC.java b/common/mekanism/common/tile/TileEntityPRC.java index fb289fea1..ea1b4bfb9 100644 --- a/common/mekanism/common/tile/TileEntityPRC.java +++ b/common/mekanism/common/tile/TileEntityPRC.java @@ -329,6 +329,12 @@ public class TileEntityPRC extends TileEntityBasicMachine implements IFluidHandl nbtTags.setBoolean("dumpRight", dumpRight); */ } + @Override + public String getInvName() + { + return MekanismUtils.localize(getBlockType().getUnlocalizedName() + "." + fullName + ".short.name"); + } + @Override public Map getRecipes() { diff --git a/resources/assets/mekanism/gui/elements/GuiSlot.png b/resources/assets/mekanism/gui/elements/GuiSlot.png index cd3ddb754ea2fbc87ce9f68cac4e68590cd54970..183afdfe86c4e945e068d9ae5916c9bbb311d796 100644 GIT binary patch delta 591 zcmV-V02I&TnQ-2E+6ezuBp9i+t;+tV+ zzjyxqnfa&ccDro~^?JQ*pEjjsGQX63J*f$b&zt)NiOp69&0-j z*w1#S3jf{QRRfo(>pI(~O}0Pxi|TyqG|6GI(BCVnv)XLtB*~Zl%c43zn~zBj(%*Yu zRHxZ|m$Vnfb*5!IliAN5-8ThZI0PU70096906+i$0ss&IfB*ml03ZMW0RRX9KmY&& z01yDcw3_SndVi_w^2IaemoA^@FSL*wW_FEl?N$SHtzY+;=4J{i^f!=GA|;MgTA)BY@J0y4&iMP6A$y0hu5r002ovPDHLkV1mEW7#9El delta 598 zcmV-c0;&D!2JZ%tQ-22#At6v_?@Isx0{lrtK~#9!?cFg>6k!+!;CGA#y^)RsNH!K& zUw}noz(EH~|!7lRbrv2XHL}BZ-*Rf0k@^o~PX6V>0ab z&Od)W8y7!0y^-jtTf%6jtgxGJu*nkr|hi|edqJAWtDQOa#3xyt-)B-8yW zFr&w}4P2tG>+GF3*?T`Ks`I(mB*)3>=%A?1RVFSQ9RPo7{v>(!Jjs*B*@tBgfYZZKCKsdhUfjLp)^FbD zFSME}Tg`59owaP=yw6{1z>(0I&z}fBOA?E0cxV(%wWM klYs)!laK-l7=Y#X16Ee7U#hHy%K!iX07*qoM6N<$g2x*ao&W#< diff --git a/resources/assets/mekanism/lang/en_US.lang b/resources/assets/mekanism/lang/en_US.lang index 7eb7aef25..ded52c50e 100644 --- a/resources/assets/mekanism/lang/en_US.lang +++ b/resources/assets/mekanism/lang/en_US.lang @@ -99,6 +99,7 @@ tile.MachineBlock2.ChemicalWasher.name=Chemical Washer tile.MachineBlock2.ChemicalCrystalizer.name=Chemical Crystalizer tile.MachineBlock2.SeismicVibrator.name=Seismic Vibrator tile.MachineBlock2.PressurizedReactionChamber.name=Pressurized Reaction Chamber +tile.MachineBlock2.PressurizedReactionChamber.short.name=PRC //Plastic tile.PlasticBlock.PlasticBlock.name=Plastic Block