Assembly table now has a little ledger panel. Strings are updated.

This commit is contained in:
Christian 2012-10-13 15:57:32 -04:00
parent 4c05ccbde9
commit 30fe5841c1
3 changed files with 61 additions and 6 deletions

View file

@ -11,6 +11,8 @@ gui.energy=Energy
gui.currentOutput=Current Output
gui.stored=Stored
gui.heat=Heat
gui.assemblyRate=Energy Rate
gui.assemblyCurrentRequired=Energy Required
item.bucketFuel=Fuel Bucket
item.bucketOil=Oil Bucket
item.woodenGearItem=Wood Gear

View file

@ -82,6 +82,10 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor
@Override
public void updateEntity() {
tick++;
tick = tick % recentEnergy.length;
recentEnergy[tick] = 0.0f;
if (currentRecipe == null)
return;
@ -92,8 +96,6 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor
return;
}
tick = ++tick % recentEnergy.length;
recentEnergy[tick] = 0.0f;
if (energyStored >= currentRecipe.energy) {
energyStored = 0;
@ -428,7 +430,7 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor
int lRecentEnergy = 0;
for (int i = 0; i < recentEnergy.length; i++)
{
lRecentEnergy += (int)(recentEnergy[i] * 100.0 / recentEnergy.length);
lRecentEnergy += (int)(recentEnergy[i] * 100.0 / (float)(recentEnergy.length - 1));
}
iCrafting.updateCraftingInventoryInfo(container, 0, requiredEnergy & 0xFFFF);
iCrafting.updateCraftingInventoryInfo(container, 1, currentStored & 0xFFFF);
@ -462,4 +464,12 @@ public class TileAssemblyTable extends TileEntity implements IMachine, IInventor
return recentEnergyAverage;
}
public float getStoredEnergy() {
return energyStored;
}
public float getRequiredEnergy() {
return currentRequiredEnergy;
}
}

View file

@ -26,6 +26,7 @@ import buildcraft.core.network.PacketPayload;
import buildcraft.core.network.PacketUpdate;
import buildcraft.core.proxy.CoreProxy;
import buildcraft.core.utils.StringUtil;
import buildcraft.energy.TileEngine;
import buildcraft.factory.TileAssemblyTable;
import buildcraft.factory.TileAssemblyTable.SelectionMessage;
@ -33,6 +34,44 @@ public class GuiAssemblyTable extends GuiAdvancedInterface {
TileAssemblyTable assemblyTable;
class AssemblyLedger extends Ledger
{
int headerColour = 0xe1c92f;
int subheaderColour = 0xaaafb8;
int textColour = 0x000000;
public AssemblyLedger() {
maxHeight = 94;
overlayColor = 0xd46c1f;
}
@Override
public void draw(int x, int y) {
// Draw background
drawBackground(x, y);
// Draw icon
drawIcon(DefaultProps.TEXTURE_ICONS, 0, x + 3, y + 4);
if (!isFullyOpened())
return;
fontRenderer.drawStringWithShadow(StringUtil.localize("gui.energy"), x + 22, y + 8, headerColour);
fontRenderer.drawStringWithShadow(StringUtil.localize("gui.assemblyCurrentRequired") + ":", x + 22, y + 20, subheaderColour);
fontRenderer.drawString(String.format("%2.1f MJ", assemblyTable.getRequiredEnergy()), x + 22, y + 32, textColour);
fontRenderer.drawStringWithShadow(StringUtil.localize("gui.stored") + ":", x + 22, y + 44, subheaderColour);
fontRenderer.drawString(String.format("%2.1f MJ", assemblyTable.getStoredEnergy()), x + 22, y + 56, textColour);
fontRenderer.drawStringWithShadow(StringUtil.localize("gui.assemblyRate") + ":", x + 22, y + 68, subheaderColour);
fontRenderer.drawString(String.format("%3.2f MJ/t",assemblyTable.getRecentEnergyAverage() / 100.0f), x + 22, y + 80, textColour);
}
@Override
public String getTooltip() {
return String.format("%3.2f MJ/t",assemblyTable.getRecentEnergyAverage() / 100.0f);
}
}
class RecipeSlot extends AdvancedSlot {
public AssemblyRecipe recipe;
@ -88,12 +127,10 @@ public class GuiAssemblyTable extends GuiAdvancedInterface {
@Override
protected void drawGuiContainerForegroundLayer() {
super.drawGuiContainerForegroundLayer();
String title = StringUtil.localize("tile.assemblyTableBlock");
fontRenderer.drawString(title, getCenteredOffset(title), 15, 0x404040);
fontRenderer.drawString(StringUtil.localize("gui.inventory"), 8, ySize - 97, 0x404040);
String recentEnergy = String.format("%2.2f MJ/tick",assemblyTable.getRecentEnergyAverage() / 100.0f);
fontRenderer.drawString(recentEnergy, xSize - fontRenderer.getStringWidth(recentEnergy) - 8, ySize - 97, 0x404040);
drawForegroundSelection();
}
@ -168,4 +205,10 @@ public class GuiAssemblyTable extends GuiAdvancedInterface {
}
}
@Override
protected void initLedgers(IInventory inventory) {
super.initLedgers(inventory);
ledgerManager.add(new AssemblyLedger());
}
}