From 9b6c1252330a5ab1fa55f6f9d9a5df309c5030f3 Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 20 Jan 2021 16:38:46 -0500 Subject: [PATCH] UI.formatAmount for negative numbers --- core/src/mindustry/core/UI.java | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/core/src/mindustry/core/UI.java b/core/src/mindustry/core/UI.java index 1eddb7b8fc..e22bc6817f 100644 --- a/core/src/mindustry/core/UI.java +++ b/core/src/mindustry/core/UI.java @@ -526,16 +526,15 @@ public class UI implements ApplicationListener, Loadable{ dialog.show(); } - //TODO move? - public static String formatAmount(int number){ - if(number >= 1_000_000_000){ + int mag = Math.abs(number); + if(mag >= 1_000_000_000){ return Strings.fixed(number / 1_000_000_000f, 1) + "[gray]" + Core.bundle.get("unit.billions") + "[]"; - }else if(number >= 1_000_000){ + }else if(mag >= 1_000_000){ return Strings.fixed(number / 1_000_000f, 1) + "[gray]" + Core.bundle.get("unit.millions") + "[]"; - }else if(number >= 10_000){ + }else if(mag >= 10_000){ return number / 1000 + "[gray]" + Core.bundle.get("unit.thousands") + "[]"; - }else if(number >= 1000){ + }else if(mag >= 1000){ return Strings.fixed(number / 1000f, 1) + "[gray]" + Core.bundle.get("unit.thousands") + "[]"; }else{ return number + "";