Long support for UI.formatAmount

This commit is contained in:
Anuken 2021-04-01 09:27:36 -04:00
parent 1bd4c96ee8
commit 5a5854420e
2 changed files with 5 additions and 5 deletions

View File

@ -535,11 +535,11 @@ public class UI implements ApplicationListener, Loadable{
dialog.show();
}
public static String formatAmount(int number){
public static String formatAmount(long number){
//prevent overflow
if(number == Integer.MIN_VALUE) number ++;
if(number == Long.MIN_VALUE) number ++;
int mag = Math.abs(number);
long mag = Math.abs(number);
String sign = number < 0 ? "-" : "";
if(mag >= 1_000_000_000){
return sign + Strings.fixed(mag / 1_000_000_000f, 1) + "[gray]" + Core.bundle.get("unit.billions") + "[]";

View File

@ -108,13 +108,13 @@ public class PowerNode extends PowerBlock{
super.setBars();
bars.add("power", entity -> new Bar(() ->
Core.bundle.format("bar.powerbalance",
((entity.power.graph.getPowerBalance() >= 0 ? "+" : "") + UI.formatAmount((int)(entity.power.graph.getPowerBalance() * 60)))),
((entity.power.graph.getPowerBalance() >= 0 ? "+" : "") + UI.formatAmount((long)(entity.power.graph.getPowerBalance() * 60)))),
() -> Pal.powerBar,
() -> Mathf.clamp(entity.power.graph.getLastPowerProduced() / entity.power.graph.getLastPowerNeeded())));
bars.add("batteries", entity -> new Bar(() ->
Core.bundle.format("bar.powerstored",
(UI.formatAmount((int)entity.power.graph.getLastPowerStored())), UI.formatAmount((int)entity.power.graph.getLastCapacity())),
(UI.formatAmount((long)entity.power.graph.getLastPowerStored())), UI.formatAmount((long)entity.power.graph.getLastCapacity())),
() -> Pal.powerBar,
() -> Mathf.clamp(entity.power.graph.getLastPowerStored() / entity.power.graph.getLastCapacity())));