Added fancy graphs to display boil rate and max boil value of boilers, boiler valves now connect to corresponding tanks of multiblock based on location
This commit is contained in:
parent
382116b659
commit
cfb0986a48
9 changed files with 267 additions and 20 deletions
|
@ -9,6 +9,8 @@ import mekanism.api.util.UnitDisplayUtils.TemperatureUnit;
|
|||
import mekanism.client.gui.element.GuiBoilerTab;
|
||||
import mekanism.client.gui.element.GuiBoilerTab.BoilerTab;
|
||||
import mekanism.client.gui.element.GuiElement.IInfoHandler;
|
||||
import mekanism.client.gui.element.GuiGraph;
|
||||
import mekanism.client.gui.element.GuiGraph.GraphDataHandler;
|
||||
import mekanism.client.gui.element.GuiHeatInfo;
|
||||
import mekanism.common.content.boiler.BoilerUpdateProtocol;
|
||||
import mekanism.common.content.boiler.SynchronizedBoilerData;
|
||||
|
@ -28,12 +30,15 @@ import cpw.mods.fml.relauncher.SideOnly;
|
|||
public class GuiBoilerStats extends GuiMekanism
|
||||
{
|
||||
public TileEntityBoilerCasing tileEntity;
|
||||
|
||||
public GuiGraph boilGraph;
|
||||
public GuiGraph maxGraph;
|
||||
|
||||
public GuiBoilerStats(InventoryPlayer inventory, TileEntityBoilerCasing tentity)
|
||||
{
|
||||
super(tentity, new ContainerNull(inventory.player, tentity));
|
||||
tileEntity = tentity;
|
||||
guiElements.add(new GuiBoilerTab(this, tileEntity, BoilerTab.MAIN, 6, MekanismUtils.getResource(ResourceType.GUI, "GuiNull.png")));
|
||||
guiElements.add(new GuiBoilerTab(this, tileEntity, BoilerTab.MAIN, 6, MekanismUtils.getResource(ResourceType.GUI, "GuiBoilerStats.png")));
|
||||
guiElements.add(new GuiHeatInfo(new IInfoHandler() {
|
||||
@Override
|
||||
public List<String> getInfo()
|
||||
|
@ -41,7 +46,22 @@ public class GuiBoilerStats extends GuiMekanism
|
|||
String loss = UnitDisplayUtils.getDisplayShort(tileEntity.structure.lastEnvironmentLoss, TemperatureUnit.KELVIN);
|
||||
return ListUtils.asList(LangUtils.localize("gui.dissipated") + ": " + loss + "/t");
|
||||
}
|
||||
}, this, MekanismUtils.getResource(ResourceType.GUI, "GuiNull.png")));
|
||||
}, this, MekanismUtils.getResource(ResourceType.GUI, "GuiBoilerStats.png")));
|
||||
guiElements.add(boilGraph = new GuiGraph(this, MekanismUtils.getResource(ResourceType.GUI, "GuiBoilerStats.png"), 8, 83, 160, 36, new GraphDataHandler() {
|
||||
@Override
|
||||
public String getDataDisplay(int data)
|
||||
{
|
||||
return LangUtils.localize("gui.boilRate") + ": " + data + " mB/t";
|
||||
}
|
||||
}));
|
||||
guiElements.add(maxGraph = new GuiGraph(this, MekanismUtils.getResource(ResourceType.GUI, "GuiBoilerStats.png"), 8, 122, 160, 36, new GraphDataHandler() {
|
||||
@Override
|
||||
public String getDataDisplay(int data)
|
||||
{
|
||||
return LangUtils.localize("gui.maxBoil") + ": " + data + " mB/t";
|
||||
}
|
||||
}));
|
||||
maxGraph.enableFixedScale((int)((tentity.structure.superheatingElements*general.superheatingHeatTransfer)/SynchronizedBoilerData.getHeatEnthalpy()));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -54,8 +74,8 @@ public class GuiBoilerStats extends GuiMekanism
|
|||
|
||||
fontRendererObj.drawString(stats, (xSize/2)-(fontRendererObj.getStringWidth(stats)/2), 6, 0x404040);
|
||||
|
||||
fontRendererObj.drawString(LangUtils.localize("gui.maxWater") + ": " + tileEntity.structure.waterVolume*BoilerUpdateProtocol.WATER_PER_TANK, 8, 26, 0x404040);
|
||||
fontRendererObj.drawString(LangUtils.localize("gui.maxSteam") + ": " + tileEntity.structure.steamVolume*BoilerUpdateProtocol.STEAM_PER_TANK, 8, 35, 0x404040);
|
||||
fontRendererObj.drawString(LangUtils.localize("gui.maxWater") + ": " + tileEntity.clientWaterCapacity + " mB", 8, 26, 0x404040);
|
||||
fontRendererObj.drawString(LangUtils.localize("gui.maxSteam") + ": " + tileEntity.clientSteamCapacity + " mB", 8, 35, 0x404040);
|
||||
|
||||
fontRendererObj.drawString(LangUtils.localize("gui.heatTransfer"), 8, 49, 0x797979);
|
||||
fontRendererObj.drawString(LangUtils.localize("gui.superheaters") + ": " + tileEntity.structure.superheatingElements, 14, 58, 0x404040);
|
||||
|
@ -66,10 +86,19 @@ public class GuiBoilerStats extends GuiMekanism
|
|||
super.drawGuiContainerForegroundLayer(mouseX, mouseY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateScreen()
|
||||
{
|
||||
super.updateScreen();
|
||||
|
||||
boilGraph.addData(tileEntity.structure.lastBoilRate);
|
||||
maxGraph.addData(tileEntity.structure.lastMaxBoil);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float partialTick, int mouseX, int mouseY)
|
||||
{
|
||||
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiNull.png"));
|
||||
mc.renderEngine.bindTexture(MekanismUtils.getResource(ResourceType.GUI, "GuiBoilerStats.png"));
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
int guiWidth = (width - xSize) / 2;
|
||||
int guiHeight = (height - ySize) / 2;
|
||||
|
|
152
src/main/java/mekanism/client/gui/element/GuiGraph.java
Normal file
152
src/main/java/mekanism/client/gui/element/GuiGraph.java
Normal file
|
@ -0,0 +1,152 @@
|
|||
package mekanism.client.gui.element;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import mekanism.client.gui.IGuiWrapper;
|
||||
import mekanism.client.render.MekanismRenderer;
|
||||
import mekanism.common.util.MekanismUtils;
|
||||
import mekanism.common.util.MekanismUtils.ResourceType;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import codechicken.lib.vec.Rectangle4i;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiGraph extends GuiElement
|
||||
{
|
||||
public int xPosition;
|
||||
public int yPosition;
|
||||
|
||||
public int xSize;
|
||||
public int ySize;
|
||||
|
||||
public int currentScale = 10;
|
||||
public boolean fixedScale = false;
|
||||
|
||||
public List<Integer> graphData = new ArrayList<Integer>();
|
||||
|
||||
public GraphDataHandler dataHandler;
|
||||
|
||||
public GuiGraph(IGuiWrapper gui, ResourceLocation def, int x, int y, int sizeX, int sizeY, GraphDataHandler handler)
|
||||
{
|
||||
super(MekanismUtils.getResource(ResourceType.GUI_ELEMENT, "GuiGraph.png"), gui, def);
|
||||
|
||||
xPosition = x;
|
||||
yPosition = y;
|
||||
|
||||
xSize = sizeX;
|
||||
ySize = sizeY;
|
||||
|
||||
dataHandler = handler;
|
||||
}
|
||||
|
||||
public void enableFixedScale(int scale)
|
||||
{
|
||||
fixedScale = true;
|
||||
currentScale = scale;
|
||||
}
|
||||
|
||||
public void addData(int data)
|
||||
{
|
||||
if(graphData.size() == xSize)
|
||||
{
|
||||
graphData.remove(0);
|
||||
}
|
||||
|
||||
graphData.add(data);
|
||||
|
||||
if(!fixedScale)
|
||||
{
|
||||
for(int i : graphData)
|
||||
{
|
||||
if(i > currentScale)
|
||||
{
|
||||
currentScale = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Rectangle4i getBounds(int guiWidth, int guiHeight)
|
||||
{
|
||||
return new Rectangle4i(guiWidth + xPosition, guiHeight + yPosition, xSize, ySize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderBackground(int xAxis, int yAxis, int guiWidth, int guiHeight)
|
||||
{
|
||||
mc.renderEngine.bindTexture(RESOURCE);
|
||||
|
||||
drawBlack(guiWidth, guiHeight);
|
||||
drawGraph(guiWidth, guiHeight);
|
||||
|
||||
mc.renderEngine.bindTexture(defaultLocation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderForeground(int xAxis, int yAxis)
|
||||
{
|
||||
if(xAxis >= xPosition && xAxis <= xPosition+xSize && yAxis >= yPosition && yAxis <= yPosition+ySize)
|
||||
{
|
||||
int height = ySize-(yAxis-yPosition);
|
||||
int scaled = (int)(((double)height/(double)ySize)*currentScale);
|
||||
|
||||
displayTooltip(dataHandler.getDataDisplay(scaled), xAxis, yAxis);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preMouseClicked(int xAxis, int yAxis, int button) {}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(int xAxis, int yAxis, int button) {}
|
||||
|
||||
public void drawBlack(int guiWidth, int guiHeight)
|
||||
{
|
||||
int xDisplays = xSize/10 + (xSize%10 > 0 ? 1 : 0);
|
||||
int yDisplays = ySize/10 + (ySize%10 > 0 ? 1 : 0);
|
||||
|
||||
for(int yIter = 0; yIter < yDisplays; yIter++)
|
||||
{
|
||||
for(int xIter = 0; xIter < xDisplays; xIter++)
|
||||
{
|
||||
int width = (xSize%10 > 0 && xIter == xDisplays-1 ? xSize%10 : 10);
|
||||
int height = (ySize%10 > 0 && yIter == yDisplays-1 ? ySize%10 : 10);
|
||||
|
||||
guiObj.drawTexturedRect(guiWidth + xPosition + (xIter*10), guiHeight + yPosition + (yIter*10), 0, 0, width, height);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void drawGraph(int guiWidth, int guiHeight)
|
||||
{
|
||||
for(int i = 0; i < graphData.size(); i++)
|
||||
{
|
||||
int data = Math.min(currentScale, graphData.get(i));
|
||||
int relativeHeight = (int)(((double)data/(double)currentScale)*ySize);
|
||||
|
||||
guiObj.drawTexturedRect(guiWidth + xPosition + i, guiHeight + yPosition + (ySize-relativeHeight), 10, 0, 1, 1);
|
||||
|
||||
int displays = (relativeHeight-1)/10 + ((relativeHeight-1)%10 > 0 ? 1 : 0);
|
||||
|
||||
for(int iter = 0; iter < displays; iter++)
|
||||
{
|
||||
MekanismRenderer.blendOn();
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 0.2F + (0.8F*((float)i/(float)graphData.size())));
|
||||
int height = ((relativeHeight-1)%10 > 0 && iter == displays-1 ? (relativeHeight-1)%10 : 10);
|
||||
guiObj.drawTexturedRect(guiWidth + xPosition + i, guiHeight + yPosition + (ySize-(iter*10)) - 10 + (10-height), 11, 0, 1, height);
|
||||
MekanismRenderer.blendOff();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static interface GraphDataHandler
|
||||
{
|
||||
public String getDataDisplay(int data);
|
||||
}
|
||||
}
|
|
@ -100,7 +100,7 @@ public class GuiScrollList extends GuiElement
|
|||
{
|
||||
for(int xIter = 0; xIter < xDisplays; xIter++)
|
||||
{
|
||||
int width = (xSize%10 > 0 && xIter == xDisplays ? xSize%10 : 10);
|
||||
int width = (xSize%10 > 0 && xIter == xDisplays-1 ? xSize%10 : 10);
|
||||
guiObj.drawTexturedRect(guiWidth + xPosition + (xIter*10), guiHeight + yPosition + (yIter*10), 0, 0, width, 10);
|
||||
}
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ public class GuiScrollList extends GuiElement
|
|||
|
||||
for(int xIter = 0; xIter < xDisplays; xIter++)
|
||||
{
|
||||
int width = (xSize%10 > 0 && xIter == xDisplays ? xSize%10 : 10);
|
||||
int width = (xSize%10 > 0 && xIter == xDisplays-1 ? xSize%10 : 10);
|
||||
guiObj.drawTexturedRect(guiWidth + xPosition + (xIter*10), guiHeight + yPosition + (index-scroll)*10, 0, 10, width, 10);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -143,6 +143,7 @@ public class BoilerUpdateProtocol extends UpdateProtocol<SynchronizedBoilerData>
|
|||
return false;
|
||||
}
|
||||
|
||||
//Gradle build requires these fields to be final
|
||||
final Coord4D renderLocation = structure.renderLocation.clone();
|
||||
final int volLength = structure.volLength;
|
||||
final int volWidth = structure.volWidth;
|
||||
|
|
|
@ -235,10 +235,10 @@ public class TileEntityBoilerCasing extends TileEntityMultiblock<SynchronizedBoi
|
|||
data.add(0);
|
||||
}
|
||||
|
||||
structure.upperRenderLocation.write(data);
|
||||
|
||||
if(isRendering)
|
||||
{
|
||||
structure.upperRenderLocation.write(data);
|
||||
|
||||
Set<ValveData> toSend = new HashSet<ValveData>();
|
||||
|
||||
for(ValveData valveData : structure.valves)
|
||||
|
@ -293,11 +293,11 @@ public class TileEntityBoilerCasing extends TileEntityMultiblock<SynchronizedBoi
|
|||
else {
|
||||
structure.steamStored = null;
|
||||
}
|
||||
|
||||
structure.upperRenderLocation = Coord4D.read(dataStream);
|
||||
|
||||
if(isRendering)
|
||||
{
|
||||
structure.upperRenderLocation = Coord4D.read(dataStream);
|
||||
|
||||
int size = dataStream.readInt();
|
||||
|
||||
valveViewing.clear();
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package mekanism.common.tile;
|
||||
|
||||
import mekanism.api.Coord4D;
|
||||
import mekanism.common.content.boiler.BoilerSteamTank;
|
||||
import mekanism.common.content.boiler.BoilerTank;
|
||||
import mekanism.common.content.boiler.BoilerWaterTank;
|
||||
import mekanism.common.util.PipeUtils;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
@ -17,31 +19,84 @@ public class TileEntityBoilerValve extends TileEntityBoilerCasing implements IFl
|
|||
|
||||
public TileEntityBoilerValve()
|
||||
{
|
||||
super("Boiler Valve");
|
||||
super("BoilerValve");
|
||||
|
||||
waterTank = new BoilerWaterTank(this);
|
||||
steamTank = new BoilerSteamTank(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
super.onUpdate();
|
||||
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
if(structure != null && structure.upperRenderLocation != null && yCoord >= structure.upperRenderLocation.yCoord)
|
||||
{
|
||||
if(structure.steamStored != null && structure.steamStored.amount > 0)
|
||||
{
|
||||
for(ForgeDirection side : ForgeDirection.VALID_DIRECTIONS)
|
||||
{
|
||||
TileEntity tile = Coord4D.get(this).getFromSide(side).getTileEntity(worldObj);
|
||||
|
||||
if(tile instanceof IFluidHandler && !(tile instanceof TileEntityBoilerValve))
|
||||
{
|
||||
if(((IFluidHandler)tile).canFill(side.getOpposite(), structure.steamStored.getFluid()))
|
||||
{
|
||||
structure.steamStored.amount -= ((IFluidHandler)tile).fill(side.getOpposite(), structure.steamStored, true);
|
||||
|
||||
if(structure.steamStored.amount <= 0)
|
||||
{
|
||||
structure.steamStored = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidTankInfo[] getTankInfo(ForgeDirection from)
|
||||
{
|
||||
return ((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure)) ? new FluidTankInfo[] {waterTank.getInfo(), steamTank.getInfo()} : PipeUtils.EMPTY;
|
||||
if((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure))
|
||||
{
|
||||
if(structure.upperRenderLocation != null && yCoord >= structure.upperRenderLocation.yCoord)
|
||||
{
|
||||
return new FluidTankInfo[] {steamTank.getInfo()};
|
||||
}
|
||||
else {
|
||||
return new FluidTankInfo[] {waterTank.getInfo()};
|
||||
}
|
||||
}
|
||||
|
||||
return PipeUtils.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int fill(ForgeDirection from, FluidStack resource, boolean doFill)
|
||||
{
|
||||
return waterTank.fill(resource, doFill);
|
||||
if(structure != null && structure.upperRenderLocation != null && yCoord < structure.upperRenderLocation.yCoord)
|
||||
{
|
||||
return waterTank.fill(resource, doFill);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, FluidStack resource, boolean doDrain)
|
||||
{
|
||||
if(structure != null && structure.steamStored != null)
|
||||
if(structure != null && structure.upperRenderLocation != null && yCoord >= structure.upperRenderLocation.yCoord)
|
||||
{
|
||||
if(resource.getFluid() == structure.steamStored.getFluid())
|
||||
if(structure.steamStored != null)
|
||||
{
|
||||
return steamTank.drain(resource.amount, doDrain);
|
||||
if(resource.getFluid() == structure.steamStored.getFluid())
|
||||
{
|
||||
return steamTank.drain(resource.amount, doDrain);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -51,7 +106,7 @@ public class TileEntityBoilerValve extends TileEntityBoilerCasing implements IFl
|
|||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
|
||||
{
|
||||
if(structure != null)
|
||||
if(structure != null && structure.upperRenderLocation != null && yCoord >= structure.upperRenderLocation.yCoord)
|
||||
{
|
||||
return steamTank.drain(maxDrain, doDrain);
|
||||
}
|
||||
|
@ -62,12 +117,22 @@ public class TileEntityBoilerValve extends TileEntityBoilerCasing implements IFl
|
|||
@Override
|
||||
public boolean canFill(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return ((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure));
|
||||
if((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure))
|
||||
{
|
||||
return structure.upperRenderLocation != null && yCoord < structure.upperRenderLocation.yCoord;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(ForgeDirection from, Fluid fluid)
|
||||
{
|
||||
return ((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure));
|
||||
if((!worldObj.isRemote && structure != null) || (worldObj.isRemote && clientHasStructure))
|
||||
{
|
||||
return structure.upperRenderLocation != null && yCoord >= structure.upperRenderLocation.yCoord;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
BIN
src/main/resources/assets/mekanism/gui/GuiBoilerStats.png
Normal file
BIN
src/main/resources/assets/mekanism/gui/GuiBoilerStats.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3 KiB |
Binary file not shown.
Before Width: | Height: | Size: 3.3 KiB After Width: | Height: | Size: 3.3 KiB |
BIN
src/main/resources/assets/mekanism/gui/elements/GuiGraph.png
Normal file
BIN
src/main/resources/assets/mekanism/gui/elements/GuiGraph.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
Loading…
Reference in a new issue