tagtagtagtag

This commit is contained in:
sharlotte
2021-09-20 14:04:00 +09:00
parent 82f77ed6ee
commit b1fd7af6c5

View File

@@ -24,7 +24,6 @@ import mindustry.entities.units.*;
import mindustry.game.*; import mindustry.game.*;
import mindustry.gen.*; import mindustry.gen.*;
import mindustry.graphics.*; import mindustry.graphics.*;
import mindustry.input.*;
import mindustry.logic.Ranged; import mindustry.logic.Ranged;
import mindustry.type.*; import mindustry.type.*;
import mindustry.ui.*; import mindustry.ui.*;
@@ -40,8 +39,6 @@ import mindustry.world.blocks.production.*;
import mindustry.world.blocks.storage.*; import mindustry.world.blocks.storage.*;
import mindustry.world.blocks.units.*; import mindustry.world.blocks.units.*;
import java.util.regex.Pattern;
import static UnitInfo.SVars.*; import static UnitInfo.SVars.*;
import static arc.Core.*; import static arc.Core.*;
import static mindustry.Vars.*; import static mindustry.Vars.*;
@@ -56,11 +53,7 @@ public class HudUi {
Table itemTable = new Table(); Table itemTable = new Table();
Table waveInfoTable = new Table(); Table waveInfoTable = new Table();
Table schemListTable = new Table(); Table schemListTable = new Table();
Table notifs = new Table(); float waveScrollPos, itemScrollPos, weaponScrollPos, schemScrollPos, tagScrollPos;
float waveScrollPos;
float itemScrollPos;
float weaponScrollPos;
float schemScrollPos;
Teamc shotTarget; Teamc shotTarget;
Teamc lockedTarget; Teamc lockedTarget;
@@ -69,6 +62,8 @@ public class HudUi {
boolean waveShown, schemShown; boolean waveShown, schemShown;
private Schematic firstSchematic; private Schematic firstSchematic;
private Seq<String> selectedTags = new Seq<>();
private Runnable rebuildList = () -> {};
float a; float a;
int uiIndex = 0; int uiIndex = 0;
@@ -86,6 +81,7 @@ public class HudUi {
public final Rect scissor = new Rect(); public final Rect scissor = new Rect();
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public <T extends Teamc> T getTarget(){ public <T extends Teamc> T getTarget(){
if(locked && lockedTarget != null) { if(locked && lockedTarget != null) {
@@ -255,52 +251,63 @@ public class HudUi {
}); });
} }
public void addSchemTable() { public void setSchemTable() {
schemListTable = new Table(table -> { schemListTable = new Table(table -> {
table.right(); table.right();
table.button("Schemtic List", Icon.downOpen, Styles.squareTogglet, () -> { table.button("Schemtic List", Icon.downOpen, Styles.squareTogglet, () -> {
schemShown = !schemShown; schemShown = !schemShown;
rebuildList(); setSchemTable();
}).width(160f).height(60f) }).width(160f).height(60f).checked(b -> {
.checked(b -> {
Image image = (Image)b.getCells().first().get(); Image image = (Image)b.getCells().first().get();
image.setDrawable(schemShown ? Icon.upOpen : Icon.downOpen); image.setDrawable(schemShown ? Icon.upOpen : Icon.downOpen);
return schemShown; return schemShown;
}).row(); }).row();
table.collapser(t -> { table.collapser(t -> {
t.background(Styles.black8); t.background(Styles.black8).defaults().maxHeight(72 * 8f).maxWidth(160f);
notifs = t; rebuildList = () -> {
rebuildList(); t.clearChildren();
}, true, () -> schemShown); ScrollPane pane1 = t.pane(Styles.nonePane, p -> {
p.left().defaults().pad(2).height(42f);
});
Table table = (Table) scene.find("minimap/position");
table.row();
table.add(schemListTable);
}
public void rebuildList() {
if(notifs == null) return;
notifs.clear();
notifs.defaults().maxHeight(72 * 8f);
ScrollPane pane = notifs.pane(Styles.nonePane, p -> {
firstSchematic = null;
for(Schematic s : schematics.all()){
//make sure *tags* fit
Seq<String> seq = null;
try { try {
seq = (Seq<String>) SUtils.invoke(ui.schematics, "selectedTags"); for(String tag : (Seq<String>)SUtils.invoke(ui.schematics, "tags")){
p.button(tag, Styles.togglet, () -> {
if(selectedTags.contains(tag)){
selectedTags.remove(tag);
}else{
selectedTags.add(tag);
}
rebuildList.run();
}).checked(selectedTags.contains(tag)).with(c -> c.getLabel().setWrap(false));
}
} catch (IllegalAccessException | NoSuchFieldException e) { } catch (IllegalAccessException | NoSuchFieldException e) {
e.printStackTrace(); e.printStackTrace();
} }
if(seq != null && seq.any() && !s.labels.containsAll(seq)) continue; }).fillX().height(42f).get();
pane1.update(() -> {
Element result = scene.hit(input.mouseX(), input.mouseY(), true);
if(pane1.hasScroll() && (result == null || !result.isDescendantOf(pane1)))
scene.setScrollFocus(null);
tagScrollPos = pane1.getScrollY();
});
pane1.setOverscroll(false, false);
pane1.setScrollingDisabled(false, true);
pane1.setScrollYForce(tagScrollPos);
t.row();
ScrollPane pane = t.pane(Styles.nonePane, p -> {
p.table().update(tt -> {
tt.clear();
firstSchematic = null;
for(Schematic s : schematics.all()){
if(selectedTags.any() && !s.labels.containsAll(selectedTags)) continue;
if(firstSchematic == null) firstSchematic = s; if(firstSchematic == null) firstSchematic = s;
Button[] sel = {null}; Button[] sel = {null};
sel[0] = p.button(b -> { sel[0] = tt.button(b -> {
b.top(); b.top();
b.margin(0f); b.margin(0f);
b.stack(new SchematicsDialog.SchematicImage(s).setScaling(Scaling.fit), new Table(n -> { b.stack(new SchematicsDialog.SchematicImage(s).setScaling(Scaling.fit), new Table(n -> {
@@ -329,12 +336,13 @@ public class HudUi {
}).pad(4).style(Styles.cleari).get(); }).pad(4).style(Styles.cleari).get();
sel[0].getStyle().up = Tex.pane; sel[0].getStyle().up = Tex.pane;
p.row(); tt.row();
} }
if(firstSchematic == null){ if(firstSchematic == null){
p.add("@none"); tt.add("@none");
} }
});
}).grow().get(); }).grow().get();
pane.update(() -> { pane.update(() -> {
@@ -347,6 +355,18 @@ public class HudUi {
pane.setOverscroll(false, false); pane.setOverscroll(false, false);
pane.setScrollingDisabled(true, false); pane.setScrollingDisabled(true, false);
pane.setScrollYForce(schemScrollPos); pane.setScrollYForce(schemScrollPos);
};
rebuildList.run();
}, true, () -> schemShown);
});
}
public void addSchemTable() {
setSchemTable();
Table table = (Table) scene.find("minimap/position");
table.row();
table.add(schemListTable);
} }
public void addWaveInfoTable() { public void addWaveInfoTable() {