This commit is contained in:
sharlotte
2021-08-26 09:25:12 +09:00
parent 24cd31776f
commit 09e5c4bc9e
8 changed files with 22 additions and 34 deletions

View File

@@ -19,8 +19,12 @@ public class SUtils {
public static String floatFormat(float number){
if(number >= 1000) return UI.formatAmount((long)number);
if(String.valueOf(number).length() > 2 && String.valueOf(number).split("[.]")[1].matches("0")) return String.valueOf(number).split("[.]")[0];
return Strings.fixed(number, 2);
return Strings.fixed(number, 1);
}
public static String floatFormat(int number){
if(number >= 1000) return UI.formatAmount(number);
return String.valueOf(number);
}
public static Object invoke(Object ut, String fieldName) throws IllegalAccessException, NoSuchFieldException {

View File

@@ -135,24 +135,24 @@ public class BarInfo {
numbers.set(1, (float) crafter.sense(LAccess.progress));
}
else if(target instanceof PowerNode.PowerNodeBuild node){
strings.set(1, bundle.format("bar.power", floatFormat(node.power.graph.getLastPowerStored()), floatFormat(node.power.graph.getLastCapacity())));
strings.set(1, bundle.format("shar-stat.power", floatFormat(node.power.graph.getLastPowerStored()), floatFormat(node.power.graph.getLastCapacity())));
colors.set(1, Pal.powerBar);
numbers.set(1, node.power.graph.getLastPowerStored() / node.power.graph.getLastCapacity());
}
else if(target instanceof PowerGenerator.GeneratorBuild generator){
strings.set(1, bundle.format("bar.power", floatFormat(generator.getPowerProduction() * generator.timeScale() * 60f)));
strings.set(1, bundle.format("shar-stat.power", floatFormat(generator.getPowerProduction() * generator.timeScale() * 60f)));
colors.set(1, Pal.powerBar);
numbers.set(1, generator.productionEfficiency);
}
if(target instanceof ItemTurret.ItemTurretBuild turret) {
ItemTurret block = (ItemTurret)turret.block;
strings.set(2, bundle.format("shar-stat.itemAmmo", floatFormat(turret.totalAmmo), floatFormat(block.maxAmmo)));
strings.set(2, bundle.format("shar-stat.capacity", turret.hasAmmo() ? block.ammoTypes.findKey(turret.peekAmmo(), true).localizedName : bundle.get("stat.ammo"), floatFormat(turret.totalAmmo), floatFormat(block.maxAmmo)));
colors.set(2, turret.hasAmmo() ? block.ammoTypes.findKey(turret.peekAmmo(), true).color : Pal.ammo);
numbers.set(2, turret.totalAmmo / (float)block.maxAmmo);
}
else if(target instanceof LiquidTurret.LiquidTurretBuild turret){
strings.set(2, bundle.format("shar-stat.liquidAmmo", floatFormat(turret.liquids.get(turret.liquids.current())), floatFormat(turret.block.liquidCapacity)));
strings.set(2, bundle.format("shar-stat.capacity", turret.liquids.currentAmount() < 0.01f ? turret.liquids.current().localizedName : bundle.get("stat.ammo"), floatFormat(turret.liquids.get(turret.liquids.current())), floatFormat(turret.block.liquidCapacity)));
colors.set(2, turret.liquids.current().color);
numbers.set(2, turret.liquids.get(turret.liquids.current()) / turret.block.liquidCapacity);
}
@@ -165,21 +165,21 @@ public class BarInfo {
}
else if(target instanceof Building b && b.block.hasItems) {
if(target instanceof CoreBlock.CoreBuild cb){
strings.set(2, bundle.format("shar-stat.itemCapacity", floatFormat(b.items.total()), floatFormat(cb.storageCapacity * content.items().count(UnlockableContent::unlockedNow))));
strings.set(2, bundle.format("shar-stat.capacity", bundle.get("category.items"), floatFormat(b.items.total()), floatFormat(cb.storageCapacity * content.items().count(UnlockableContent::unlockedNow))));
numbers.set(2, cb.items.total() / (cb.storageCapacity * content.items().count(UnlockableContent::unlockedNow) * 1f));
}
else if(target instanceof StorageBlock.StorageBuild sb && !sb.canPickup() && sb.linkedCore instanceof CoreBlock.CoreBuild cb){
strings.set(2, bundle.format("shar-stat.itemCapacity", floatFormat(sb.items.total()), floatFormat(cb.storageCapacity * content.items().count(UnlockableContent::unlockedNow))));
strings.set(2, bundle.format("shar-stat.capacity", bundle.get("category.items"), floatFormat(sb.items.total()), floatFormat(cb.storageCapacity * content.items().count(UnlockableContent::unlockedNow))));
numbers.set(2, sb.items.total() / (cb.storageCapacity * content.items().count(UnlockableContent::unlockedNow) * 1f));
}
else {
strings.set(2, bundle.format("shar-stat.itemCapacity", floatFormat(b.items.total()), floatFormat(b.block.itemCapacity)));
strings.set(2, bundle.format("shar-stat.capacity", bundle.get("category.items"), floatFormat(b.items.total()), floatFormat(b.block.itemCapacity)));
numbers.set(2, b.items.total() / (float) b.block.itemCapacity);
}
colors.set(2, Pal.items);
}
else if(target instanceof Unit unit && unit.type != null) {
strings.set(2, bundle.format("shar-stat.itemCapacity", floatFormat(unit.stack.amount), floatFormat(unit.type.itemCapacity)));
strings.set(2, bundle.format("shar-stat.capacity", unit.stack.item.localizedName, floatFormat(unit.stack.amount), floatFormat(unit.type.itemCapacity)));
if(unit.stack.amount > 0 && unit.stack().item != null) colors.set(2, unit.stack.item.color.cpy().lerp(Color.white, 0.15f));
numbers.set(2, unit.stack.amount / (unit.type.itemCapacity * 1f));
}
@@ -261,7 +261,7 @@ public class BarInfo {
numbers.set(4, node.power.graph.getLastScaledPowerOut() / node.power.graph.getLastScaledPowerIn());
}
else if(build.block.hasLiquids) {
strings.set(4, bundle.format("shar-stat.liquidCapacity", floatFormat(build.liquids.currentAmount()), floatFormat(build.block.liquidCapacity)));
strings.set(4, bundle.format("shar-stat.capacity", build.liquids.currentAmount() < 0.01f ? build.liquids.current().localizedName : bundle.get("bar.liquid"), floatFormat(build.liquids.currentAmount()), floatFormat(build.block.liquidCapacity)));
colors.set(4, build.liquids.current().color);
numbers.set(4, build.liquids.currentAmount() / build.block.liquidCapacity);
}

View File

@@ -448,19 +448,19 @@ public class HudUi {
Button unitBtn = new ImageButton(new ScaledNinePatchDrawable(new NinePatch(Icon.grid.getRegion()), 0.5f), Styles.clearToggleTransi);
Button logicBtn = new ImageButton(new ScaledNinePatchDrawable(new NinePatch(Icon.grid.getRegion()), 0.5f), Styles.clearToggleTransi);
pathBtn.addListener(new Tooltip(l -> l.label(() -> "PathLine " + (pathLine ? "[accent]Enabled[]" : "[gray]Disabled[]"))){{allowMobile = true;}});
pathBtn.addListener(new Tooltip(l -> l.label(() -> "PathLine " + (pathLine ? "[accent]Enabled[]" : "[gray]Disabled[]"))));
pathBtn.clicked(() -> {
pathLine = !pathLine;
pathBtn.setChecked(pathLine);
});
unitBtn.addListener(new Tooltip(l -> l.label(() -> "UnitLine " + (unitLine ? "[accent]Enabled[]" : "[gray]Disabled[]"))){{allowMobile = true;}});
unitBtn.addListener(new Tooltip(l -> l.label(() -> "UnitLine " + (unitLine ? "[accent]Enabled[]" : "[gray]Disabled[]"))));
unitBtn.clicked(() -> {
unitLine = !unitLine;
unitBtn.setChecked(unitLine);
});
logicBtn.addListener(new Tooltip(l -> l.label(() -> "LogicLine " + (logicLine ? "[accent]Enabled[]" : "[gray]Disabled[]"))){{allowMobile = true;}});
logicBtn.addListener(new Tooltip(l -> l.label(() -> "LogicLine " + (logicLine ? "[accent]Enabled[]" : "[gray]Disabled[]"))));
logicBtn.clicked(() -> {
logicLine = !logicLine;
logicBtn.setChecked(logicLine);
@@ -1024,7 +1024,7 @@ public class HudUi {
}).size(iconMed * Scl.scl(modUiScale));
to.row();
}
})){{allowMobile = true;}});
})));
});
if(++row % 4 == 0) tx.row();
}

View File

@@ -47,7 +47,7 @@ public class CoresItemsDisplay {
updateItems.clear();
prevItems.clear();
coreAmount.clear();
teams = new Seq<Team>(Team.all).addAll(Team.baseTeams).filter(t -> t.cores().any()).toArray();
teams = Team.baseTeams;
for(Team team : teams) {
usedItems.put(team, new ObjectSet<>());
usedUnits.put(team, new ObjectSet<>());
@@ -148,7 +148,7 @@ public class CoresItemsDisplay {
new Table(ttt -> {
ttt.bottom().right();
Label label = new Label(() -> {
int amount = updateItems.get(team).get(item.id).amount / (settings.getInt("coreItemCheckRate") / 60);
int amount = (int)(updateItems.get(team).get(item.id).amount / ((settings.getInt("coreItemCheckRate") * 1f) / 60f));
return (amount > 0 ? "[green]+" : amount == 0 ? "[orange]" : "[red]") + amount + "/s[]";
});
label.setFontScale(0.65f * modUiScale);