2014-01-03 03:09:21 +01:00
|
|
|
package mekanism.client.gui;
|
2012-10-28 23:18:23 +01:00
|
|
|
|
2014-01-10 23:42:53 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
|
2014-01-03 01:24:22 +01:00
|
|
|
import mekanism.api.Coord4D;
|
2014-01-10 23:42:53 +01:00
|
|
|
import mekanism.api.ListUtils;
|
2014-01-03 05:34:52 +01:00
|
|
|
import mekanism.api.gas.GasStack;
|
2014-01-10 23:42:53 +01:00
|
|
|
import mekanism.client.gui.GuiEnergyInfo.IInfoHandler;
|
2014-01-03 05:34:52 +01:00
|
|
|
import mekanism.client.render.MekanismRenderer;
|
2014-01-10 23:42:53 +01:00
|
|
|
import mekanism.common.Mekanism;
|
2014-01-03 01:24:22 +01:00
|
|
|
import mekanism.common.PacketHandler;
|
|
|
|
import mekanism.common.PacketHandler.Transmission;
|
2014-01-03 03:09:21 +01:00
|
|
|
import mekanism.common.inventory.container.ContainerElectrolyticSeparator;
|
2014-01-03 01:24:22 +01:00
|
|
|
import mekanism.common.network.PacketTileEntity;
|
2014-01-08 02:55:50 +01:00
|
|
|
import mekanism.common.tile.TileEntityElectrolyticSeparator;
|
2013-08-27 00:57:08 +02:00
|
|
|
import mekanism.common.util.MekanismUtils;
|
|
|
|
import mekanism.common.util.MekanismUtils.ResourceType;
|
2012-12-20 22:53:39 +01:00
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
2014-01-03 05:34:52 +01:00
|
|
|
import net.minecraftforge.fluids.FluidStack;
|
|
|
|
|
2012-12-20 22:53:39 +01:00
|
|
|
import org.lwjgl.opengl.GL11;
|
2012-10-28 23:18:23 +01:00
|
|
|
|
2014-01-10 23:42:53 +01:00
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
2014-01-03 01:24:22 +01:00
|
|
|
|
2013-04-13 16:33:37 +02:00
|
|
|
@SideOnly(Side.CLIENT)
|
2014-01-05 02:23:25 +01:00
|
|
|
public class GuiElectrolyticSeparator extends GuiMekanism
|
2012-10-28 23:18:23 +01:00
|
|
|
{
|
2012-11-15 21:04:12 +01:00
|
|
|
public TileEntityElectrolyticSeparator tileEntity;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2012-11-15 21:04:12 +01:00
|
|
|
public GuiElectrolyticSeparator(InventoryPlayer inventory, TileEntityElectrolyticSeparator tentity)
|
2014-03-08 02:00:25 +01:00
|
|
|
{
|
|
|
|
super(new ContainerElectrolyticSeparator(inventory, tentity));
|
|
|
|
|
|
|
|
guiElements.add(new GuiEnergyInfo(new IInfoHandler() {
|
|
|
|
@Override
|
|
|
|
public List<String> getInfo()
|
|
|
|
{
|
2014-04-04 02:01:54 +02:00
|
|
|
String multiplier = MekanismUtils.getEnergyDisplay(Mekanism.FROM_H2*2);
|
2014-03-08 02:00:25 +01:00
|
|
|
return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy()));
|
|
|
|
}
|
|
|
|
}, this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png")));
|
|
|
|
|
|
|
|
tileEntity = tentity;
|
|
|
|
}
|
|
|
|
|
2012-11-23 03:22:11 +01:00
|
|
|
@Override
|
2014-03-08 02:00:25 +01:00
|
|
|
protected void mouseClicked(int x, int y, int button)
|
|
|
|
{
|
2012-12-19 21:23:55 +01:00
|
|
|
super.mouseClicked(x, y, button);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2012-12-19 21:23:55 +01:00
|
|
|
int xAxis = (x - (width - xSize) / 2);
|
|
|
|
int yAxis = (y - (height - ySize) / 2);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-03 01:24:22 +01:00
|
|
|
if(xAxis > 8 && xAxis < 17 && yAxis > 73 && yAxis < 82)
|
2012-11-23 03:22:11 +01:00
|
|
|
{
|
2013-02-27 02:21:30 +01:00
|
|
|
ArrayList data = new ArrayList();
|
|
|
|
data.add((byte)0);
|
2014-01-03 01:24:22 +01:00
|
|
|
|
2013-12-20 22:09:09 +01:00
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data));
|
2013-01-12 15:52:41 +01:00
|
|
|
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
2014-01-03 01:24:22 +01:00
|
|
|
|
2013-01-12 15:52:41 +01:00
|
|
|
}
|
2014-01-03 01:24:22 +01:00
|
|
|
else if(xAxis > 160 && xAxis < 169 && yAxis > 73 && yAxis < 82)
|
2013-01-12 15:52:41 +01:00
|
|
|
{
|
2013-02-27 02:21:30 +01:00
|
|
|
ArrayList data = new ArrayList();
|
|
|
|
data.add((byte)1);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-12-20 22:09:09 +01:00
|
|
|
PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data));
|
2012-12-19 21:23:55 +01:00
|
|
|
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
|
2014-01-03 01:24:22 +01:00
|
|
|
|
2012-11-23 03:22:11 +01:00
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
}
|
2012-10-28 23:18:23 +01:00
|
|
|
|
2012-11-06 16:44:14 +01:00
|
|
|
@Override
|
2013-05-20 00:43:01 +02:00
|
|
|
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
2014-03-08 02:00:25 +01:00
|
|
|
{
|
2013-05-20 00:43:01 +02:00
|
|
|
int xAxis = (mouseX - (width - xSize) / 2);
|
|
|
|
int yAxis = (mouseY - (height - ySize) / 2);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
|
|
|
fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040);
|
|
|
|
|
2014-01-03 06:43:55 +01:00
|
|
|
String name = tileEntity.dumpLeft ? "Dumping..." : tileEntity.leftTank.getGas() == null ? MekanismUtils.localize("gui.none") : tileEntity.leftTank.getGas().getGas().getLocalizedName();
|
2014-03-08 02:00:25 +01:00
|
|
|
fontRenderer.drawString(name, 21, 73, 0x404040);
|
|
|
|
|
2014-01-03 06:43:55 +01:00
|
|
|
name = tileEntity.dumpRight ? "Dumping..." : tileEntity.rightTank.getGas() == null ? MekanismUtils.localize("gui.none") : tileEntity.rightTank.getGas().getGas().getLocalizedName();
|
2014-03-08 02:00:25 +01:00
|
|
|
fontRenderer.drawString(name, 156-fontRenderer.getStringWidth(name), 73, 0x404040);
|
2014-01-03 01:24:22 +01:00
|
|
|
|
2014-01-03 05:34:52 +01:00
|
|
|
if(xAxis >= 6 && xAxis <= 22 && yAxis >= 11 && yAxis <= 69)
|
2014-01-03 01:24:22 +01:00
|
|
|
{
|
|
|
|
drawCreativeTabHoveringText(tileEntity.fluidTank.getFluid() != null ? tileEntity.fluidTank.getFluid().getFluid().getLocalizedName() + ": " + tileEntity.fluidTank.getFluidAmount() + "mB" : MekanismUtils.localize("gui.empty"), xAxis, yAxis);
|
|
|
|
}
|
2014-01-03 05:34:52 +01:00
|
|
|
if(xAxis >= 59 && xAxis <= 75 && yAxis >= 19 && yAxis <= 47)
|
2014-01-03 01:24:22 +01:00
|
|
|
{
|
|
|
|
drawCreativeTabHoveringText(tileEntity.leftTank.getGas() != null ? tileEntity.leftTank.getGas().getGas().getLocalizedName() + ": " + tileEntity.leftTank.getStored() : MekanismUtils.localize("gui.empty"), xAxis, yAxis);
|
|
|
|
}
|
2014-01-03 05:34:52 +01:00
|
|
|
if(xAxis >= 101 && xAxis <= 117 && yAxis >= 19 && yAxis <= 47)
|
2014-01-03 01:24:22 +01:00
|
|
|
{
|
|
|
|
drawCreativeTabHoveringText(tileEntity.rightTank.getGas() != null ? tileEntity.rightTank.getGas().getGas().getLocalizedName() + ": " + tileEntity.rightTank.getStored() : MekanismUtils.localize("gui.empty"), xAxis, yAxis);
|
|
|
|
}
|
|
|
|
if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69)
|
2013-05-20 00:43:01 +02:00
|
|
|
{
|
2013-11-23 02:58:49 +01:00
|
|
|
drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis);
|
2013-05-20 00:43:01 +02:00
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-10 23:42:53 +01:00
|
|
|
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
2014-03-08 02:00:25 +01:00
|
|
|
}
|
2012-10-28 23:18:23 +01:00
|
|
|
|
2012-11-06 16:44:14 +01:00
|
|
|
@Override
|
2014-03-08 02:00:25 +01:00
|
|
|
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
|
|
|
|
{
|
2014-01-10 23:42:53 +01:00
|
|
|
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-09-28 03:59:47 +02:00
|
|
|
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"));
|
2014-03-08 02:00:25 +01:00
|
|
|
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
|
|
|
int guiWidth = (width - xSize) / 2;
|
|
|
|
int guiHeight = (height - ySize) / 2;
|
|
|
|
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
|
|
|
|
|
|
|
|
int displayInt = tileEntity.dumpLeft ? 60 : 52;
|
|
|
|
drawTexturedModalRect(guiWidth + 8, guiHeight + 73, 176, displayInt, 8, 8);
|
|
|
|
|
|
|
|
displayInt = tileEntity.dumpRight ? 60 : 52;
|
|
|
|
drawTexturedModalRect(guiWidth + 160, guiHeight + 73, 176, displayInt, 8, 8);
|
|
|
|
|
|
|
|
if(tileEntity.fluidTank.getFluid() != null)
|
|
|
|
{
|
|
|
|
displayGauge(58, 6, 11, tileEntity.getScaledFluidLevel(58), tileEntity.fluidTank.getFluid(), null);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(tileEntity.leftTank.getGas() != null)
|
|
|
|
{
|
|
|
|
displayGauge(28, 59, 19, tileEntity.getLeftScaledLevel(28), null, tileEntity.leftTank.getGas());
|
|
|
|
}
|
|
|
|
|
|
|
|
if(tileEntity.rightTank.getGas() != null)
|
|
|
|
{
|
|
|
|
displayGauge(28, 101, 19, tileEntity.getRightScaledLevel(28), null, tileEntity.rightTank.getGas());
|
|
|
|
}
|
|
|
|
|
|
|
|
displayInt = tileEntity.getScaledEnergyLevel(52);
|
|
|
|
drawTexturedModalRect(guiWidth + 165, guiHeight + 17 + 52 - displayInt, 176, 52 - displayInt, 4, displayInt);
|
|
|
|
}
|
|
|
|
|
2014-01-03 05:34:52 +01:00
|
|
|
public void displayGauge(int length, int xPos, int yPos, int scale, FluidStack fluid, GasStack gas)
|
|
|
|
{
|
2014-03-08 02:00:25 +01:00
|
|
|
if(fluid == null && gas == null)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int guiWidth = (width - xSize) / 2;
|
|
|
|
int guiHeight = (height - ySize) / 2;
|
|
|
|
|
2014-01-03 05:34:52 +01:00
|
|
|
int start = 0;
|
|
|
|
|
|
|
|
while(true)
|
|
|
|
{
|
|
|
|
int renderRemaining = 0;
|
|
|
|
|
2014-03-08 02:00:25 +01:00
|
|
|
if(scale > 16)
|
2014-01-03 05:34:52 +01:00
|
|
|
{
|
|
|
|
renderRemaining = 16;
|
|
|
|
scale -= 16;
|
2014-03-08 02:00:25 +01:00
|
|
|
}
|
2014-01-03 05:34:52 +01:00
|
|
|
else {
|
|
|
|
renderRemaining = scale;
|
|
|
|
scale = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture());
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-03 05:34:52 +01:00
|
|
|
if(fluid != null)
|
|
|
|
{
|
|
|
|
drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + length - renderRemaining - start, fluid.getFluid().getIcon(), 16, 16 - (16 - renderRemaining));
|
|
|
|
}
|
|
|
|
else if(gas != null)
|
|
|
|
{
|
|
|
|
drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + length - renderRemaining - start, gas.getGas().getIcon(), 16, 16 - (16 - renderRemaining));
|
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-01-03 05:34:52 +01:00
|
|
|
start+=16;
|
|
|
|
|
|
|
|
if(renderRemaining == 0 || scale == 0)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiElectrolyticSeparator.png"));
|
|
|
|
drawTexturedModalRect(guiWidth + xPos, guiHeight + yPos, 176, 68, 16, length+1);
|
|
|
|
}
|
2012-10-28 23:18:23 +01:00
|
|
|
}
|