| package mekanism.client.gui; |
| |
| import mekanism.api.Coord4D; |
| import mekanism.api.EnumColor; |
| import mekanism.api.util.ListUtils; |
| import mekanism.client.gui.element.GuiElement.IInfoHandler; |
| import mekanism.client.gui.element.EnergyInfoGui; |
| import mekanism.client.gui.element.GuiPowerBar; |
| import mekanism.client.gui.element.GuiRedstoneControl; |
| import mekanism.client.gui.element.GuiSlot; |
| import mekanism.client.gui.element.GuiSlot.SlotOverlay; |
| import mekanism.client.gui.element.GuiSlot.SlotType; |
| import mekanism.client.gui.element.GuiUpgradeTab; |
| import mekanism.client.gui.element.VisualsTab; |
| import mekanism.client.render.MekanismRenderer; |
| import mekanism.client.sound.SoundHandler; |
| import mekanism.common.Mekanism; |
| import mekanism.common.content.miner.MinerSearchThread.State; |
| import mekanism.common.inventory.container.DigitalMinerContainer; |
| import mekanism.common.network.DigitalMinerGuiPacket.DigitalMinerGuiMessage; |
| import mekanism.common.network.DigitalMinerGuiPacket.MinerGuiPacket; |
| import mekanism.common.network.PacketTileEntity.TileEntityMessage; |
| import mekanism.common.tile.DigitalMinerTileEntity; |
| import mekanism.common.util.LangUtils; |
| import mekanism.common.util.MekanismUtils; |
| import mekanism.common.util.MekanismUtils.ResourceType; |
| import cpw.mods.fml.relauncher.Side; |
| import cpw.mods.fml.relauncher.SideOnly; |
| import net.minecraft.client.gui.GuiButton; |
| import net.minecraft.entity.player.InventoryPlayer; |
| import org.lwjgl.opengl.GL11; |
| import org.lwjgl.opengl.GL12; |
| import java.util.ArrayList; |
| import java.util.List; |
| |
| @SideOnly(Side.CLIENT) |
| public class DigitalMinerGui extends GuiMekanism |
| { |
| public DigitalMinerTileEntity tileEntity; |
| |
| public GuiButton startButton; |
| public GuiButton stopButton; |
| public GuiButton configButton; |
| |
| public DigitalMinerGui(InventoryPlayer inventory, DigitalMinerTileEntity tentity) |
| { |
| super(tentity, new DigitalMinerContainer(inventory, tentity)); |
| tileEntity = tentity; |
| |
| guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "DigitalMinerGui.png"))); |
| guiElements.add(new GuiUpgradeTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "DigitalMinerGui.png"))); |
| guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "DigitalMinerGui.png"), 163, 23)); |
| guiElements.add(new VisualsTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "DigitalMinerGui.png"))); |
| guiElements.add(new EnergyInfoGui(new IInfoHandler() { |
| @Override |
| public List<String> getInfo() |
| { |
| String multiplier = MekanismUtils.getEnergyDisplay(tileEntity.getPerTick()); |
| return ListUtils.asList(LangUtils.localize("gui.using") + ": " + multiplier + "/t", LangUtils.localize("gui.needed") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy())); |
| } |
| }, this, MekanismUtils.getResource(ResourceType.GUI, "DigitalMinerGui.png"))); |
| |
| guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "DigitalMinerGui.png"), 151, 5).with(SlotOverlay.POWER)); |
| guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "DigitalMinerGui.png"), 143, 26)); |
| |
| ySize+=64; |
| } |
| |
| @Override |
| public void initGui() |
| { |
| super.initGui(); |
| |
| int guiWidth = (width - xSize) / 2; |
| int guiHeight = (height - ySize) / 2; |
| |
| buttonList.clear(); |
| startButton = new GuiButton(0, guiWidth + 69, guiHeight + 17, 60, 20, LangUtils.localize("gui.start")); |
| |
| if(tileEntity.searcher.state != State.IDLE && tileEntity.running) |
| { |
| startButton.enabled = false; |
| } |
| |
| stopButton = new GuiButton(1, guiWidth + 69, guiHeight + 37, 60, 20, LangUtils.localize("gui.stop")); |
| |
| if(tileEntity.searcher.state == State.IDLE || !tileEntity.running) |
| { |
| stopButton.enabled = false; |
| } |
| |
| configButton = new GuiButton(2, guiWidth + 69, guiHeight + 57, 60, 20, LangUtils.localize("gui.config")); |
| |
| if(tileEntity.searcher.state != State.IDLE) |
| { |
| configButton.enabled = false; |
| } |
| |
| buttonList.add(startButton); |
| buttonList.add(stopButton); |
| buttonList.add(configButton); |
| } |
| |
| @Override |
| protected void actionPerformed(GuiButton guibutton) |
| { |
| super.actionPerformed(guibutton); |
| |
| if(guibutton.id == 0) |
| { |
| ArrayList data = new ArrayList(); |
| data.add(Integer.valueOf(3)); |
| |
| Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); |
| } |
| else if(guibutton.id == 1) |
| { |
| ArrayList data = new ArrayList(); |
| data.add(Integer.valueOf(4)); |
| |
| Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); |
| } |
| else if(guibutton.id == 2) |
| { |
| Mekanism.packetHandler.sendToServer(new DigitalMinerGuiMessage(MinerGuiPacket.SERVER, Coord4D.get(tileEntity), 0, 0, 0)); |
| } |
| } |
| |
| @Override |
| public void updateScreen() |
| { |
| super.updateScreen(); |
| |
| if(tileEntity.searcher.state != State.IDLE && tileEntity.running) |
| { |
| startButton.enabled = false; |
| } |
| else { |
| startButton.enabled = true; |
| } |
| |
| if(tileEntity.searcher.state == State.IDLE || !tileEntity.running) |
| { |
| stopButton.enabled = false; |
| } |
| else { |
| stopButton.enabled = true; |
| } |
| |
| if(tileEntity.searcher.state != State.IDLE) |
| { |
| configButton.enabled = false; |
| } |
| else { |
| configButton.enabled = true; |
| } |
| } |
| |
| @Override |
| protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY) |
| { |
| int xAxis = (mouseX - (width - xSize) / 2); |
| int yAxis = (mouseY - (height - ySize) / 2); |
| |
| fontRendererObj.drawString(tileEntity.getInventoryName(), 69, 6, 0x404040); |
| fontRendererObj.drawString(LangUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); |
| |
| fontRendererObj.drawString(tileEntity.running ? LangUtils.localize("gui.digitalMiner.running") : LangUtils.localize("gui.idle"), 9, 10, 0x00CD00); |
| fontRendererObj.drawString(tileEntity.searcher.state.desc, 9, 19, 0x00CD00); |
| |
| fontRendererObj.drawString(LangUtils.localize("gui.eject") + ": " + LangUtils.localize("gui." + (tileEntity.doEject ? "on" : "off")), 9, 30, 0x00CD00); |
| fontRendererObj.drawString(LangUtils.localize("gui.digitalMiner.pull") + ": " + LangUtils.localize("gui." + (tileEntity.doPull ? "on" : "off")), 9, 39, 0x00CD00); |
| fontRendererObj.drawString(LangUtils.localize("gui.digitalMiner.silk") + ": " + LangUtils.localize("gui." + (tileEntity.silkTouch ? "on" : "off")), 9, 48, 0x00CD00); |
| |
| fontRendererObj.drawString(LangUtils.localize("gui.digitalMiner.toMine") + ":", 9, 59, 0x00CD00); |
| fontRendererObj.drawString("" + tileEntity.clientToMine, 9, 68, 0x00CD00); |
| |
| if(tileEntity.missingStack != null) |
| { |
| GL11.glPushMatrix(); |
| GL11.glColor4f(1, 1, 1, 1); |
| GL11.glEnable(GL11.GL_LIGHTING); |
| GL11.glEnable(GL12.GL_RESCALE_NORMAL); |
| |
| mc.getTextureManager().bindTexture(MekanismRenderer.getBlocksTexture()); |
| |
| itemRender.renderIcon(144, 27, MekanismRenderer.getColorIcon(EnumColor.DARK_RED), 16, 16); |
| itemRender.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), tileEntity.missingStack, 144, 27); |
| |
| GL11.glDisable(GL11.GL_LIGHTING); |
| GL11.glPopMatrix(); |
| } |
| else { |
| mc.getTextureManager().bindTexture(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiSlot.png")); |
| drawTexturedModalRect(143, 26, SlotOverlay.CHECK.textureX, SlotOverlay.CHECK.textureY, 18, 18); |
| } |
| |
| if(xAxis >= 164 && xAxis <= 168 && yAxis >= 25 && yAxis <= 77) |
| { |
| drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis); |
| } |
| |
| if(xAxis >= 147 && xAxis <= 161 && yAxis >= 47 && yAxis <= 61) |
| { |
| drawCreativeTabHoveringText(LangUtils.localize("gui.autoEject"), xAxis, yAxis); |
| } |
| |
| if(xAxis >= 147 && xAxis <= 161 && yAxis >= 63 && yAxis <= 77) |
| { |
| drawCreativeTabHoveringText(LangUtils.localize("gui.digitalMiner.autoPull"), xAxis, yAxis); |
| } |
| |
| if(xAxis >= 144 && xAxis <= 160 && yAxis >= 27 && yAxis <= 43) |
| { |
| if(tileEntity.missingStack != null) |
| { |
| drawCreativeTabHoveringText(LangUtils.localize("gui.digitalMiner.missingBlock"), xAxis, yAxis); |
| } |
| else { |
| drawCreativeTabHoveringText(LangUtils.localize("gui.well"), xAxis, yAxis); |
| } |
| } |
| |
| if(xAxis >= 131 && xAxis <= 145 && yAxis >= 47 && yAxis <= 61) |
| { |
| drawCreativeTabHoveringText(LangUtils.localize("gui.digitalMiner.reset"), xAxis, yAxis); |
| } |
| |
| if(xAxis >= 131 && xAxis <= 145 && yAxis >= 63 && yAxis <= 77) |
| { |
| drawCreativeTabHoveringText(LangUtils.localize("gui.digitalMiner.silkTouch"), xAxis, yAxis); |
| } |
| |
| super.drawGuiContainerForegroundLayer(mouseX, mouseY); |
| } |
| |
| @Override |
| protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY) |
| { |
| mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "DigitalMinerGui.png")); |
| GL11.glColor4f(1F, 1F, 1F, 1F); |
| int guiWidth = (width - xSize) / 2; |
| int guiHeight = (height - ySize) / 2; |
| drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize); |
| |
| int xAxis = mouseX - guiWidth; |
| int yAxis = mouseY - guiHeight; |
| |
| int displayInt; |
| |
| displayInt = tileEntity.getScaledEnergyLevel(52); |
| drawTexturedModalRect(guiWidth + 164, guiHeight + 25 + 52 - displayInt, 176, 52 - displayInt, 4, displayInt); |
| |
| if(xAxis >= 147 && xAxis <= 161 && yAxis >= 47 && yAxis <= 61) |
| { |
| drawTexturedModalRect(guiWidth + 147, guiHeight + 47, 176 + 4, 0, 14, 14); |
| } |
| else { |
| drawTexturedModalRect(guiWidth + 147, guiHeight + 47, 176 + 4, 14, 14, 14); |
| } |
| |
| if(xAxis >= 147 && xAxis <= 161 && yAxis >= 63 && yAxis <= 77) |
| { |
| drawTexturedModalRect(guiWidth + 147, guiHeight + 63, 176 + 4 + 14, 0, 14, 14); |
| } |
| else { |
| drawTexturedModalRect(guiWidth + 147, guiHeight + 63, 176 + 4 + 14, 14, 14, 14); |
| } |
| |
| if(xAxis >= 131 && xAxis <= 145 && yAxis >= 47 && yAxis <= 61) |
| { |
| drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 4 + 28, 0, 14, 14); |
| } |
| else { |
| drawTexturedModalRect(guiWidth + 131, guiHeight + 47, 176 + 4 + 28, 14, 14, 14); |
| } |
| |
| if(xAxis >= 131 && xAxis <= 145 && yAxis >= 63 && yAxis <= 77) |
| { |
| drawTexturedModalRect(guiWidth + 131, guiHeight + 63, 176 + 4 + 42, 0, 14, 14); |
| } |
| else { |
| drawTexturedModalRect(guiWidth + 131, guiHeight + 63, 176 + 4 + 42, 14, 14, 14); |
| } |
| |
| super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY); |
| } |
| |
| @Override |
| protected void mouseClicked(int mouseX, int mouseY, int button) |
| { |
| super.mouseClicked(mouseX, mouseY, button); |
| |
| if(button == 0) |
| { |
| int xAxis = (mouseX - (width - xSize) / 2); |
| int yAxis = (mouseY - (height - ySize) / 2); |
| |
| if(xAxis >= 147 && xAxis <= 161 && yAxis >= 47 && yAxis <= 61) |
| { |
| SoundHandler.playSound("gui.button.press"); |
| |
| ArrayList data = new ArrayList(); |
| data.add(Integer.valueOf(0)); |
| |
| Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); |
| } |
| |
| if(xAxis >= 147 && xAxis <= 161 && yAxis >= 63 && yAxis <= 77) |
| { |
| SoundHandler.playSound("gui.button.press"); |
| |
| ArrayList data = new ArrayList(); |
| data.add(Integer.valueOf(1)); |
| |
| Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); |
| } |
| |
| if(xAxis >= 131 && xAxis <= 145 && yAxis >= 47 && yAxis <= 61) |
| { |
| SoundHandler.playSound("gui.button.press"); |
| |
| ArrayList data = new ArrayList(); |
| data.add(Integer.valueOf(5)); |
| |
| Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); |
| } |
| |
| if(xAxis >= 131 && xAxis <= 145 && yAxis >= 63 && yAxis <= 77) |
| { |
| SoundHandler.playSound("gui.button.press"); |
| |
| ArrayList data = new ArrayList(); |
| data.add(Integer.valueOf(9)); |
| |
| Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data)); |
| } |
| } |
| } |
| } |