blob: f1e8ba2141977c01ef0a901ffe130a54aba74953 [file] [log] [blame] [raw]
package mekanism.client.gui;
import java.util.ArrayList;
import java.util.List;
import mekanism.api.Coord4D;
import mekanism.api.gas.GasTank;
import mekanism.api.util.ListUtils;
import mekanism.client.gui.GuiEnergyInfo.IInfoHandler;
import mekanism.client.gui.GuiGasGauge.IGasInfoHandler;
import mekanism.client.gui.GuiProgress.IProgressInfoHandler;
import mekanism.client.gui.GuiProgress.ProgressBar;
import mekanism.client.gui.GuiSlot.SlotOverlay;
import mekanism.client.gui.GuiSlot.SlotType;
import mekanism.client.sound.SoundHandler;
import mekanism.common.Mekanism;
import mekanism.common.inventory.container.ContainerChemicalInfuser;
import mekanism.common.network.PacketTileEntity.TileEntityMessage;
import mekanism.common.tile.TileEntityChemicalInfuser;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.entity.player.InventoryPlayer;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class GuiChemicalInfuser extends GuiMekanism
{
public TileEntityChemicalInfuser tileEntity;
public GuiChemicalInfuser(InventoryPlayer inventory, TileEntityChemicalInfuser tentity)
{
super(tentity, new ContainerChemicalInfuser(inventory, tentity));
tileEntity = tentity;
guiElements.add(new GuiRedstoneControl(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png")));
guiElements.add(new GuiUpgradeTab(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png")));
guiElements.add(new GuiEnergyInfo(new IInfoHandler() {
@Override
public List<String> getInfo()
{
double usage = 0;
if(tileEntity.getRecipe() != null)
{
usage = tileEntity.getUpgradedUsage(tileEntity.getRecipe())*tileEntity.BASE_ENERGY_USAGE;
}
String multiplier = MekanismUtils.getEnergyDisplay(usage);
return ListUtils.asList("Using: " + multiplier + "/t", "Needed: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxEnergy()-tileEntity.getEnergy()));
}
}, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png")));
guiElements.add(new GuiGasGauge(new IGasInfoHandler() {
@Override
public GasTank getTank()
{
return tileEntity.leftTank;
}
}, GuiGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"), 25, 13));
guiElements.add(new GuiGasGauge(new IGasInfoHandler() {
@Override
public GasTank getTank()
{
return tileEntity.centerTank;
}
}, GuiGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"), 79, 4));
guiElements.add(new GuiGasGauge(new IGasInfoHandler() {
@Override
public GasTank getTank()
{
return tileEntity.rightTank;
}
}, GuiGauge.Type.STANDARD, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"), 133, 13));
guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"), 154, 4).with(SlotOverlay.POWER));
guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"), 154, 55).with(SlotOverlay.MINUS));
guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"), 4, 55).with(SlotOverlay.MINUS));
guiElements.add(new GuiSlot(SlotType.NORMAL, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"), 79, 64).with(SlotOverlay.PLUS));
guiElements.add(new GuiProgress(new IProgressInfoHandler()
{
@Override
public double getProgress()
{
return tileEntity.isActive ? 1 : 0;
}
}, ProgressBar.SMALL_RIGHT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"), 45, 38));
guiElements.add(new GuiProgress(new IProgressInfoHandler()
{
@Override
public double getProgress()
{
return tileEntity.isActive ? 1 : 0;
}
}, ProgressBar.SMALL_LEFT, this, MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"), 99, 38));
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2);
fontRendererObj.drawString(MekanismUtils.localize("gui.chemicalInfuser.short"), 5, 5, 0x404040);
fontRendererObj.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 4, 0x404040);
if(xAxis >= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80)
{
drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis);
}
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
@Override
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
{
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiChemicalInfuser.png"));
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;
displayInt = tileEntity.getScaledEnergyLevel(52);
drawTexturedModalRect(guiWidth + 116, guiHeight + 76, 176, 0, displayInt, 4);
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
}
@Override
protected void mouseClicked(int x, int y, int button)
{
super.mouseClicked(x, y, button);
if(button == 0)
{
int xAxis = (x - (width - xSize) / 2);
int yAxis = (y - (height - ySize) / 2);
if(xAxis > 44 && xAxis < 62 && yAxis > 13 && yAxis < 21)
{
ArrayList data = new ArrayList();
data.add(0);
Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data));
SoundHandler.playSound("gui.button.press");
}
else if(xAxis > 114 && xAxis < 132 && yAxis > 13 && yAxis < 21)
{
ArrayList data = new ArrayList();
data.add(1);
Mekanism.packetHandler.sendToServer(new TileEntityMessage(Coord4D.get(tileEntity), data));
SoundHandler.playSound("gui.button.press");
}
}
}
}