diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 8da18c55f6..70f35b5c86 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -634,6 +634,7 @@ unit.percent = % unit.items = items unit.thousands = k unit.millions = mil +unit.billions = b category.general = General category.power = Power category.liquids = Liquids diff --git a/core/src/mindustry/content/TechTree.java b/core/src/mindustry/content/TechTree.java index 02c9fd0318..da36956a4d 100644 --- a/core/src/mindustry/content/TechTree.java +++ b/core/src/mindustry/content/TechTree.java @@ -4,6 +4,7 @@ import arc.*; import arc.math.*; import arc.struct.*; import arc.util.ArcAnnotate.*; +import mindustry.core.*; import mindustry.ctype.*; import mindustry.game.Objectives.*; import mindustry.type.*; @@ -431,7 +432,9 @@ public class TechTree implements ContentList{ requirements = new ItemStack[block.requirements.length]; for(int i = 0; i < requirements.length; i++){ - requirements[i] = new ItemStack(block.requirements[i].item, 40 + Mathf.round(Mathf.pow(block.requirements[i].amount, 1.25f) * 20, 10)); + int quantity = 40 + Mathf.round(Mathf.pow(block.requirements[i].amount, 1.25f) * 20, 10); + + requirements[i] = new ItemStack(block.requirements[i].item, UI.roundAmount(quantity)); } }else{ requirements = ItemStack.empty; diff --git a/core/src/mindustry/core/UI.java b/core/src/mindustry/core/UI.java index 196937d548..31478bf39e 100644 --- a/core/src/mindustry/core/UI.java +++ b/core/src/mindustry/core/UI.java @@ -488,10 +488,14 @@ public class UI implements ApplicationListener, Loadable{ dialog.show(); } - public String formatAmount(int number){ - if(number >= 1000000){ - return Strings.fixed(number / 1000000f, 1) + "[gray]" + Core.bundle.get("unit.millions") + "[]"; - }else if(number >= 10000){ + //TODO move? + + public static String formatAmount(long number){ + if(number >= 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){ + return Strings.fixed(number / 1_000_000f, 1) + "[gray]" + Core.bundle.get("unit.millions") + "[]"; + }else if(number >= 10_000){ return number / 1000 + "[gray]" + Core.bundle.get("unit.thousands") + "[]"; }else if(number >= 1000){ return Strings.fixed(number / 1000f, 1) + "[gray]" + Core.bundle.get("unit.thousands") + "[]"; @@ -499,4 +503,22 @@ public class UI implements ApplicationListener, Loadable{ return number + ""; } } + + public static int roundAmount(int number){ + if(number >= 1_000_000_000){ + return Mathf.round(number, 100_000_000); + }else if(number >= 1_000_000){ + return Mathf.round(number, 100_000); + }else if(number >= 10_000){ + return Mathf.round(number, 1000); + }else if(number >= 1000){ + return Mathf.round(number, 100); + }else if(number >= 100){ + return Mathf.round(number, 100); + }else if(number >= 10){ + return Mathf.round(number, 10); + }else{ + return number; + } + } } diff --git a/core/src/mindustry/game/SectorInfo.java b/core/src/mindustry/game/SectorInfo.java index 4192831910..11cb1c8ace 100644 --- a/core/src/mindustry/game/SectorInfo.java +++ b/core/src/mindustry/game/SectorInfo.java @@ -81,7 +81,7 @@ public class SectorInfo{ state.rules.sector.setTimeSpent(internalTimeSpent); } - /** Update averages of various stats. + /** Update averages of various stats, updates some special sector logic. * Called every frame. */ public void update(){ internalTimeSpent += Time.delta; diff --git a/core/src/mindustry/ui/CoreItemsDisplay.java b/core/src/mindustry/ui/CoreItemsDisplay.java index cb9e92fd47..30b838e0b9 100644 --- a/core/src/mindustry/ui/CoreItemsDisplay.java +++ b/core/src/mindustry/ui/CoreItemsDisplay.java @@ -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(); diff --git a/core/src/mindustry/ui/ItemsDisplay.java b/core/src/mindustry/ui/ItemsDisplay.java index 351b3f17f2..8b1b67278c 100644 --- a/core/src/mindustry/ui/ItemsDisplay.java +++ b/core/src/mindustry/ui/ItemsDisplay.java @@ -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(); } diff --git a/core/src/mindustry/ui/dialogs/PlanetDialog.java b/core/src/mindustry/ui/dialogs/PlanetDialog.java index 801f2ee057..a4764be9ef 100644 --- a/core/src/mindustry/ui/dialogs/PlanetDialog.java +++ b/core/src/mindustry/ui/dialogs/PlanetDialog.java @@ -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(); } diff --git a/core/src/mindustry/ui/dialogs/ResearchDialog.java b/core/src/mindustry/ui/dialogs/ResearchDialog.java index 007544f66b..6e28a421e7 100644 --- a/core/src/mindustry/ui/dialogs/ResearchDialog.java +++ b/core/src/mindustry/ui/dialogs/ResearchDialog.java @@ -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(); diff --git a/core/src/mindustry/ui/fragments/PlacementFragment.java b/core/src/mindustry/ui/fragments/PlacementFragment.java index ac44de1d8c..26f4bdc014 100644 --- a/core/src/mindustry/ui/fragments/PlacementFragment.java +++ b/core/src/mindustry/ui/fragments/PlacementFragment.java @@ -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(); diff --git a/core/src/mindustry/world/blocks/power/PowerNode.java b/core/src/mindustry/world/blocks/power/PowerNode.java index 5fc2683b98..443ace7aae 100644 --- a/core/src/mindustry/world/blocks/power/PowerNode.java +++ b/core/src/mindustry/world/blocks/power/PowerNode.java @@ -10,6 +10,7 @@ import arc.struct.*; import arc.util.ArcAnnotate.*; import arc.util.*; import mindustry.annotations.Annotations.*; +import mindustry.core.*; import mindustry.entities.units.*; import mindustry.game.*; import mindustry.gen.*; @@ -99,7 +100,7 @@ public class PowerNode extends PowerBlock{ bars.add("batteries", entity -> new Bar(() -> Core.bundle.format("bar.powerstored", - (ui.formatAmount((int)entity.power.graph.getBatteryStored())), ui.formatAmount((int)entity.power.graph.getTotalBatteryCapacity())), + (UI.formatAmount((int)entity.power.graph.getBatteryStored())), UI.formatAmount((int)entity.power.graph.getTotalBatteryCapacity())), () -> Pal.powerBar, () -> Mathf.clamp(entity.power.graph.getBatteryStored() / entity.power.graph.getTotalBatteryCapacity()))); } diff --git a/core/src/mindustry/world/blocks/production/Fracker.java b/core/src/mindustry/world/blocks/production/Fracker.java index 12649b8f06..05753ded52 100644 --- a/core/src/mindustry/world/blocks/production/Fracker.java +++ b/core/src/mindustry/world/blocks/production/Fracker.java @@ -39,11 +39,6 @@ public class Fracker extends SolidPump{ @Override public void drawCracks(){} - @Override - public boolean shouldConsume(){ - return liquids.get(result) < liquidCapacity - 0.01f; - } - @Override public void draw(){ Draw.rect(region, x, y); diff --git a/core/src/mindustry/world/blocks/production/Pump.java b/core/src/mindustry/world/blocks/production/Pump.java index ae77c42690..cc109b57d7 100644 --- a/core/src/mindustry/world/blocks/production/Pump.java +++ b/core/src/mindustry/world/blocks/production/Pump.java @@ -113,6 +113,11 @@ public class Pump extends LiquidBlock{ } } + @Override + public boolean shouldConsume(){ + return liquidDrop != null && liquids.get(liquidDrop) < liquidCapacity - 0.01f; + } + @Override public void updateTile(){ if(consValid() && liquidDrop != null){ diff --git a/core/src/mindustry/world/blocks/production/SolidPump.java b/core/src/mindustry/world/blocks/production/SolidPump.java index 5c83b4fcec..422557ff8d 100644 --- a/core/src/mindustry/world/blocks/production/SolidPump.java +++ b/core/src/mindustry/world/blocks/production/SolidPump.java @@ -101,6 +101,11 @@ public class SolidPump extends Pump{ Draw.rect(topRegion, x, y); } + @Override + public boolean shouldConsume(){ + return liquids.get(result) < liquidCapacity - 0.01f; + } + @Override public void updateTile(){ float fraction = 0f; diff --git a/core/src/mindustry/world/blocks/storage/CoreBlock.java b/core/src/mindustry/world/blocks/storage/CoreBlock.java index 80902f9636..3f2b2f42be 100644 --- a/core/src/mindustry/world/blocks/storage/CoreBlock.java +++ b/core/src/mindustry/world/blocks/storage/CoreBlock.java @@ -9,6 +9,7 @@ import arc.struct.*; import arc.util.ArcAnnotate.*; import mindustry.annotations.Annotations.*; import mindustry.content.*; +import mindustry.core.*; import mindustry.entities.*; import mindustry.game.EventType.*; import mindustry.game.*; @@ -77,10 +78,10 @@ public class CoreBlock extends StorageBlock{ bars.add("capacity", (CoreEntity e) -> new Bar( - () -> Core.bundle.format("bar.capacity", ui.formatAmount(e.storageCapacity)), + () -> Core.bundle.format("bar.capacity", UI.formatAmount(e.storageCapacity)), () -> Pal.items, () -> e.items.total() / ((float)e.storageCapacity * content.items().count(i -> i.unlockedNow())) - )); + )); } @Override diff --git a/gradle.properties b/gradle.properties index 05c6e6b468..019171b64b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms256m -Xmx1024m -archash=5743c603a03f521a841da6104192bcb679d58889 +archash=9758a12fe9090a08fead6186fe49b7c347180f2e