mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-10 03:59:26 +02:00
display enemy units
This commit is contained in:
@@ -3,9 +3,12 @@ package UnitInfo.ui;
|
|||||||
import arc.scene.ui.layout.Table;
|
import arc.scene.ui.layout.Table;
|
||||||
import arc.struct.ObjectSet;
|
import arc.struct.ObjectSet;
|
||||||
import arc.struct.Seq;
|
import arc.struct.Seq;
|
||||||
|
import mindustry.content.UnitTypes;
|
||||||
import mindustry.core.UI;
|
import mindustry.core.UI;
|
||||||
import mindustry.game.Team;
|
import mindustry.game.Team;
|
||||||
|
import mindustry.gen.Groups;
|
||||||
import mindustry.type.Item;
|
import mindustry.type.Item;
|
||||||
|
import mindustry.type.UnitType;
|
||||||
import mindustry.ui.Styles;
|
import mindustry.ui.Styles;
|
||||||
import mindustry.world.blocks.storage.CoreBlock;
|
import mindustry.world.blocks.storage.CoreBlock;
|
||||||
|
|
||||||
@@ -14,6 +17,7 @@ import static mindustry.Vars.iconSmall;
|
|||||||
|
|
||||||
public class CoresItemsDisplay {
|
public class CoresItemsDisplay {
|
||||||
private final ObjectSet<Item> usedItems = new ObjectSet<>();
|
private final ObjectSet<Item> usedItems = new ObjectSet<>();
|
||||||
|
private final ObjectSet<UnitType> usedUnits = new ObjectSet<>();
|
||||||
private CoreBlock.CoreBuild core;
|
private CoreBlock.CoreBuild core;
|
||||||
public Team[] teams;
|
public Team[] teams;
|
||||||
public Seq<Table> tables = new Seq<>();
|
public Seq<Table> tables = new Seq<>();
|
||||||
@@ -25,42 +29,48 @@ public class CoresItemsDisplay {
|
|||||||
|
|
||||||
public void resetUsed(){
|
public void resetUsed(){
|
||||||
usedItems.clear();
|
usedItems.clear();
|
||||||
|
usedUnits.clear();
|
||||||
tables.each(t->t.background(null));
|
tables.each(t->t.background(null));
|
||||||
}
|
}
|
||||||
|
|
||||||
Seq<Table> rebuild(){
|
void rebuild(){
|
||||||
tables.clear();
|
tables.clear();
|
||||||
for(Team team : teams) {
|
for(Team team : teams) {
|
||||||
tables.add(new Table(t -> {
|
tables.add(new Table(t -> {
|
||||||
t.clear();
|
t.clear();
|
||||||
|
|
||||||
if(usedItems.size > 0){
|
if(usedItems.size > 0 || usedUnits.size > 0){
|
||||||
t.background(Styles.black6);
|
t.background(Styles.black6);
|
||||||
t.margin(4);
|
t.margin(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
t.update(() -> {
|
t.update(() -> {
|
||||||
core = team.core();
|
core = team.core();
|
||||||
|
|
||||||
if(content.items().contains(item -> core != null && core.items.get(item) > 0 && usedItems.add(item))){
|
if(content.items().contains(item -> core != null && core.items.get(item) > 0 && usedItems.add(item)) || content.units().contains(unit -> core != null && Groups.unit.count(u -> u.team == team) > 0 && usedUnits.add(unit))){
|
||||||
rebuild();
|
rebuild();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
for(Item item : content.items()){
|
for(Item item : content.items()){
|
||||||
if(usedItems.contains(item)){
|
if(usedItems.contains(item)){
|
||||||
t.image(item.uiIcon).size(iconSmall).padRight(3).tooltip(tt -> tt.background(Styles.black6).margin(4f).add(item.localizedName).style(Styles.outlineLabel));
|
t.image(item.uiIcon).size(iconSmall).padRight(3).tooltip(tt -> tt.background(Styles.black6).margin(2f).add(item.localizedName).style(Styles.outlineLabel));
|
||||||
t.label(() -> core == null ? "0" : UI.formatAmount(core.items.get(item))).padRight(3).minWidth(52f).left();
|
t.label(() -> core == null ? "0" : UI.formatAmount(core.items.get(item))).padRight(3).minWidth(5 * 8f).left();
|
||||||
|
if(++i % 5 == 0) t.row();
|
||||||
if(++i % 4 == 0){
|
}
|
||||||
t.row();
|
}
|
||||||
}
|
t.row();
|
||||||
|
i = 0;
|
||||||
|
for(UnitType unit : content.units()){
|
||||||
|
if(unit == UnitTypes.block) continue;
|
||||||
|
if(usedUnits.contains(unit)){
|
||||||
|
t.image(unit.uiIcon).size(iconSmall).padRight(3).tooltip(tt -> tt.background(Styles.black6).margin(2f).add(unit.localizedName).style(Styles.outlineLabel));
|
||||||
|
t.label(() -> core == null ? "0" : UI.formatAmount(Groups.unit.count(u -> u.team == team && u.type == unit))).padRight(3).minWidth(5 * 8f).left();
|
||||||
|
if(++i % 5 == 0) t.row();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
return tables;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user