mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-05 08:27:37 +07:00
Long support for UI.formatAmount
This commit is contained in:
parent
1bd4c96ee8
commit
5a5854420e
@ -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") + "[]";
|
||||
|
@ -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())));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user