mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-19 11:49:14 +00:00
Clean up Ledgers a bit
This commit is contained in:
1 parent
6dab61b0f9
commit
25b33b8db9
9 files changed
+152
-141
No files matched your search
@@ -23,10 +23,9 @@ public class ClimateLedger extends Ledger {
|
||||
private final IClimatised tile;
|
||||
|
||||
public ClimateLedger(LedgerManager manager, IClimatised tile) {
|
||||
super(manager);
|
||||
super(manager, "climate");
|
||||
this.tile = tile;
|
||||
maxHeight = 72;
|
||||
overlayColor = manager.gui.fontColor.get("ledger.climate.background");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -44,16 +43,13 @@ public class ClimateLedger extends Ledger {
|
||||
return;
|
||||
}
|
||||
|
||||
manager.minecraft.fontRenderer.drawStringWithShadow(StringUtil.localize("gui.climate"), x + 22, y + 8,
|
||||
manager.gui.fontColor.get("ledger.climate.header"));
|
||||
manager.minecraft.fontRenderer.drawStringWithShadow(StringUtil.localize("gui.temperature") + ":", x + 22, y + 20,
|
||||
manager.gui.fontColor.get("ledger.climate.subheader"));
|
||||
manager.minecraft.fontRenderer.drawString(AlleleManager.climateHelper.toDisplay(temperature) + " " + StringUtil.floatAsPercent(tile.getExactTemperature()), x + 22,
|
||||
y + 32, manager.gui.fontColor.get("ledger.climate.text"));
|
||||
manager.minecraft.fontRenderer.drawStringWithShadow(StringUtil.localize("gui.humidity") + ":", x + 22, y + 44,
|
||||
manager.gui.fontColor.get("ledger.climate.subheader"));
|
||||
manager.minecraft.fontRenderer.drawString(AlleleManager.climateHelper.toDisplay(tile.getHumidity()) + " " + StringUtil.floatAsPercent(tile.getExactHumidity()),
|
||||
x + 22, y + 56, manager.gui.fontColor.get("ledger.climate.text"));
|
||||
drawHeader(StringUtil.localize("gui.climate"), x + 22, y + 8);
|
||||
|
||||
drawSubheader(StringUtil.localize("gui.temperature") + ':', x + 22, y + 20);
|
||||
drawText(AlleleManager.climateHelper.toDisplay(temperature) + ' ' + StringUtil.floatAsPercent(tile.getExactTemperature()), x + 22, y + 32);
|
||||
|
||||
drawSubheader(StringUtil.localize("gui.humidity") + ':', x + 22, y + 44);
|
||||
drawText(AlleleManager.climateHelper.toDisplay(tile.getHumidity()) + ' ' + StringUtil.floatAsPercent(tile.getExactHumidity()), x + 22, y + 56);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,9 +26,8 @@ public class ErrorLedger extends Ledger {
|
||||
private IErrorState state;
|
||||
|
||||
public ErrorLedger(LedgerManager manager) {
|
||||
super(manager, false);
|
||||
super(manager, "error", false);
|
||||
maxHeight = 72;
|
||||
overlayColor = manager.gui.fontColor.get("ledger.error.background");
|
||||
}
|
||||
|
||||
public void setState(@Nullable IErrorState state) {
|
||||
@@ -37,7 +36,7 @@ public class ErrorLedger extends Ledger {
|
||||
String helpString = StringUtil.localize(state.getHelp());
|
||||
FontRenderer fontRenderer = manager.minecraft.fontRenderer;
|
||||
int lineCount = fontRenderer.listFormattedStringToWidth(helpString, maxWidth - 28).size();
|
||||
maxHeight = lineCount * (fontRenderer.FONT_HEIGHT + 2) + 20;
|
||||
maxHeight = (lineCount + 1) * fontRenderer.FONT_HEIGHT + 20;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,8 +46,6 @@ public class ErrorLedger extends Ledger {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Draw background
|
||||
drawBackground(x, y);
|
||||
|
||||
@@ -57,12 +54,10 @@ public class ErrorLedger extends Ledger {
|
||||
|
||||
// Write description if fully opened
|
||||
if (isFullyOpened()) {
|
||||
FontRenderer fontRenderer = manager.minecraft.fontRenderer;
|
||||
|
||||
fontRenderer.drawStringWithShadow(getTooltip(), x + 24, y + 8, manager.gui.fontColor.get("ledger.error.header"));
|
||||
drawHeader(getTooltip(), x + 24, y + 8);
|
||||
|
||||
String helpString = StringUtil.localize(state.getHelp());
|
||||
fontRenderer.drawSplitString(helpString, x + 24, y + 20, maxWidth - 28, manager.gui.fontColor.get("ledger.error.text"));
|
||||
drawSplitText(helpString, x + 24, y + 20, maxWidth - 28);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,19 +20,20 @@ import forestry.core.utils.StringUtil;
|
||||
|
||||
public class HintLedger extends Ledger {
|
||||
|
||||
private final int position;
|
||||
private final String[] hints;
|
||||
private final String hintString;
|
||||
private final String hintTooltip;
|
||||
|
||||
public HintLedger(LedgerManager manager, IHintSource tile) {
|
||||
super(manager);
|
||||
this.hints = tile.getHints();
|
||||
position = new Random().nextInt(hints.length);
|
||||
overlayColor = manager.gui.fontColor.get("ledger.hint.background");
|
||||
super(manager, "hint");
|
||||
String[] hints = tile.getHints();
|
||||
int position = new Random().nextInt(hints.length);
|
||||
|
||||
hintString = StringUtil.localize("hints." + hints[position] + ".desc");
|
||||
hintTooltip = StringUtil.localize("hints." + hints[position] + ".tag");
|
||||
|
||||
String helpString = StringUtil.localize("hints." + hints[position] + ".desc");
|
||||
FontRenderer fontRenderer = manager.minecraft.fontRenderer;
|
||||
int lineCount = fontRenderer.listFormattedStringToWidth(helpString, maxWidth - 28).size();
|
||||
maxHeight = lineCount * (fontRenderer.FONT_HEIGHT + 2) + 20;
|
||||
int lineCount = fontRenderer.listFormattedStringToWidth(hintString, maxWidth - 28).size();
|
||||
maxHeight = (lineCount + 1) * fontRenderer.FONT_HEIGHT + 20;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,16 +49,12 @@ public class HintLedger extends Ledger {
|
||||
return;
|
||||
}
|
||||
|
||||
manager.minecraft.fontRenderer.drawStringWithShadow(StringUtil.localize("gui.didyouknow") + '?', x + 22, y + 8,
|
||||
manager.gui.fontColor.get("ledger.hint.header"));
|
||||
manager.minecraft.fontRenderer.drawSplitString(StringUtil.localize("hints." + hints[position] + ".desc"), x + 22, y + 20, maxWidth - 28,
|
||||
manager.gui.fontColor.get("ledger.hint.text"));
|
||||
|
||||
drawHeader(StringUtil.localize("gui.didyouknow") + '?', x + 22, y + 8);
|
||||
drawSplitText(hintString, x + 22, y + 20, maxWidth - 28);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return StringUtil.localize("hints." + hints[position] + ".tag");
|
||||
return hintTooltip;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -30,36 +30,44 @@ public abstract class Ledger {
|
||||
protected static final int maxWidth = 124;
|
||||
protected static final int minWidth = 24;
|
||||
public static final int minHeight = 24;
|
||||
protected int maxHeight = 24;
|
||||
|
||||
private static final ResourceLocation ledgerTextureRight = new ForestryResource(Defaults.TEXTURE_PATH_GUI + "/ledger.png");
|
||||
private static final ResourceLocation ledgerTextureLeft = new ForestryResource(Defaults.TEXTURE_PATH_GUI + "/ledgerLeft.png");
|
||||
|
||||
protected final LedgerManager manager;
|
||||
|
||||
private boolean open;
|
||||
protected final int fontColorHeader;
|
||||
protected final int fontColorText;
|
||||
protected final int fontColorSubheader;
|
||||
protected final int overlayColor;
|
||||
|
||||
protected int overlayColor = 0xffffff;
|
||||
private boolean open;
|
||||
|
||||
public int currentShiftX = 0;
|
||||
public int currentShiftY = 0;
|
||||
protected float currentWidth = minWidth;
|
||||
protected int maxHeight = 24;
|
||||
|
||||
protected float currentWidth = minWidth;
|
||||
protected float currentHeight = minHeight;
|
||||
|
||||
protected final ResourceLocation texture;
|
||||
|
||||
public Ledger(LedgerManager manager) {
|
||||
this(manager, true);
|
||||
public Ledger(LedgerManager manager, String name) {
|
||||
this(manager, name, true);
|
||||
}
|
||||
|
||||
public Ledger(LedgerManager manager, boolean rightSide) {
|
||||
public Ledger(LedgerManager manager, String name, boolean rightSide) {
|
||||
this.manager = manager;
|
||||
if (rightSide) {
|
||||
texture = ledgerTextureRight;
|
||||
} else {
|
||||
texture = ledgerTextureLeft;
|
||||
}
|
||||
|
||||
fontColorHeader = manager.gui.fontColor.get("ledger." + name + ".header");
|
||||
fontColorSubheader = manager.gui.fontColor.get("ledger." + name + ".subheader");
|
||||
fontColorText = manager.gui.fontColor.get("ledger." + name + ".text");
|
||||
overlayColor = manager.gui.fontColor.get("ledger." + name + ".background");
|
||||
}
|
||||
|
||||
// adjust the update's move amount to match the look of 60 fps (16.67 ms per update)
|
||||
@@ -186,6 +194,21 @@ public abstract class Ledger {
|
||||
manager.gui.drawTexturedModelRectFromIcon(x, y, icon, 16, 16);
|
||||
GL11.glEnable(GL11.GL_LIGHTING);
|
||||
}
|
||||
}
|
||||
|
||||
protected void drawHeader(String string, int x, int y) {
|
||||
manager.minecraft.fontRenderer.drawStringWithShadow(string, x, y, fontColorHeader);
|
||||
}
|
||||
|
||||
protected void drawSubheader(String string, int x, int y) {
|
||||
manager.minecraft.fontRenderer.drawStringWithShadow(string, x, y, fontColorSubheader);
|
||||
}
|
||||
|
||||
protected void drawText(String string, int x, int y) {
|
||||
manager.minecraft.fontRenderer.drawString(string, x, y, fontColorText);
|
||||
}
|
||||
|
||||
protected void drawSplitText(String string, int x, int y, int width) {
|
||||
manager.minecraft.fontRenderer.drawSplitString(string, x, y, width, fontColorText);
|
||||
}
|
||||
}
|
||||
@@ -31,10 +31,19 @@ import forestry.core.utils.StringUtil;
|
||||
public class OwnerLedger extends Ledger {
|
||||
|
||||
private final IOwnable tile;
|
||||
private final boolean playerIsOwner;
|
||||
|
||||
public OwnerLedger(LedgerManager manager, IOwnable tile) {
|
||||
super(manager);
|
||||
super(manager, "owner");
|
||||
this.tile = tile;
|
||||
|
||||
playerIsOwner = tile.isOwner(manager.minecraft.thePlayer);
|
||||
|
||||
if (playerIsOwner) {
|
||||
maxHeight = 60;
|
||||
} else {
|
||||
maxHeight = 36;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAccessButton(int mouseX, int mouseY) {
|
||||
@@ -47,16 +56,6 @@ public class OwnerLedger extends Ledger {
|
||||
|
||||
@Override
|
||||
public void draw(int x, int y) {
|
||||
|
||||
// Update state
|
||||
boolean playerIsOwner = tile.isOwner(manager.minecraft.thePlayer);
|
||||
|
||||
if (playerIsOwner) {
|
||||
maxHeight = 60;
|
||||
} else {
|
||||
maxHeight = 36;
|
||||
}
|
||||
|
||||
// Draw background
|
||||
drawBackground(x, y);
|
||||
|
||||
@@ -75,16 +74,15 @@ public class OwnerLedger extends Ledger {
|
||||
return;
|
||||
}
|
||||
|
||||
manager.minecraft.fontRenderer.drawStringWithShadow(StringUtil.localize("gui.owner"), x + 22, y + 8, manager.gui.fontColor.get("ledger.owner.header"));
|
||||
drawHeader(StringUtil.localize("gui.owner"), x + 22, y + 8);
|
||||
|
||||
manager.minecraft.fontRenderer.drawString(PlayerUtil.getOwnerName(tile), x + 22, y + 20, manager.gui.fontColor.get("ledger.owner.text"));
|
||||
drawText(PlayerUtil.getOwnerName(tile), x + 22, y + 20);
|
||||
|
||||
if (playerIsOwner && tile instanceof IRestrictedAccess) {
|
||||
manager.minecraft.fontRenderer.drawStringWithShadow(StringUtil.localize("gui.access") + ":", x + 22, y + 32,
|
||||
manager.gui.fontColor.get("ledger.owner.subheader"));
|
||||
drawSubheader(StringUtil.localize("gui.access") + ':', x + 22, y + 32);
|
||||
// Access rules
|
||||
drawIcon(accessIcon, x + 20, y + 40);
|
||||
manager.minecraft.fontRenderer.drawString(StringUtil.localize(access.getName()), x + 38, y + 44, manager.gui.fontColor.get("ledger.owner.text"));
|
||||
drawText(StringUtil.localize(access.getName()), x + 38, y + 44);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,5 +106,4 @@ public class OwnerLedger extends Ledger {
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,10 +20,9 @@ public class PowerLedger extends Ledger {
|
||||
private final IPowerHandler tile;
|
||||
|
||||
public PowerLedger(LedgerManager manager, IPowerHandler tile) {
|
||||
super(manager);
|
||||
super(manager, "power");
|
||||
this.tile = tile;
|
||||
maxHeight = 94;
|
||||
overlayColor = manager.gui.fontColor.get("ledger.power.background");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -39,17 +38,17 @@ public class PowerLedger extends Ledger {
|
||||
}
|
||||
|
||||
EnergyManager energyManager = tile.getEnergyManager();
|
||||
manager.minecraft.fontRenderer.drawStringWithShadow(StringUtil.localize("gui.energy"), x + 22, y + 8, manager.gui.fontColor.get("ledger.power.header"));
|
||||
manager.minecraft.fontRenderer.drawStringWithShadow(StringUtil.localize("gui.stored") + ":", x + 22, y + 20,
|
||||
manager.gui.fontColor.get("ledger.power.subheader"));
|
||||
manager.minecraft.fontRenderer.drawString(energyManager.getTotalEnergyStored() + " RF", x + 22, y + 32, manager.gui.fontColor.get("ledger.power.text"));
|
||||
manager.minecraft.fontRenderer.drawStringWithShadow(StringUtil.localize("gui.maxenergy") + ":", x + 22, y + 44,
|
||||
manager.gui.fontColor.get("ledger.power.subheader"));
|
||||
manager.minecraft.fontRenderer.drawString(energyManager.getMaxEnergyStored() + " RF", x + 22, y + 56, manager.gui.fontColor.get("ledger.power.text"));
|
||||
manager.minecraft.fontRenderer.drawStringWithShadow(StringUtil.localize("gui.maxenergyreceive") + ":", x + 22, y + 68,
|
||||
manager.gui.fontColor.get("ledger.power.subheader"));
|
||||
manager.minecraft.fontRenderer.drawString(energyManager.getMaxEnergyReceived() + " RF", x + 22, y + 80, manager.gui.fontColor.get("ledger.power.text"));
|
||||
|
||||
drawHeader(StringUtil.localize("gui.energy"), x + 22, y + 8);
|
||||
|
||||
drawSubheader(StringUtil.localize("gui.stored") + ':', x + 22, y + 20);
|
||||
drawText(energyManager.getTotalEnergyStored() + " RF", x + 22, y + 32);
|
||||
|
||||
drawSubheader(StringUtil.localize("gui.maxenergy") + ':', x + 22, y + 44);
|
||||
drawText(energyManager.getMaxEnergyStored() + " RF", x + 22, y + 56);
|
||||
|
||||
drawSubheader(StringUtil.localize("gui.maxenergyreceive") + ':', x + 22, y + 68);
|
||||
drawText(energyManager.getMaxEnergyReceived() + " RF", x + 22, y + 80);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,9 +26,8 @@ public abstract class GuiEngine<C extends Container, I extends Engine> extends G
|
||||
protected class EngineLedger extends Ledger {
|
||||
|
||||
public EngineLedger() {
|
||||
super(ledgerManager);
|
||||
super(ledgerManager, "power");
|
||||
maxHeight = 94;
|
||||
overlayColor = fontColor.get("ledger.power.background");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -44,13 +43,16 @@ public abstract class GuiEngine<C extends Container, I extends Engine> extends G
|
||||
return;
|
||||
}
|
||||
|
||||
fontRendererObj.drawStringWithShadow(StringUtil.localize("gui.energy"), x + 22, y + 8, fontColor.get("ledger.power.header"));
|
||||
fontRendererObj.drawStringWithShadow(StringUtil.localize("gui.currentOutput") + ":", x + 22, y + 20, fontColor.get("ledger.power.subheader"));
|
||||
fontRendererObj.drawString(inventory.getCurrentOutput() + " RF/t", x + 22, y + 32, fontColor.get("ledger.power.text"));
|
||||
fontRendererObj.drawStringWithShadow(StringUtil.localize("gui.stored") + ":", x + 22, y + 44, fontColor.get("ledger.power.subheader"));
|
||||
fontRendererObj.drawString(inventory.getEnergyManager().getEnergyStored(inventory.getOrientation()) + " RF", x + 22, y + 56, fontColor.get("ledger.power.text"));
|
||||
fontRendererObj.drawStringWithShadow(StringUtil.localize("gui.heat") + ":", x + 22, y + 68, fontColor.get("ledger.power.subheader"));
|
||||
fontRendererObj.drawString((((double) inventory.getHeat() / (double) 10) + 20.0) + " C", x + 22, y + 80, fontColor.get("ledger.power.text"));
|
||||
drawHeader(StringUtil.localize("gui.energy"), x + 22, y + 8);
|
||||
|
||||
drawSubheader(StringUtil.localize("gui.currentOutput") + ':', x + 22, y + 20);
|
||||
drawText(inventory.getCurrentOutput() + " RF/t", x + 22, y + 32);
|
||||
|
||||
drawSubheader(StringUtil.localize("gui.stored") + ':', x + 22, y + 44);
|
||||
drawText(inventory.getEnergyManager().getEnergyStored(inventory.getOrientation()) + " RF", x + 22, y + 56);
|
||||
|
||||
drawSubheader(StringUtil.localize("gui.heat") + ':', x + 22, y + 68);
|
||||
drawText((((double) inventory.getHeat() / (double) 10) + 20.0) + " C", x + 22, y + 80);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -34,9 +34,8 @@ public class GuiFarm extends GuiForestry<ContainerFarm, TileFarmPlain> {
|
||||
protected class FarmLedger extends Ledger {
|
||||
|
||||
public FarmLedger() {
|
||||
super(ledgerManager);
|
||||
super(ledgerManager, "farm");
|
||||
maxHeight = 118;
|
||||
overlayColor = fontColor.get("ledger.farm.background");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -52,22 +51,24 @@ public class GuiFarm extends GuiForestry<ContainerFarm, TileFarmPlain> {
|
||||
return;
|
||||
}
|
||||
|
||||
fontRendererObj.drawStringWithShadow(StringUtil.localize("gui.hydration"), x + 22, y + 8, fontColor.get("ledger.power.header"));
|
||||
fontRendererObj.drawStringWithShadow(StringUtil.localize("gui.hydr.heat") + ":", x + 22, y + 20, fontColor.get("ledger.power.subheader"));
|
||||
fontRendererObj.drawString(StringUtil.floatAsPercent(inventory.getHydrationTempModifier()), x + 22, y + 32, fontColor.get("ledger.power.text"));
|
||||
fontRendererObj.drawStringWithShadow(StringUtil.localize("gui.hydr.humid") + ":", x + 22, y + 44, fontColor.get("ledger.power.subheader"));
|
||||
fontRendererObj.drawString(StringUtil.floatAsPercent(inventory.getHydrationHumidModifier()), x + 22, y + 56, fontColor.get("ledger.power.text"));
|
||||
fontRendererObj.drawStringWithShadow(StringUtil.localize("gui.hydr.rainfall") + ":", x + 22, y + 68, fontColor.get("ledger.power.subheader"));
|
||||
fontRendererObj.drawString(StringUtil.floatAsPercent(inventory.getHydrationRainfallModifier()) + " (" + inventory.getDrought() + " d)", x + 22, y + 80,
|
||||
fontColor.get("ledger.power.text"));
|
||||
fontRendererObj.drawStringWithShadow(StringUtil.localize("gui.hydr.overall") + ":", x + 22, y + 92, fontColor.get("ledger.power.subheader"));
|
||||
fontRendererObj.drawString(StringUtil.floatAsPercent(inventory.getHydrationModifier()), x + 22, y + 104, fontColor.get("ledger.power.text"));
|
||||
drawHeader(StringUtil.localize("gui.hydration"), x + 22, y + 8);
|
||||
|
||||
drawSubheader(StringUtil.localize("gui.hydr.heat") + ':', x + 22, y + 20);
|
||||
drawText(StringUtil.floatAsPercent(inventory.getHydrationTempModifier()), x + 22, y + 32);
|
||||
|
||||
drawSubheader(StringUtil.localize("gui.hydr.humid") + ':', x + 22, y + 44);
|
||||
drawText(StringUtil.floatAsPercent(inventory.getHydrationHumidModifier()), x + 22, y + 56);
|
||||
|
||||
drawSubheader(StringUtil.localize("gui.hydr.rainfall") + ':', x + 22, y + 68);
|
||||
drawText(StringUtil.floatAsPercent(inventory.getHydrationRainfallModifier()) + " (" + inventory.getDrought() + " d)", x + 22, y + 80);
|
||||
|
||||
drawSubheader(StringUtil.localize("gui.hydr.overall") + ':', x + 22, y + 92);
|
||||
drawText(StringUtil.floatAsPercent(inventory.getHydrationModifier()), x + 22, y + 104);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTooltip() {
|
||||
return StringUtil.floatAsPercent(inventory.getHydrationModifier()) + " " + StringUtil.localize("gui.hydration");
|
||||
return StringUtil.floatAsPercent(inventory.getHydrationModifier()) + ' ' + StringUtil.localize("gui.hydration");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user