Skip to content

Commit

Permalink
Better rounding.
Browse files Browse the repository at this point in the history
  • Loading branch information
MEEPofFaith committed Feb 17, 2022
1 parent 27ab691 commit 04c227a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions src/testing/dialogs/WaveChangeDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void rebuild(){

all.clear();

float iconMul = 1.5f;
float iconMul = 2f;
all.table(t -> {
for(int i = minWave; i <= maxWave; i++){
int ii = i;
Expand Down Expand Up @@ -104,10 +104,10 @@ void rebuild(){
if(hasShield){
e.add(TUElements.itemImage(
Icon.defense,
() -> Utils.roundAmount((int)group.getShield(wave)),
() -> Utils.roundAmount(group.getShield(wave)),
Pal.accentBack,
Pal.accent,
0.75f,
1f,
Align.center
)).size(8 * 2 * iconMul).growX();
}
Expand Down
12 changes: 6 additions & 6 deletions src/testing/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,16 @@ public static String fixQuotes(String s){
return s.replaceAll("\"", "\\\\\"");
}

public static String roundAmount(int amount){
amount = UI.roundAmount(amount);
public static String roundAmount(float amount){
amount = UI.roundAmount((int)amount);
if(amount >= 1_000_000_000){
return amount / 1_000_000_000 + bundle.get("unit.billions");
return Strings.autoFixed(amount / 1_000_000_000, 1) + bundle.get("unit.billions");
}else if(amount >= 1_000_000){
return amount / 1_000_000 + bundle.get("unit.millions");
return Strings.autoFixed(amount / 1_000_000, 1) + bundle.get("unit.millions");
}else if(amount >= 1000){
return amount / 1000 + bundle.get("unit.thousands");
return Strings.autoFixed(amount / 1000, 1) + bundle.get("unit.thousands");
}else{
return String.valueOf(amount);
return String.valueOf((int)amount);
}
}
}

0 comments on commit 04c227a

Please sign in to comment.