Mekanism-tilera-Edition/common/mekanism/client/gui/GuiSalinationController.java

214 lines
5.9 KiB
Java
Raw Normal View History

package mekanism.client.gui;
2014-01-15 00:30:26 +01:00
import java.util.ArrayList;
2014-01-15 00:30:26 +01:00
import mekanism.api.Coord4D;
import mekanism.api.gas.GasStack;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.PacketHandler;
import mekanism.common.PacketHandler.Transmission;
import mekanism.common.inventory.container.ContainerSalinationController;
2014-01-15 00:30:26 +01:00
import mekanism.common.network.PacketTileEntity;
import mekanism.common.tile.TileEntitySalinationController;
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.entity.player.InventoryPlayer;
2014-01-15 00:30:26 +01:00
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
2014-03-16 01:05:26 +01:00
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiSalinationController extends GuiMekanism
{
public TileEntitySalinationController tileEntity;
public GuiSalinationController(InventoryPlayer inventory, TileEntitySalinationController tentity)
{
super(tentity, new ContainerSalinationController(inventory, tentity));
tileEntity = tentity;
}
2014-01-15 00:30:26 +01:00
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
2014-01-15 00:30:26 +01:00
int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2);
fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 4, 0x404040);
fontRenderer.drawString(getStruct(), 50, 21, 0x00CD00);
fontRenderer.drawString("Height: " + tileEntity.height, 50, 30, 0x00CD00);
fontRenderer.drawString("Mult: " + getTempMult(), 50, 39, 0x00CD00);
fontRenderer.drawString("Max: " + getMaxTemp(), 50, 48, 0x00CD00);
2014-01-15 00:30:26 +01:00
if(xAxis >= 7 && xAxis <= 23 && yAxis >= 14 && yAxis <= 72)
{
drawCreativeTabHoveringText(tileEntity.waterTank.getFluid() != null ? tileEntity.waterTank.getFluid().getFluid().getLocalizedName() + ": " + tileEntity.waterTank.getFluidAmount() : MekanismUtils.localize("gui.empty"), xAxis, yAxis);
}
2014-01-15 00:30:26 +01:00
if(xAxis >= 153 && xAxis <= 169 && yAxis >= 14 && yAxis <= 72)
{
drawCreativeTabHoveringText(tileEntity.brineTank.getFluid() != null ? tileEntity.brineTank.getFluid().getFluid().getLocalizedName() + ": " + tileEntity.brineTank.getFluidAmount() : MekanismUtils.localize("gui.empty"), xAxis, yAxis);
}
2014-01-15 00:30:26 +01:00
if(xAxis >= 49 && xAxis <= 127 && yAxis >= 64 && yAxis <= 72)
{
drawCreativeTabHoveringText(getTemp(), xAxis, yAxis);
}
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
private String getStruct()
{
if(tileEntity.structured)
{
return "Structured";
}
else if(!tileEntity.structured)
{
if(tileEntity.controllerConflict)
{
return "Conflict";
}
else {
return "Incomplete";
}
}
return null;
}
private String getTemp()
{
float temp = (float)Math.round((tileEntity.getTemperature()*200)*10)/10F;
return temp + " F";
}
private String getMaxTemp()
{
float temp = (float)Math.round((tileEntity.getMaxTemperature()*200)*10)/10F;
return temp + " F";
}
private String getTempMult()
{
float temp = (float)Math.round((tileEntity.getTempMultiplier())*10)/10F;
return temp + "x";
}
@Override
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
{
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiSalinationController.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 xAxis = mouseX - guiWidth;
2014-01-15 00:30:26 +01:00
int yAxis = mouseY - guiHeight;
int displayInt;
if(tileEntity.getScaledWaterLevel(58) > 0)
{
displayGauge(7, 14, tileEntity.getScaledWaterLevel(58), tileEntity.waterTank.getFluid(), null);
}
if(tileEntity.getScaledBrineLevel(58) > 0)
{
displayGauge(153, 14, tileEntity.getScaledBrineLevel(58), tileEntity.brineTank.getFluid(), null);
}
displayInt = tileEntity.getScaledTempLevel(78);
drawTexturedModalRect(guiWidth + 49, guiHeight + 64, 176, 59, displayInt, 8);
if(xAxis >= 48 && xAxis <= 128 && yAxis >= 5 && yAxis <= 17)
{
drawTexturedModalRect(guiWidth + 48, guiHeight + 5, 176, 79, 80, 12);
}
else {
drawTexturedModalRect(guiWidth + 48, guiHeight + 5, 176, 67, 80, 12);
}
}
@Override
protected void mouseClicked(int x, int y, int button)
{
2014-01-15 00:30:26 +01:00
super.mouseClicked(x, y, button);
2014-01-15 00:30:26 +01:00
if(button == 0)
{
int xAxis = (x - (width - xSize) / 2);
int yAxis = (y - (height - ySize) / 2);
if(xAxis >= 48 && xAxis <= 128 && yAxis >= 5 && yAxis <= 17)
2014-01-15 00:30:26 +01:00
{
ArrayList data = new ArrayList();
data.add(0);
2014-01-15 00:30:26 +01:00
PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Coord4D.get(tileEntity), data));
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
}
}
}
2014-01-15 00:30:26 +01:00
public void displayGauge(int xPos, int yPos, int scale, FluidStack fluid, GasStack gas)
{
if(fluid == null && gas == null)
{
return;
}
int guiWidth = (width - xSize) / 2;
int guiHeight = (height - ySize) / 2;
2014-01-15 00:30:26 +01:00
int start = 0;
2014-01-15 00:30:26 +01:00
while(true)
{
int renderRemaining = 0;
if(scale > 16)
2014-01-15 00:30:26 +01:00
{
renderRemaining = 16;
scale -= 16;
}
2014-01-15 00:30:26 +01:00
else {
renderRemaining = scale;
scale = 0;
}
mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture());
2014-01-15 00:30:26 +01:00
if(fluid != null)
{
drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, fluid.getFluid().getIcon(), 16, 16 - (16 - renderRemaining));
}
else if(gas != null)
{
drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, gas.getGas().getIcon(), 16, 16 - (16 - renderRemaining));
}
2014-01-15 00:30:26 +01:00
start+=16;
2014-01-15 00:30:26 +01:00
if(renderRemaining == 0 || scale == 0)
{
break;
}
}
2014-01-15 00:30:26 +01:00
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiSalinationController.png"));
drawTexturedModalRect(guiWidth + xPos, guiHeight + yPos, 176, 0, 16, 59);
}
}