2013-08-27 00:49:32 +02:00
|
|
|
package mekanism.client.gui;
|
2013-04-28 21:23:08 +02:00
|
|
|
|
2013-08-27 00:57:08 +02:00
|
|
|
import mekanism.client.render.MekanismRenderer;
|
2013-08-27 00:49:32 +02:00
|
|
|
import mekanism.common.inventory.container.ContainerDynamicTank;
|
2014-01-08 02:55:50 +01:00
|
|
|
import mekanism.common.tank.TankUpdateProtocol;
|
|
|
|
import mekanism.common.tile.TileEntityDynamicTank;
|
2013-08-27 00:57:08 +02:00
|
|
|
import mekanism.common.util.MekanismUtils;
|
|
|
|
import mekanism.common.util.MekanismUtils.ResourceType;
|
2013-04-28 21:23:08 +02:00
|
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
2013-07-20 18:10:14 +02:00
|
|
|
import net.minecraftforge.fluids.FluidStack;
|
2013-04-28 21:23:08 +02:00
|
|
|
|
|
|
|
import org.lwjgl.opengl.GL11;
|
|
|
|
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
2013-11-27 02:11:26 +01:00
|
|
|
public class GuiDynamicTank extends GuiMekanism
|
2013-04-28 21:23:08 +02:00
|
|
|
{
|
|
|
|
public TileEntityDynamicTank tileEntity;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-04-28 21:23:08 +02:00
|
|
|
public GuiDynamicTank(InventoryPlayer inventory, TileEntityDynamicTank tentity)
|
2014-03-08 02:00:25 +01:00
|
|
|
{
|
|
|
|
super(new ContainerDynamicTank(inventory, tentity));
|
|
|
|
tileEntity = tentity;
|
|
|
|
}
|
|
|
|
|
2013-04-28 21:23:08 +02:00
|
|
|
@Override
|
|
|
|
protected void drawGuiContainerForegroundLayer(int mouseX, int mouseY)
|
2014-03-08 02:00:25 +01:00
|
|
|
{
|
2013-04-28 21:23:08 +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);
|
|
|
|
fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 94) + 2, 0x404040);
|
|
|
|
fontRenderer.drawString(MekanismUtils.localize("gui.volume") + ": " + tileEntity.clientCapacity/TankUpdateProtocol.FLUID_PER_TANK, 53, 26, 0x00CD00);
|
|
|
|
fontRenderer.drawString(tileEntity.structure.fluidStored != null ? tileEntity.structure.fluidStored.getFluid().getName() + ":" : MekanismUtils.localize("gui.noFluid"), 53, 44, 0x00CD00);
|
|
|
|
|
|
|
|
if(tileEntity.structure.fluidStored != null)
|
|
|
|
{
|
|
|
|
fontRenderer.drawString(tileEntity.structure.fluidStored.amount + "mB", 53, 53, 0x00CD00);
|
|
|
|
}
|
|
|
|
|
2013-04-28 21:23:08 +02:00
|
|
|
if(xAxis >= 7 && xAxis <= 39 && yAxis >= 14 && yAxis <= 72)
|
|
|
|
{
|
2013-11-30 06:28:02 +01:00
|
|
|
drawCreativeTabHoveringText(tileEntity.structure.fluidStored != null ? tileEntity.structure.fluidStored.getFluid().getLocalizedName() + ": " + tileEntity.structure.fluidStored.amount + "mB" : MekanismUtils.localize("gui.empty"), xAxis, yAxis);
|
2013-04-28 21:23:08 +02:00
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-11-27 02:11:26 +01:00
|
|
|
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
2014-03-08 02:00:25 +01:00
|
|
|
}
|
2013-04-28 21:23:08 +02:00
|
|
|
|
|
|
|
@Override
|
2014-03-08 02:00:25 +01:00
|
|
|
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
|
|
|
|
{
|
|
|
|
super.drawGuiContainerBackgroundLayer(partialTick, mouseX, mouseY);
|
|
|
|
|
2013-09-28 03:59:47 +02:00
|
|
|
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiDynamicTank.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);
|
|
|
|
|
|
|
|
if(tileEntity.getScaledFluidLevel(58) > 0)
|
|
|
|
{
|
2013-11-27 02:11:26 +01:00
|
|
|
displayGauge(7, 14, tileEntity.getScaledFluidLevel(58), tileEntity.structure.fluidStored, 0);
|
|
|
|
displayGauge(23, 14, tileEntity.getScaledFluidLevel(58), tileEntity.structure.fluidStored, 1);
|
2013-04-28 21:23:08 +02:00
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
}
|
|
|
|
|
2013-11-27 02:11:26 +01:00
|
|
|
public void displayGauge(int xPos, int yPos, int scale, FluidStack fluid, int side /*0-left, 1-right*/)
|
2013-04-28 21:23:08 +02:00
|
|
|
{
|
2014-03-08 02:00:25 +01:00
|
|
|
if(fluid == null)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int guiWidth = (width - xSize) / 2;
|
|
|
|
int guiHeight = (height - ySize) / 2;
|
|
|
|
|
2013-04-28 21:23:08 +02:00
|
|
|
int start = 0;
|
|
|
|
|
|
|
|
while(true)
|
|
|
|
{
|
|
|
|
int renderRemaining = 0;
|
|
|
|
|
2014-03-08 02:00:25 +01:00
|
|
|
if(scale > 16)
|
2013-04-28 21:23:08 +02:00
|
|
|
{
|
|
|
|
renderRemaining = 16;
|
|
|
|
scale -= 16;
|
2014-03-08 02:00:25 +01:00
|
|
|
}
|
2013-04-28 21:23:08 +02:00
|
|
|
else {
|
|
|
|
renderRemaining = scale;
|
|
|
|
scale = 0;
|
|
|
|
}
|
|
|
|
|
2013-11-24 19:12:42 +01:00
|
|
|
mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture());
|
2013-11-27 02:11:26 +01:00
|
|
|
drawTexturedModelRectFromIcon(guiWidth + xPos, guiHeight + yPos + 58 - renderRemaining - start, fluid.getFluid().getIcon(), 16, 16 - (16 - renderRemaining));
|
2013-04-28 21:23:08 +02:00
|
|
|
start+=16;
|
|
|
|
|
|
|
|
if(renderRemaining == 0 || scale == 0)
|
|
|
|
{
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-28 03:59:47 +02:00
|
|
|
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiDynamicTank.png"));
|
2013-11-27 02:11:26 +01:00
|
|
|
drawTexturedModalRect(guiWidth + xPos, guiHeight + yPos, 176, side == 0 ? 0 : 54, 16, 54);
|
2013-04-28 21:23:08 +02:00
|
|
|
}
|
|
|
|
}
|