Rounding of research amounts

This commit is contained in:
Anuken
2020-07-26 10:35:47 -04:00
parent 42d7eb4e05
commit 95f7fc1b3b
15 changed files with 60 additions and 22 deletions

View File

@@ -3,6 +3,7 @@ package mindustry.ui;
import arc.scene.ui.layout.*;
import arc.struct.*;
import mindustry.*;
import mindustry.core.*;
import mindustry.type.*;
import mindustry.world.blocks.storage.CoreBlock.*;
@@ -41,7 +42,7 @@ public class CoreItemsDisplay extends Table{
for(Item item : content.items()){
if(usedItems.contains(item)){
image(item.icon(Cicon.small)).padRight(3);
label(() -> core == null ? "0" : ui.formatAmount(core.items.get(item))).padRight(3);
label(() -> core == null ? "0" : UI.formatAmount(core.items.get(item))).padRight(3);
if(++i % 4 == 0){
row();

View File

@@ -3,6 +3,7 @@ package mindustry.ui;
import arc.graphics.*;
import arc.scene.ui.*;
import arc.scene.ui.layout.*;
import mindustry.core.*;
import mindustry.gen.*;
import mindustry.type.*;
@@ -52,10 +53,10 @@ public class ItemsDisplay extends Table{
private String format(Item item){
builder.setLength(0);
builder.append("[TODO implement]");
//builder.append(ui.formatAmount(data.getItem(item)));
//builder.append(UI.formatAmount(data.getItem(item)));
if(state.isGame() && player.team().data().hasCore() && player.team().core().items.get(item) > 0){
builder.append(" [unlaunched]+ ");
builder.append(ui.formatAmount(state.teams.get(player.team()).core().items.get(item)));
builder.append(UI.formatAmount(state.teams.get(player.team()).core().items.get(item)));
}
return builder.toString();
}

View File

@@ -14,6 +14,7 @@ import arc.scene.ui.layout.*;
import arc.struct.*;
import arc.util.*;
import arc.util.ArcAnnotate.*;
import mindustry.core.*;
import mindustry.ctype.*;
import mindustry.game.*;
import mindustry.gen.*;
@@ -327,7 +328,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
int total = (int)(stat.mean * 60);
if(total > 1){
t.image(item.icon(Cicon.small)).padRight(3);
t.add(ui.formatAmount(total) + " /min").color(Color.lightGray);
t.add(UI.formatAmount(total) + " /min").color(Color.lightGray);
t.row();
}
});
@@ -348,7 +349,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
int amount = Math.min(map.get(item), sector.save.meta.secinfo.storageCapacity);
if(amount > 0){
res.image(item.icon(Cicon.small)).padRight(3);
res.add(ui.formatAmount(amount)).color(Color.lightGray);
res.add(UI.formatAmount(amount)).color(Color.lightGray);
if(++i % 2 == 0){
res.row();
}

View File

@@ -16,6 +16,7 @@ import arc.struct.*;
import arc.util.*;
import mindustry.content.*;
import mindustry.content.TechTree.*;
import mindustry.core.*;
import mindustry.game.EventType.*;
import mindustry.game.Objectives.*;
import mindustry.gen.*;
@@ -381,7 +382,7 @@ public class ResearchDialog extends BaseDialog{
list.left();
list.image(req.item.icon(Cicon.small)).size(8 * 3).padRight(3);
list.add(req.item.localizedName).color(Color.lightGray);
list.label(() -> " " + (player.team().core() != null ? Math.min(player.team().core().items.get(req.item), req.amount) + " / " : "") + req.amount)
list.label(() -> " " + (player.team().core() != null ? UI.formatAmount(Math.min(player.team().core().items.get(req.item), req.amount)) + " / " : "") + UI.formatAmount(req.amount))
.update(l -> l.setColor(items().has(req.item, req.amount) ? Color.lightGray : Color.scarlet));//TODO
}).fillX().left();
t.row();

View File

@@ -12,6 +12,7 @@ import arc.scene.ui.layout.*;
import arc.struct.*;
import arc.util.ArcAnnotate.*;
import arc.util.*;
import mindustry.core.*;
import mindustry.entities.*;
import mindustry.entities.units.*;
import mindustry.game.EventType.*;
@@ -325,7 +326,7 @@ public class PlacementFragment extends Fragment{
int stackamount = Math.round(stack.amount * state.rules.buildCostMultiplier);
String color = (amount < stackamount / 2f ? "[red]" : amount < stackamount ? "[accent]" : "[white]");
return color + ui.formatAmount(amount) + "[white]/" + stackamount;
return color + UI.formatAmount(amount) + "[white]/" + stackamount;
}).padLeft(5);
}).left();
req.row();