mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-10 10:47:13 +07:00
Rounding of research amounts
This commit is contained in:
parent
42d7eb4e05
commit
95f7fc1b3b
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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();
|
||||
|
@ -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())));
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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){
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -1,3 +1,3 @@
|
||||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||
archash=5743c603a03f521a841da6104192bcb679d58889
|
||||
archash=9758a12fe9090a08fead6186fe49b7c347180f2e
|
||||
|
Loading…
Reference in New Issue
Block a user