mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-18 11:29:30 +00:00
Merge pull request #1907 from MatthiasMann/generator_progress_tooltips
add remaining percentage/time/RF tooltip on stirling generator
This commit is contained in:
commit
95f016ee92
3 files changed
+38
-9
No files matched your search
+20
-1
@@ -39,6 +39,8 @@ public class GuiStirlingGenerator extends GuiPoweredMachineBase<TileEntityStirli
|
||||
return !c.getUpgradeSlot().getHasStack() && super.shouldDraw();
|
||||
}
|
||||
});
|
||||
|
||||
addProgressTooltip(80, 52, 14, 14);
|
||||
}
|
||||
|
||||
private static float getFactor(Capacitors upgrade) {
|
||||
@@ -62,6 +64,23 @@ public class GuiStirlingGenerator extends GuiPoweredMachineBase<TileEntityStirli
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String formatProgressTooltip(int scaledProgress, float remaining) {
|
||||
int totalBurnTime = getTileEntity().totalBurnTime;
|
||||
int remainingTicks = (int)(remaining * totalBurnTime);
|
||||
int remainingSecs = remainingTicks / 20;
|
||||
int remainingRF = getTileEntity().getPowerUsePerTick() * remainingTicks;
|
||||
return MessageFormat.format(Lang.localize("stirlingGenerator.remaining"),
|
||||
remaining, remainingSecs / 60, remainingSecs % 60, remainingRF);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int scaleProgressForTooltip(float progress) {
|
||||
int totalBurnTime = getTileEntity().totalBurnTime;
|
||||
int scale = Math.max(100, (totalBurnTime+19)/20);
|
||||
return (int)(progress * scale);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3) {
|
||||
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
@@ -72,7 +91,7 @@ public class GuiStirlingGenerator extends GuiPoweredMachineBase<TileEntityStirli
|
||||
drawTexturedModalRect(sx, sy, 0, 0, this.xSize, this.ySize);
|
||||
int scaled;
|
||||
|
||||
if(getTileEntity().getProgress() < 1 && getTileEntity().getProgress() > 0) {
|
||||
if(shouldRenderProgress()) {
|
||||
scaled = getTileEntity().getProgressScaled(12);
|
||||
drawTexturedModalRect(sx + 80, sy + 64 - scaled, 176, 12 - scaled, 14, scaled + 2);
|
||||
}
|
||||
|
||||
@@ -151,33 +151,42 @@ public abstract class GuiMachineBase<T extends AbstractMachineEntity> extends Gu
|
||||
addToolTip(tt);
|
||||
}
|
||||
|
||||
private void updateProgressTooltips(int progress) {
|
||||
if(lastProgressTooltipValue == progress || progressTooltips == null) {
|
||||
private void updateProgressTooltips(int scaledProgress, float progress) {
|
||||
if(lastProgressTooltipValue == scaledProgress || progressTooltips == null) {
|
||||
return;
|
||||
}
|
||||
lastProgressTooltipValue = progress;
|
||||
lastProgressTooltipValue = scaledProgress;
|
||||
|
||||
if(progress < 0) {
|
||||
if(scaledProgress < 0) {
|
||||
for(GuiToolTip tt : progressTooltips) {
|
||||
tt.setVisible(false);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
String msg = MessageFormat.format(Lang.localize("gui.progress"), progress);
|
||||
String msg = formatProgressTooltip(scaledProgress, progress);
|
||||
String[] tooltip = msg.split("\\|");
|
||||
for(GuiToolTip tt : progressTooltips) {
|
||||
tt.setToolTipText(msg);
|
||||
tt.setToolTipText(tooltip);
|
||||
tt.setVisible(true);
|
||||
}
|
||||
}
|
||||
|
||||
protected String formatProgressTooltip(int scaledProgress, float progress) {
|
||||
return MessageFormat.format(Lang.localize("gui.progress"), scaledProgress);
|
||||
}
|
||||
|
||||
protected int scaleProgressForTooltip(float progress) {
|
||||
return (int)(progress * 100);
|
||||
}
|
||||
|
||||
protected boolean shouldRenderProgress() {
|
||||
float progress = tileEntity.getProgress();
|
||||
if(progress > 0 && progress < 1) {
|
||||
updateProgressTooltips((int)(progress * 100));
|
||||
updateProgressTooltips(scaleProgressForTooltip(progress), progress);
|
||||
return true;
|
||||
} else {
|
||||
updateProgressTooltips(-1);
|
||||
updateProgressTooltips(-1, -1);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user