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

174 lines
5.4 KiB
Java
Raw Normal View History

2013-11-28 05:42:54 +01:00
package mekanism.client.gui;
import java.util.ArrayList;
import mekanism.api.Object3D;
2013-11-28 05:42:54 +01:00
import mekanism.api.gas.GasStack;
import mekanism.client.render.MekanismRenderer;
import mekanism.common.PacketHandler;
import mekanism.common.PacketHandler.Transmission;
2013-11-28 05:42:54 +01:00
import mekanism.common.inventory.container.ContainerRotaryCondensentrator;
import mekanism.common.network.PacketTileEntity;
2013-11-28 05:42:54 +01:00
import mekanism.common.tileentity.TileEntityRotaryCondensentrator;
import mekanism.common.util.ListUtils;
2013-11-28 05:42:54 +01:00
import mekanism.common.util.MekanismUtils;
import mekanism.common.util.MekanismUtils.ResourceType;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class GuiRotaryCondensentrator extends GuiMekanism
{
public TileEntityRotaryCondensentrator tileEntity;
private int guiWidth;
private int guiHeight;
public GuiRotaryCondensentrator(InventoryPlayer inventory, TileEntityRotaryCondensentrator tentity)
{
super(new ContainerRotaryCondensentrator(inventory, tentity));
tileEntity = tentity;
}
@Override
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
{
int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2);
fontRenderer.drawString("Rotary Condensentrator", 26, 4, 0x404040);
fontRenderer.drawString(tileEntity.mode == 0 ? "Condensentrating" : "Decondensentrating", 6, (ySize - 94) + 2, 0x404040);
2013-11-28 05:42:54 +01:00
if(xAxis >= 26 && xAxis <= 42 && yAxis >= 14 && yAxis <= 72)
{
drawCreativeTabHoveringText(tileEntity.gasTank != null ? tileEntity.gasTank.getGas().getLocalizedName() + ": " + tileEntity.gasTank.amount : "Empty", xAxis, yAxis);
}
if(xAxis >= 134 && xAxis <= 150 && yAxis >= 14 && yAxis <= 72)
2013-11-28 05:42:54 +01:00
{
drawCreativeTabHoveringText(tileEntity.fluidTank.getFluid() != null ? tileEntity.fluidTank.getFluid().getFluid().getLocalizedName() + ": " + tileEntity.fluidTank.getFluid().amount + "mB" : "Empty", xAxis, yAxis);
}
if(xAxis >= 116 && xAxis <= 168 && yAxis >= 76 && yAxis <= 80)
{
drawCreativeTabHoveringText(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), xAxis, yAxis);
}
if(xAxis >= 4 && xAxis <= 22 && yAxis >= 4 && yAxis <= 22)
{
drawCreativeTabHoveringText("Toggle operation", xAxis, yAxis);
}
2013-11-28 05:42:54 +01:00
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
}
@Override
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
{
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png"));
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
guiWidth = (width - xSize) / 2;
guiHeight = (height - ySize) / 2;
drawTexturedModalRect(guiWidth, guiHeight, 0, 0, xSize, ySize);
int displayInt;
int xAxis = (mouseX - (width - xSize) / 2);
int yAxis = (mouseY - (height - ySize) / 2);
2013-11-28 05:42:54 +01:00
displayInt = tileEntity.getScaledEnergyLevel(52);
drawTexturedModalRect(guiWidth + 116, guiHeight + 76, 176, 36, displayInt, 4);
if(tileEntity.getScaledGasLevel(58) > 0)
2013-11-28 05:42:54 +01:00
{
displayGauge(26, 14, tileEntity.getScaledGasLevel(58), null, tileEntity.gasTank);
2013-11-28 05:42:54 +01:00
}
if(tileEntity.getScaledFluidLevel(58) > 0)
2013-11-28 05:42:54 +01:00
{
displayGauge(134, 14, tileEntity.getScaledFluidLevel(58), tileEntity.fluidTank.getFluid(), null);
2013-11-28 05:42:54 +01:00
}
if(xAxis >= 4 && xAxis <= 22 && yAxis >= 4 && yAxis <= 22)
{
drawTexturedModalRect(guiWidth + 4, guiHeight + 4, 176, 0, 18, 18);
}
else {
drawTexturedModalRect(guiWidth + 4, guiHeight + 4, 176, 18, 18, 18);
}
2013-11-28 05:42:54 +01:00
}
@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 >= 4 && xAxis <= 22 && yAxis >= 4 && yAxis <= 22)
{
ArrayList data = new ArrayList();
data.add(0);
PacketHandler.sendPacket(Transmission.SERVER, new PacketTileEntity().setParams(Object3D.get(tileEntity), data));
mc.sndManager.playSoundFX("random.click", 1.0F, 1.0F);
}
}
}
2013-11-28 05:42:54 +01:00
public void displayGauge(int xPos, int yPos, int scale, FluidStack fluid, GasStack gas)
{
if(fluid == null)
{
return;
}
int start = 0;
while(true)
{
int renderRemaining = 0;
if(scale > 16)
{
renderRemaining = 16;
scale -= 16;
}
else {
renderRemaining = scale;
scale = 0;
}
mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture());
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));
}
start+=16;
if(renderRemaining == 0 || scale == 0)
{
break;
}
}
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiRotaryCondensentrator.png"));
drawTexturedModalRect(guiWidth + xPos, guiHeight + yPos, 176, 40, 16, 60);
}
}