mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-26 06:22:17 -08:00
Sector items display fixes
This commit is contained in:
parent
ba227d64fb
commit
b28aff4a7b
2 changed files with 27 additions and 31 deletions
|
|
@ -265,10 +265,9 @@ public class SectorInfo{
|
|||
return map;
|
||||
}
|
||||
|
||||
|
||||
/** @return a newly allocated map with import statistics. Use sparingly. */
|
||||
//TODO this can be a float map
|
||||
public ObjectMap<Item, ExportStat> importStats(){
|
||||
//build empty import stats
|
||||
ObjectMap<Item, ExportStat> imports = new ObjectMap<>();
|
||||
//for all sectors on all planets that have bases and export to this sector
|
||||
for(Planet planet : content.planets()){
|
||||
|
|
|
|||
|
|
@ -603,36 +603,33 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
|||
selectAlpha = Mathf.lerpDelta(selectAlpha, Mathf.num(planets.zoom < 1.9f), 0.1f);
|
||||
}
|
||||
|
||||
void displayItems(Table c, float scl, ObjectMap<Item, ExportStat> stats, String name){
|
||||
Table t = new Table().left();
|
||||
|
||||
int i = 0;
|
||||
for(var item : content.items()){
|
||||
var stat = stats.get(item);
|
||||
if(stat == null) continue;
|
||||
int total = (int)(stat.mean * 60 * scl);
|
||||
if(total > 1){
|
||||
t.image(item.uiIcon).padRight(3);
|
||||
t.add(UI.formatAmount(total) + " " + Core.bundle.get("unit.perminute")).color(Color.lightGray).padRight(3);
|
||||
if(++i % 3 == 0){
|
||||
t.row();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(t.getChildren().any()){
|
||||
c.add(name).left().row();
|
||||
c.add(t).padLeft(10f).left().row();
|
||||
}
|
||||
}
|
||||
|
||||
void showStats(Sector sector){
|
||||
BaseDialog dialog = new BaseDialog(sector.name());
|
||||
|
||||
dialog.cont.pane(c -> {
|
||||
Cons2<ObjectMap<Item, ExportStat>, String> display = (stats, name) -> {
|
||||
Table t = new Table().left();
|
||||
|
||||
float scl = sector.getProductionScale();
|
||||
|
||||
int[] i = {0};
|
||||
|
||||
for(var item : content.items()){
|
||||
var stat = stats.get(item);
|
||||
if(stat == null) continue;
|
||||
int total = (int)(stat.mean * 60 * scl);
|
||||
if(total > 1){
|
||||
t.image(item.uiIcon).padRight(3);
|
||||
t.add(UI.formatAmount(total) + " " + Core.bundle.get("unit.perminute")).color(Color.lightGray).padRight(3);
|
||||
if(++i[0] % 3 == 0){
|
||||
t.row();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(t.getChildren().any()){
|
||||
c.add(name).left().row();
|
||||
c.add(t).padLeft(10f).left().row();
|
||||
}
|
||||
};
|
||||
|
||||
c.defaults().padBottom(5);
|
||||
|
||||
c.add(Core.bundle.get("sectors.time") + " [accent]" + sector.save.getPlayTime()).left().row();
|
||||
|
|
@ -655,14 +652,14 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
|||
}
|
||||
|
||||
//production
|
||||
display.get(sector.info.production, "@sectors.production");
|
||||
displayItems(c, sector.getProductionScale(), sector.info.production, "@sectors.production");
|
||||
|
||||
//export
|
||||
display.get(sector.info.export, "@sectors.export");
|
||||
displayItems(c, sector.getProductionScale(), sector.info.export, "@sectors.export");
|
||||
|
||||
//import
|
||||
if(sector.hasBase()){
|
||||
display.get(sector.info.importStats(), "@sectors.import");
|
||||
displayItems(c, 1f, sector.info.importStats(), "@sectors.import");
|
||||
}
|
||||
|
||||
ItemSeq items = sector.items();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue