More work on Gas gauge stuff

This commit is contained in:
Ben Spiers 2014-04-07 03:28:05 +01:00
parent 00388cb875
commit ffebfb0a9e
5 changed files with 37 additions and 18 deletions

View file

@ -23,6 +23,8 @@ public class Gas
private boolean visible = true; private boolean visible = true;
private boolean from_fluid = false;
/** /**
* Creates a new Gas object with a defined name or key value. * Creates a new Gas object with a defined name or key value.
* @param s - name or key to associate this Gas with * @param s - name or key to associate this Gas with
@ -40,6 +42,7 @@ public class Gas
unlocalizedName = name = f.getName(); unlocalizedName = name = f.getName();
icon = f.getStillIcon(); icon = f.getStillIcon();
fluid = f; fluid = f;
from_fluid = true;
} }
/** /**
@ -108,6 +111,10 @@ public class Gas
*/ */
public Icon getIcon() public Icon getIcon()
{ {
if(from_fluid)
{
return this.getFluid().getIcon();
}
return icon; return icon;
} }
@ -124,7 +131,7 @@ public class Gas
{ {
fluid.setIcons(getIcon()); fluid.setIcons(getIcon());
} }
from_fluid = false;
return this; return this;
} }

View file

@ -14,11 +14,10 @@ public class GuiGasGauge extends GuiElement
private int xLocation; private int xLocation;
private int yLocation; private int yLocation;
private int width = 6; private int width;
private int height = 56; private int height;
private int innerOffsetY = 2;
private Type gaugeType; private int number;
IGasInfoHandler infoHandler; IGasInfoHandler infoHandler;
@ -31,16 +30,22 @@ public class GuiGasGauge extends GuiElement
width = type.width; width = type.width;
height = type.height; height = type.height;
number = type.number;
infoHandler = handler; infoHandler = handler;
} }
@Override @Override
public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight) public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight)
{ {
int scale = getScaledGasLevel(height); mc.renderEngine.bindTexture(RESOURCE);
int scale = getScaledGasLevel(height-2);
int start = 0; int start = 0;
GasStack gas = infoHandler.getTank().getGas(); GasStack gas = infoHandler.getTank().getGas();
guiObj.drawTexturedModalRect(guiWidth + xLocation, guiHeight + yLocation, 0, 0, width, height);
while(true) while(true)
{ {
int renderRemaining = 0; int renderRemaining = 0;
@ -57,7 +62,10 @@ public class GuiGasGauge extends GuiElement
mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture()); mc.renderEngine.bindTexture(MekanismRenderer.getBlocksTexture());
guiObj.drawTexturedModelRectFromIcon(guiWidth + xLocation, guiHeight + yLocation + 58 - renderRemaining - start, gas.getGas().getIcon(), 16, 16 - (16 - renderRemaining)); for(int i = 0; i < number; i++)
{
guiObj.drawTexturedModelRectFromIcon(guiWidth + xLocation + 16*i + 1, guiHeight + yLocation + height - renderRemaining - start - 1, gas.getGas().getIcon(), 16, renderRemaining);
}
start+=16; start+=16;
@ -67,9 +75,10 @@ public class GuiGasGauge extends GuiElement
} }
} }
mc.renderEngine.bindTexture(defaultLocation); mc.renderEngine.bindTexture(RESOURCE);
guiObj.drawTexturedModalRect(guiWidth + xLocation, guiHeight + yLocation, 176, 40, 16, 59); guiObj.drawTexturedModalRect(guiWidth + xLocation, guiHeight + yLocation, width, 0, width, height);
mc.renderEngine.bindTexture(defaultLocation);
} }
@Override @Override
@ -102,17 +111,19 @@ public class GuiGasGauge extends GuiElement
public static enum Type public static enum Type
{ {
STANDARD(20, 58, "mekanism:gasGaugeStandard"), STANDARD(18, 60, 1, "GuiGaugeStandard.png"),
WIDE(100, 58, "mekanism:gasGaugeWide"); WIDE(66, 50, 4, "GuiGaugeWide.png");
public int width; public int width;
public int height; public int height;
public int number;
public String textureLocation; public String textureLocation;
private Type(int w, int h, String t) private Type(int w, int h, int n, String t)
{ {
width = w; width = w;
height = h; height = h;
number = n;
textureLocation = t; textureLocation = t;
} }
} }

View file

@ -10,6 +10,7 @@ import mekanism.client.gui.GuiGasGauge;
import mekanism.client.gui.GuiGasGauge.IGasInfoHandler; import mekanism.client.gui.GuiGasGauge.IGasInfoHandler;
import mekanism.client.gui.GuiGasGauge.Type; import mekanism.client.gui.GuiGasGauge.Type;
import mekanism.client.gui.GuiMekanism; import mekanism.client.gui.GuiMekanism;
import mekanism.client.gui.GuiPowerBar;
import mekanism.client.gui.GuiRedstoneControl; import mekanism.client.gui.GuiRedstoneControl;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.util.MekanismUtils; import mekanism.common.util.MekanismUtils;
@ -37,8 +38,10 @@ public class GuiHydrogenGenerator extends GuiMekanism
@Override @Override
public List<String> getInfo() public List<String> getInfo()
{ {
String production = MekanismUtils.getEnergyDisplay(tileEntity.generationRate); return ListUtils.asList(
return ListUtils.asList("Producing: " + production + "/t", "Storing: " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy())); "Producing: " + MekanismUtils.getEnergyDisplay(tileEntity.generationRate) + "/t",
"Storing: " + MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()),
"Max Output: " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()));
} }
}, this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiHydrogenGenerator.png"))); }, this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiHydrogenGenerator.png")));
guiElements.add(new GuiGasGauge(new IGasInfoHandler() { guiElements.add(new GuiGasGauge(new IGasInfoHandler() {
@ -47,7 +50,8 @@ public class GuiHydrogenGenerator extends GuiMekanism
{ {
return tileEntity.fuelTank; return tileEntity.fuelTank;
} }
}, Type.WIDE, this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiHydrogenGenerator.png"), 20, 20)); }, Type.WIDE, this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiHydrogenGenerator.png"), 55, 18));
guiElements.add(new GuiPowerBar(this, tileEntity, MekanismUtils.getResource(ResourceType.GUI, "GuiHydrogenGenerator.png"), 164, 15));
} }
@Override @Override
@ -60,9 +64,6 @@ public class GuiHydrogenGenerator extends GuiMekanism
fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040); fontRenderer.drawString(tileEntity.getInvName(), 45, 6, 0x404040);
fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040); fontRenderer.drawString(MekanismUtils.localize("container.inventory"), 8, (ySize - 96) + 2, 0x404040);
fontRenderer.drawString(MekanismUtils.getEnergyDisplay(tileEntity.getEnergy()), 51, 26, 0x00CD00);
fontRenderer.drawString("H: " + tileEntity.fuelTank.getStored(), 51, 35, 0x00CD00);
fontRenderer.drawString(MekanismUtils.localize("gui.out") + ": " + MekanismUtils.getEnergyDisplay(tileEntity.getMaxOutput()) + "/t", 51, 44, 0x00CD00);
if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69) if(xAxis >= 165 && xAxis <= 169 && yAxis >= 17 && yAxis <= 69)
{ {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.6 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 564 B