mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-10 12:09:27 +02:00
ui clean up
This commit is contained in:
@@ -84,8 +84,8 @@ window.unit.name = Unit Display
|
|||||||
window.wave.name = Wave Display
|
window.wave.name = Wave Display
|
||||||
window.core.name = Core Display
|
window.core.name = Core Display
|
||||||
window.player.name = Player Display
|
window.player.name = Player Display
|
||||||
window.tool.name = Tool Display
|
window.tool.name = Tool Display [red](WIP)[]
|
||||||
window.editor.name = Map Editor Display
|
window.editor.name = Map Editor Display [red](WIP)[]
|
||||||
|
|
||||||
#Other
|
#Other
|
||||||
default-bar = default bar
|
default-bar = default bar
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ public class SUtils {
|
|||||||
public static <T extends Teamc> T getTarget(){
|
public static <T extends Teamc> T getTarget(){
|
||||||
if(locked && target != null) {
|
if(locked && target != null) {
|
||||||
if(settings.getBool("deadTarget") && !Groups.all.contains(e -> e == target)) {
|
if(settings.getBool("deadTarget") && !Groups.all.contains(e -> e == target)) {
|
||||||
target = null;
|
target = player.unit();
|
||||||
locked = false;
|
locked = false;
|
||||||
}
|
}
|
||||||
else return (T) target; //if there is locked target, return it first.
|
else return (T) target; //if there is locked target, return it first.
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import mindustry.gen.Teamc;
|
|||||||
import static arc.Core.atlas;
|
import static arc.Core.atlas;
|
||||||
|
|
||||||
public class SVars {
|
public class SVars {
|
||||||
public static HudUi hud = new HudUi();
|
|
||||||
public static TextureRegion clear = atlas.find("clear");
|
public static TextureRegion clear = atlas.find("clear");
|
||||||
public static TextureRegion error = atlas.find("error");
|
public static TextureRegion error = atlas.find("error");
|
||||||
public static RangeShader turretRange;
|
public static RangeShader turretRange;
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
package unitinfo.core;
|
package unitinfo.core;
|
||||||
|
|
||||||
|
import arc.input.KeyCode;
|
||||||
|
import arc.scene.ui.layout.Table;
|
||||||
import unitinfo.shaders.*;
|
import unitinfo.shaders.*;
|
||||||
import unitinfo.ui.*;
|
import unitinfo.ui.*;
|
||||||
import unitinfo.ui.draws.OverDraws;
|
import unitinfo.ui.draws.OverDraws;
|
||||||
@@ -38,13 +40,14 @@ public class Main extends Mod {
|
|||||||
});
|
});
|
||||||
|
|
||||||
Events.run(Trigger.update, () -> {
|
Events.run(Trigger.update, () -> {
|
||||||
|
target = getTarget();
|
||||||
|
|
||||||
for (Window window : windows) {
|
for (Window window : windows) {
|
||||||
if(window instanceof Updatable u) u.update();
|
if(window instanceof Updatable u) u.update();
|
||||||
}
|
}
|
||||||
});
|
if((input.keyDown(KeyCode.shiftRight) || input.keyDown(KeyCode.shiftLeft))) {
|
||||||
|
if(input.keyTap(KeyCode.r)) lockTarget();
|
||||||
Events.on(ContentInitEvent.class, e -> {
|
}
|
||||||
Windows.load();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Events.on(ClientLoadEvent.class, e -> {
|
Events.on(ClientLoadEvent.class, e -> {
|
||||||
@@ -52,11 +55,6 @@ public class Main extends Mod {
|
|||||||
SettingS.init();
|
SettingS.init();
|
||||||
WindowManager.init();
|
WindowManager.init();
|
||||||
OverDraws.init();
|
OverDraws.init();
|
||||||
|
|
||||||
hud = new HudUi();
|
|
||||||
hud.addWaveInfoTable();
|
|
||||||
hud.addSchemTable();
|
|
||||||
hud.setEvents();
|
|
||||||
OverDrawer.setEvent();
|
OverDrawer.setEvent();
|
||||||
|
|
||||||
Seq.with(scene.root,
|
Seq.with(scene.root,
|
||||||
@@ -66,7 +64,16 @@ public class Main extends Mod {
|
|||||||
ui.planet, ui.research, ui.mods, ui.schematics, ui.logic
|
ui.planet, ui.research, ui.mods, ui.schematics, ui.logic
|
||||||
).each(dialog-> dialog.addChild(new ElementDisplay(dialog)));
|
).each(dialog-> dialog.addChild(new ElementDisplay(dialog)));
|
||||||
|
|
||||||
|
Table table = ((Table) scene.find("minimap/position")).row();
|
||||||
|
table.add(new SchemDisplay());
|
||||||
|
new WaveInfoDisplay().addWaveInfoTable();
|
||||||
|
|
||||||
if(jsonGen) ContentJSON.save();
|
if(jsonGen) ContentJSON.save();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void lockTarget() {
|
||||||
|
if(target==getTarget()) locked = !locked;
|
||||||
|
target = getTarget();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,17 +25,26 @@ import static arc.Core.*;
|
|||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
import static mindustry.Vars.ui;
|
import static mindustry.Vars.ui;
|
||||||
|
|
||||||
public class SchemDisplay extends Table {
|
public class SchemDisplay extends Table implements Updatable {
|
||||||
static float schemScrollPos, tagScrollPos;
|
static float schemScrollPos, tagScrollPos;
|
||||||
static boolean schemShown;
|
static boolean schemShown;
|
||||||
static Schematic firstSchematic;
|
static Schematic firstSchematic;
|
||||||
static final Seq<String> selectedTags = new Seq<>();
|
static final Seq<String> selectedTags = new Seq<>();
|
||||||
static Runnable rebuildList = () -> {};
|
static Runnable rebuildList = () -> {};
|
||||||
|
float heat;
|
||||||
|
|
||||||
public SchemDisplay() {
|
public SchemDisplay() {
|
||||||
setSchemTable();
|
setSchemTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update() {
|
||||||
|
heat += Time.delta;
|
||||||
|
if(heat>=60f) {
|
||||||
|
heat = 0;
|
||||||
|
setSchemTable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setSchemTable() {
|
public void setSchemTable() {
|
||||||
clear();
|
clear();
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
package unitinfo.core;
|
package unitinfo.ui;
|
||||||
|
|
||||||
import unitinfo.ui.SchemDisplay;
|
|
||||||
import arc.*;
|
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.game.*;
|
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.Pal;
|
import mindustry.graphics.Pal;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
@@ -14,27 +11,8 @@ import static unitinfo.SVars.*;
|
|||||||
import static arc.Core.*;
|
import static arc.Core.*;
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class HudUi {
|
public class WaveInfoDisplay {
|
||||||
public SchemDisplay schemTable;
|
|
||||||
public boolean waveShown;
|
public boolean waveShown;
|
||||||
float heat = 0;
|
|
||||||
|
|
||||||
public void setEvents() {
|
|
||||||
Events.run(EventType.Trigger.update, ()->{
|
|
||||||
target = getTarget();
|
|
||||||
heat += Time.delta;
|
|
||||||
if(heat > 60) {
|
|
||||||
heat = 0;
|
|
||||||
schemTable.setSchemTable();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addSchemTable() {
|
|
||||||
Table table = ((Table) scene.find("minimap/position")).row();
|
|
||||||
schemTable = new SchemDisplay();
|
|
||||||
table.add(schemTable);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addWaveInfoTable() {
|
public void addWaveInfoTable() {
|
||||||
Table waveInfoTable = new Table(Tex.buttonEdge4, table -> {
|
Table waveInfoTable = new Table(Tex.buttonEdge4, table -> {
|
||||||
@@ -8,7 +8,6 @@ import arc.graphics.Color;
|
|||||||
import arc.math.Mathf;
|
import arc.math.Mathf;
|
||||||
import arc.math.geom.Vec2;
|
import arc.math.geom.Vec2;
|
||||||
import arc.scene.event.HandCursorListener;
|
import arc.scene.event.HandCursorListener;
|
||||||
import arc.scene.style.*;
|
|
||||||
import arc.scene.ui.*;
|
import arc.scene.ui.*;
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
@@ -29,8 +28,9 @@ import static mindustry.Vars.*;
|
|||||||
|
|
||||||
public class CoreDisplay extends Window implements Updatable {
|
public class CoreDisplay extends Window implements Updatable {
|
||||||
Vec2 scrollPos = new Vec2(0, 0);
|
Vec2 scrollPos = new Vec2(0, 0);
|
||||||
ObjectMap<Team, ItemData> itemData = new ObjectMap<>();
|
Table window;
|
||||||
float heat;
|
float heat;
|
||||||
|
ObjectMap<Team, ItemData> itemData = new ObjectMap<>();
|
||||||
|
|
||||||
public CoreDisplay() {
|
public CoreDisplay() {
|
||||||
super(Icon.list, "core");
|
super(Icon.list, "core");
|
||||||
@@ -39,10 +39,11 @@ public class CoreDisplay extends Window implements Updatable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(Table table) {
|
public void build(Table table) {
|
||||||
|
window = table;
|
||||||
scrollPos = new Vec2(0, 0);
|
scrollPos = new Vec2(0, 0);
|
||||||
|
|
||||||
table.background(Styles.black8).top();
|
table.background(Styles.black8).top();
|
||||||
table.add(new OverScrollPane(rebuild(), Styles.nonePane, scrollPos).disableScroll(true, false)).name("core-pane");
|
table.add(new OverScrollPane(rebuild(), Styles.nonePane, scrollPos).disableScroll(true, false)).grow().name("core-pane");
|
||||||
Events.on(EventType.WorldLoadEvent.class, e -> resetUsed());
|
Events.on(EventType.WorldLoadEvent.class, e -> resetUsed());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,13 +61,19 @@ public class CoreDisplay extends Window implements Updatable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Table rebuild() {
|
Table rebuild() {
|
||||||
return new Table(table -> {
|
return new Table(table -> {
|
||||||
|
table.top();
|
||||||
for(Team team : getTeams()) {
|
for(Team team : getTeams()) {
|
||||||
table.add(setTable(team).background(((NinePatchDrawable)Tex.underline2).tint(team.color))).row();
|
table.table(row-> {
|
||||||
|
row.center();
|
||||||
|
row.add(setTable(team)).margin(8f).row();
|
||||||
|
row.image().height(4f).color(team.color).growX();
|
||||||
|
}).growX().row();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public Seq<Team> getTeams(){
|
public Seq<Team> getTeams(){
|
||||||
return Seq.with(Team.all).filter(Team::active);
|
return Seq.with(Team.all).filter(Team::active);
|
||||||
}
|
}
|
||||||
@@ -80,6 +87,7 @@ public class CoreDisplay extends Window implements Updatable {
|
|||||||
public Table setTable(Team team){
|
public Table setTable(Team team){
|
||||||
return new Table(table -> {
|
return new Table(table -> {
|
||||||
table.add(team.name).color(team.color).row();
|
table.add(team.name).color(team.color).row();
|
||||||
|
int max = Math.max(1, Math.round(window.getWidth()/2/60));
|
||||||
table.table(coretable -> {
|
table.table(coretable -> {
|
||||||
int row = 0;
|
int row = 0;
|
||||||
|
|
||||||
@@ -115,7 +123,9 @@ public class CoreDisplay extends Window implements Updatable {
|
|||||||
label.setFontScale(0.75f);
|
label.setFontScale(0.75f);
|
||||||
tt.add(label);
|
tt.add(label);
|
||||||
}).padTop(2).padLeft(4).padRight(4);
|
}).padTop(2).padLeft(4).padRight(4);
|
||||||
if(++row % 5 == 0) coretable.row();
|
if(row++ % max == max-1){
|
||||||
|
coretable.row();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}).row();
|
}).row();
|
||||||
|
|
||||||
@@ -140,7 +150,9 @@ public class CoreDisplay extends Window implements Updatable {
|
|||||||
ttt.add(label).bottom().right().padTop(16f);
|
ttt.add(label).bottom().right().padTop(16f);
|
||||||
ttt.pack();
|
ttt.pack();
|
||||||
})).padRight(3).left();
|
})).padRight(3).left();
|
||||||
if(++row % 5 == 0) itemTable.row();
|
if(row++ % max == max-1){
|
||||||
|
itemTable.row();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}).row();
|
}).row();
|
||||||
|
|
||||||
@@ -154,7 +166,9 @@ public class CoreDisplay extends Window implements Updatable {
|
|||||||
tt.image(unit.uiIcon).size(iconSmall).padRight(3).tooltip(ttt -> ttt.background(Styles.black6).add(unit.localizedName).style(Styles.outlineLabel).margin(2f));
|
tt.image(unit.uiIcon).size(iconSmall).padRight(3).tooltip(ttt -> ttt.background(Styles.black6).add(unit.localizedName).style(Styles.outlineLabel).margin(2f));
|
||||||
tt.add(UI.formatAmount(Groups.unit.count(u -> u.team == team && u.type == unit))).padRight(3).minWidth(5 * 8f).left();
|
tt.add(UI.formatAmount(Groups.unit.count(u -> u.team == team && u.type == unit))).padRight(3).minWidth(5 * 8f).left();
|
||||||
});
|
});
|
||||||
if(++row % 5 == 0) unitTable.row();
|
if(row++ % max == max-1){
|
||||||
|
unitTable.row();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,27 +1,17 @@
|
|||||||
package unitinfo.ui.windows;
|
package unitinfo.ui.windows;
|
||||||
|
|
||||||
import unitinfo.core.BarInfo;
|
import unitinfo.core.*;
|
||||||
import unitinfo.ui.SBar;
|
import unitinfo.ui.*;
|
||||||
import unitinfo.ui.SIcons;
|
|
||||||
import unitinfo.ui.Updatable;
|
|
||||||
import arc.Core;
|
|
||||||
import arc.func.Prov;
|
|
||||||
import arc.graphics.Color;
|
import arc.graphics.Color;
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.input.KeyCode;
|
import arc.math.geom.*;
|
||||||
import arc.math.Mathf;
|
|
||||||
import arc.math.geom.Rect;
|
|
||||||
import arc.math.geom.Vec2;
|
|
||||||
import arc.math.geom.Vec3;
|
|
||||||
import arc.scene.Element;
|
|
||||||
import arc.scene.style.*;
|
import arc.scene.style.*;
|
||||||
import arc.scene.ui.*;
|
import arc.scene.ui.*;
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.struct.Bits;
|
import arc.struct.Bits;
|
||||||
import arc.struct.Seq;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.Vars;
|
import mindustry.Vars;
|
||||||
import mindustry.ai.formations.FormationPattern;
|
|
||||||
import mindustry.core.UI;
|
import mindustry.core.UI;
|
||||||
import mindustry.entities.units.WeaponMount;
|
import mindustry.entities.units.WeaponMount;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
@@ -38,167 +28,101 @@ import mindustry.world.blocks.power.*;
|
|||||||
|
|
||||||
import static unitinfo.SVars.*;
|
import static unitinfo.SVars.*;
|
||||||
import static unitinfo.SUtils.*;
|
import static unitinfo.SUtils.*;
|
||||||
import static arc.Core.*;
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class UnitDisplay extends Window implements Updatable {
|
class UnitDisplay extends Window {
|
||||||
static Seq<Color> lastColors = Seq.with(Color.clear,Color.clear,Color.clear,Color.clear,Color.clear,Color.clear);
|
final Seq<Color> lastColors = Seq.with(Color.clear,Color.clear,Color.clear,Color.clear,Color.clear,Color.clear);
|
||||||
static final Rect scissor = new Rect();
|
final Rect scissor = new Rect();
|
||||||
float scrollPos;
|
Vec2 scrollPos;
|
||||||
|
|
||||||
public UnitDisplay() {
|
public UnitDisplay() {
|
||||||
super(Icon.units, "unit");
|
super(Icon.units, "unit");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void build(Table table) {
|
|
||||||
table.top().background(Styles.black8);
|
|
||||||
|
|
||||||
//TODO: add new UnitInfoDisplay(), new WeaponDisplay();
|
//TODO: add new UnitInfoDisplay(), new WeaponDisplay();
|
||||||
table.table(Tex.underline2, tt -> {
|
@Override
|
||||||
tt.stack(
|
protected void build(Table table) {
|
||||||
new Table(ttt -> {
|
scrollPos = new Vec2(0,0);
|
||||||
Prov<TextureRegionDrawable> reg = () -> {
|
|
||||||
|
table.top().background(Styles.black8);
|
||||||
|
table.table(tt -> {
|
||||||
|
tt.center();
|
||||||
|
Image image = new Image() {
|
||||||
|
@Override
|
||||||
|
public void draw() {
|
||||||
|
super.draw();
|
||||||
|
|
||||||
|
int offset = 8;
|
||||||
|
Draw.color(locked?Pal.accent:Pal.gray);
|
||||||
|
Draw.alpha(parentAlpha);
|
||||||
|
Lines.stroke(Scl.scl(3f));
|
||||||
|
Lines.rect(x-offset/2f, y-offset/2f, width+offset, height+offset);
|
||||||
|
Draw.reset();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
image.update(()->{
|
||||||
TextureRegion region = clear;
|
TextureRegion region = clear;
|
||||||
Teamc target = getTarget();
|
|
||||||
if (target instanceof Unit u && u.type != null) region = u.type.uiIcon;
|
if (target instanceof Unit u && u.type != null) region = u.type.uiIcon;
|
||||||
else if (target instanceof Building b) {
|
else if (target instanceof Building b) {
|
||||||
if (target instanceof ConstructBlock.ConstructBuild cb)
|
if (target instanceof ConstructBlock.ConstructBuild cb) region = cb.current.uiIcon;
|
||||||
region = cb.current.uiIcon;
|
|
||||||
else if (b.block != null) region = b.block.uiIcon;
|
else if (b.block != null) region = b.block.uiIcon;
|
||||||
}
|
}
|
||||||
return new TextureRegionDrawable(region);
|
image.setDrawable(region);
|
||||||
};
|
});
|
||||||
Drawable img = reg.get();
|
image.clicked(Main::lockTarget);
|
||||||
ImageButton imagebt = new ImageButton(img, img);
|
|
||||||
|
|
||||||
imagebt.hovered(() -> {
|
|
||||||
Time.run(60 * 2, () -> {
|
|
||||||
if (imagebt.isOver()) lockTarget();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
imagebt.clicked(() -> {
|
|
||||||
Teamc target = getTarget();
|
|
||||||
if (target instanceof Unit u && u.type != null) ui.content.show(u.type);
|
|
||||||
else if (target instanceof Building b && b.block != null) ui.content.show(b.block);
|
|
||||||
});
|
|
||||||
ttt.add(imagebt).update((i) -> {
|
|
||||||
i.getStyle().imageUp = reg.get().tint(Tmp.c1.set(locked ? Color.red.cpy().shiftHue(2 * Time.time) : Color.white));
|
|
||||||
i.getStyle().imageDown = reg.get().tint(Tmp.c1.mul(Color.darkGray));
|
|
||||||
i.layout();
|
|
||||||
}).size(4 * 8f);
|
|
||||||
}),
|
|
||||||
new Table(ttt -> {
|
|
||||||
ttt.stack(
|
|
||||||
new Table(temp -> {
|
|
||||||
temp.image(new ScaledNinePatchDrawable(new NinePatch(Icon.defenseSmall.getRegion()), 1));
|
|
||||||
temp.visibility = () -> getTarget() instanceof Unit;
|
|
||||||
}),
|
|
||||||
new Table(temp -> {
|
|
||||||
Label label = new Label(() -> (getTarget() instanceof Unit u && u.type != null ? (int) u.type.armor + "" : ""));
|
|
||||||
label.setColor(Pal.surge);
|
|
||||||
temp.add(label).center();
|
|
||||||
temp.pack();
|
|
||||||
})
|
|
||||||
).padLeft(2 * 8f).padBottom(2 * 8f);
|
|
||||||
})
|
|
||||||
);
|
|
||||||
|
|
||||||
|
tt.add(image).size(iconMed).padRight(12f);
|
||||||
tt.label(() -> {
|
tt.label(() -> {
|
||||||
String name = "";
|
if (target instanceof Unit u && u.type != null) return u.type.localizedName;
|
||||||
Teamc target = getTarget();
|
|
||||||
if (target instanceof Unit u && u.type != null)
|
|
||||||
name = u.type.localizedName;
|
|
||||||
if (target instanceof Building b && b.block != null) {
|
if (target instanceof Building b && b.block != null) {
|
||||||
if (target instanceof ConstructBlock.ConstructBuild cb)
|
if (target instanceof ConstructBlock.ConstructBuild cb) return cb.current.localizedName;
|
||||||
name = cb.current.localizedName;
|
return b.block.localizedName;
|
||||||
else name = b.block.localizedName;
|
|
||||||
}
|
}
|
||||||
return "[accent]" + (name.length() > 13 ? name.substring(0, 13) + "..." : name) + "[]";
|
return "";
|
||||||
});
|
}).color(Pal.accent);
|
||||||
|
}).tooltip((to -> {
|
||||||
tt.addListener(new Tooltip(to -> {
|
|
||||||
Teamc target = getTarget();
|
|
||||||
|
|
||||||
to.background(Styles.black6);
|
to.background(Styles.black6);
|
||||||
|
|
||||||
to.table(Tex.underline2, tool2 -> {
|
|
||||||
tool2.label(() -> {
|
|
||||||
if (target instanceof Unit u) return u.type.localizedName;
|
|
||||||
else if (target instanceof Building b) return b.block.localizedName;
|
|
||||||
else return "";
|
|
||||||
});
|
|
||||||
}).row();
|
|
||||||
to.label(() -> target instanceof Unit u && u.isPlayer() ? u.getPlayer().name() : "AI").row();
|
to.label(() -> target instanceof Unit u && u.isPlayer() ? u.getPlayer().name() : "AI").row();
|
||||||
to.label(() -> target == null
|
to.label(() -> target == null ? "(" + 0 + ", " + 0 + ")" : "(" + Strings.fixed(target.x() / tilesize, 2) + ", " + Strings.fixed(target.y() / tilesize, 2) + ")").row();
|
||||||
? "(" + 0 + ", " + 0 + ")"
|
to.label(() -> target instanceof Unit u ? "[accent]"+ Strings.fixed(u.armor, 0) + "[] Armor" : "");
|
||||||
: "(" + Strings.fixed(target.x() / tilesize, 2) + ", " + Strings.fixed(target.y() / tilesize, 2) + ")").row();
|
})).margin(12f).row();
|
||||||
}));
|
table.image().height(4f).color(player.team().color).growX().row();
|
||||||
tt.update(() -> tt.setBackground(((NinePatchDrawable) Tex.underline2).tint(getTarget() == null ? Color.gray : getTarget().team().color)));
|
table.add(new OverScrollPane(new Table(bars -> {
|
||||||
}).row();
|
bars.top();
|
||||||
ScrollPane pane = table.pane(Styles.nonePane, new Table(tt -> {
|
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
addBar(tt, i);
|
int index = i;
|
||||||
tt.row();
|
bars.table(bar -> {
|
||||||
}
|
bar.add(new SBar(
|
||||||
}).left()).top().right().grow().get();
|
() -> BarInfo.strings.get(index),
|
||||||
pane.update(() -> {
|
() -> {
|
||||||
Element result = scene.hit(input.mouseX(), input.mouseY(), true);
|
if (BarInfo.colors.get(index) != Color.clear) lastColors.set(index, BarInfo.colors.get(index));
|
||||||
if(pane.hasScroll() && (result == null || !result.isDescendantOf(pane)))
|
return lastColors.get(index);
|
||||||
scene.setScrollFocus(null);
|
},
|
||||||
scrollPos = pane.getScrollY();
|
() -> BarInfo.numbers.get(index)
|
||||||
});
|
)).height(4 * 8f).growX();
|
||||||
|
bar.add(new Image(){
|
||||||
pane.setOverscroll(false, false);
|
|
||||||
pane.setScrollingDisabled(true, false);
|
|
||||||
pane.setScrollYForce(scrollPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void lockTarget() {
|
|
||||||
locked = !locked;
|
|
||||||
target = locked ? getTarget() : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void showMoving() {
|
|
||||||
Table table = new Table(Styles.black3).margin(4);
|
|
||||||
Vec2 pos = input.mouse();
|
|
||||||
table.update(() -> {
|
|
||||||
if(Vars.state.isMenu()) table.remove();
|
|
||||||
Vec2 vec = Core.camera.project(pos.x, pos.y);
|
|
||||||
table.setPosition(vec.x, vec.y, Align.center);
|
|
||||||
});
|
|
||||||
|
|
||||||
table.add("hello world").style(Styles.defaultLabel);
|
|
||||||
table.pack();
|
|
||||||
}
|
|
||||||
|
|
||||||
float angle = 360;
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void draw() {
|
||||||
if((input.keyDown(KeyCode.shiftRight) || input.keyDown(KeyCode.shiftLeft))) {
|
validate();
|
||||||
if(input.keyTap(KeyCode.f)) {
|
|
||||||
showMoving();
|
|
||||||
}
|
|
||||||
if(input.keyTap(KeyCode.r)) lockTarget();
|
|
||||||
if(input.keyTap(KeyCode.r)) {
|
|
||||||
player.unit().commandNearby(new FormationPattern() {
|
|
||||||
@Override
|
|
||||||
public Vec3 calculateSlotLocation(Vec3 out, int slot) {
|
|
||||||
angle+=0.3f;
|
|
||||||
float radian = angle / 360 * slot/slots * Mathf.degRad;
|
|
||||||
float sizeScaling = 0.25f;
|
|
||||||
float rotateSpeed = 0.01f;
|
|
||||||
|
|
||||||
out.set(Tmp.v1.set(this.spacing * (sizeScaling * 5 * Mathf.cos(2 * radian) + sizeScaling * 2 * Mathf.cos(3 * radian)), this.spacing * (sizeScaling * 2 * Mathf.sin(3 * radian) - sizeScaling * 5 * Mathf.sin(2 * radian))).rotateRad(Time.time * rotateSpeed), 0);
|
Draw.color(Color.white);
|
||||||
return out;
|
Draw.alpha(parentAlpha * color.a);
|
||||||
}
|
TextureRegionDrawable region = new TextureRegionDrawable(getRegions(index));
|
||||||
});
|
region.draw(x + imageX, y + imageY, imageWidth * scaleX, imageHeight * scaleY);
|
||||||
|
Draw.color(BarInfo.colors.get(index));
|
||||||
|
if(ScissorStack.push(scissor.set(x, y, imageWidth * scaleX, imageHeight * scaleY * BarInfo.numbers.get(index)))){
|
||||||
|
region.draw(x, y, imageWidth * scaleX, imageHeight * scaleY);
|
||||||
|
ScissorStack.pop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}).size(iconMed * 0.75f).padLeft(8f);
|
||||||
|
}).growX().row();
|
||||||
|
}
|
||||||
|
}), Styles.nonePane, scrollPos).disableScroll(true, false)).growX().padTop(12f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public TextureRegion getRegions(int i){
|
//do not ask me WHAT THE FUCK IS THIS
|
||||||
Teamc target = getTarget();
|
TextureRegion getRegions(int i){
|
||||||
TextureRegion region = clear;
|
TextureRegion region = clear;
|
||||||
|
|
||||||
if(i == 0){
|
if(i == 0){
|
||||||
@@ -248,49 +172,8 @@ public class UnitDisplay extends Window implements Updatable {
|
|||||||
return region;
|
return region;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addBar(Table table, int i){
|
|
||||||
table.add(new SBar(
|
|
||||||
() -> BarInfo.strings.get(i),
|
|
||||||
() -> {
|
|
||||||
if (BarInfo.colors.get(i) != Color.clear) lastColors.set(i, BarInfo.colors.get(i));
|
|
||||||
return lastColors.get(i);
|
|
||||||
},
|
|
||||||
() -> BarInfo.numbers.get(i)
|
|
||||||
)).height(4 * 8f).growX().left();
|
|
||||||
table.add(new Image(){
|
|
||||||
@Override
|
|
||||||
public void draw() {
|
|
||||||
validate();
|
|
||||||
|
|
||||||
float x = this.x;
|
|
||||||
float y = this.y;
|
|
||||||
float scaleX = this.scaleX;
|
|
||||||
float scaleY = this.scaleY;
|
|
||||||
Draw.color(Color.white);
|
|
||||||
Draw.alpha(parentAlpha * color.a);
|
|
||||||
|
|
||||||
TextureRegionDrawable region = new TextureRegionDrawable(getRegions(i));
|
|
||||||
float rotation = getRotation();
|
|
||||||
if(scaleX != 1 || scaleY != 1 || rotation != 0){
|
|
||||||
region.draw(x + imageX, y + imageY, originX - imageX, originY - imageY,
|
|
||||||
imageWidth, imageHeight, scaleX, scaleY, rotation);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
region.draw(x + imageX, y + imageY, imageWidth * scaleX, imageHeight * scaleY);
|
|
||||||
|
|
||||||
Draw.color(BarInfo.colors.get(i));
|
|
||||||
if(ScissorStack.push(scissor.set(x, y, imageWidth * scaleX, imageHeight * scaleY * BarInfo.numbers.get(i)))){
|
|
||||||
region.draw(x, y, imageWidth * scaleX, imageHeight * scaleY);
|
|
||||||
ScissorStack.pop();
|
|
||||||
}
|
|
||||||
Draw.reset();
|
|
||||||
}
|
|
||||||
}).size(iconMed * 0.75f).left();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static class WeaponDisplay extends Table {
|
static class WeaponDisplay extends Table {
|
||||||
public WeaponDisplay() {
|
WeaponDisplay() {
|
||||||
table().update(tt -> {
|
table().update(tt -> {
|
||||||
tt.clear();
|
tt.clear();
|
||||||
if(getTarget() instanceof Unit u && u.type != null && u.hasWeapons()) {
|
if(getTarget() instanceof Unit u && u.type != null && u.hasWeapons()) {
|
||||||
@@ -344,7 +227,7 @@ public class UnitDisplay extends Window implements Updatable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
static class UnitInfoDisplay extends Table {
|
static class UnitInfoDisplay extends Table {
|
||||||
public UnitInfoDisplay() {
|
UnitInfoDisplay() {
|
||||||
top();
|
top();
|
||||||
float[] count = new float[]{-1};
|
float[] count = new float[]{-1};
|
||||||
table().update(t -> {
|
table().update(t -> {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package unitinfo.ui.windows;
|
package unitinfo.ui.windows;
|
||||||
|
|
||||||
|
import mindustry.game.Team;
|
||||||
import unitinfo.ui.OverScrollPane;
|
import unitinfo.ui.OverScrollPane;
|
||||||
import arc.Events;
|
import arc.Events;
|
||||||
import arc.graphics.Color;
|
import arc.graphics.Color;
|
||||||
@@ -16,14 +17,17 @@ import mindustry.game.SpawnGroup;
|
|||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.Pal;
|
import mindustry.graphics.Pal;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
|
import unitinfo.ui.Updatable;
|
||||||
|
|
||||||
import static arc.Core.*;
|
import static arc.Core.*;
|
||||||
import static arc.Core.settings;
|
import static arc.Core.settings;
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
|
|
||||||
public class WaveDisplay extends Window {
|
public class WaveDisplay extends Window implements Updatable {
|
||||||
static Vec2 scrollPos = new Vec2(0, 0);
|
static Vec2 scrollPos = new Vec2(0, 0);
|
||||||
|
Table window;
|
||||||
|
float heat;
|
||||||
|
|
||||||
public WaveDisplay() {
|
public WaveDisplay() {
|
||||||
super(Icon.waves, "wave");
|
super(Icon.waves, "wave");
|
||||||
@@ -31,10 +35,12 @@ public class WaveDisplay extends Window {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void build(Table table) {
|
public void build(Table table) {
|
||||||
table.background(Styles.black8).top();
|
window = table;
|
||||||
|
|
||||||
|
table.top().background(Styles.black8);
|
||||||
|
|
||||||
ScrollPane pane = new OverScrollPane(rebuild(), Styles.nonePane, scrollPos).disableScroll(true, false);
|
ScrollPane pane = new OverScrollPane(rebuild(), Styles.nonePane, scrollPos).disableScroll(true, false);
|
||||||
table.add(pane);
|
table.add(pane).grow().name("wave-pane");
|
||||||
Events.on(EventType.WorldLoadEvent.class, e -> {
|
Events.on(EventType.WorldLoadEvent.class, e -> {
|
||||||
pane.clearChildren();
|
pane.clearChildren();
|
||||||
pane.setWidget(rebuild());
|
pane.setWidget(rebuild());
|
||||||
@@ -45,6 +51,16 @@ public class WaveDisplay extends Window {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update() {
|
||||||
|
heat += Time.delta;
|
||||||
|
if(heat >= 60f) {
|
||||||
|
heat = 0f;
|
||||||
|
ScrollPane pane = find("wave-pane");
|
||||||
|
pane.setWidget(rebuild());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ObjectIntMap<SpawnGroup> getWaveGroup(int index) {
|
public ObjectIntMap<SpawnGroup> getWaveGroup(int index) {
|
||||||
ObjectIntMap<SpawnGroup> groups = new ObjectIntMap<>();
|
ObjectIntMap<SpawnGroup> groups = new ObjectIntMap<>();
|
||||||
for (SpawnGroup group : state.rules.spawns) {
|
for (SpawnGroup group : state.rules.spawns) {
|
||||||
@@ -66,36 +82,40 @@ public class WaveDisplay extends Window {
|
|||||||
return groupsTmp;
|
return groupsTmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Table rebuild(){
|
Table rebuild(){
|
||||||
return new Table(table -> {
|
return new Table(table -> {
|
||||||
table.touchable = Touchable.enabled;
|
table.touchable = Touchable.enabled;
|
||||||
for (int i = settings.getBool("pastwave") ? 1 : state.wave;
|
table.table(body->{
|
||||||
i <= Math.min(state.wave + settings.getInt("wavemax"), (state.isCampaign() && state.rules.winWave > 0 ? state.rules.winWave : Integer.MAX_VALUE));
|
body.center();
|
||||||
i++) {
|
for (int i = settings.getBool("pastwave") ? 1 : state.wave; i <= Math.min(state.wave + settings.getInt("wavemax"), (state.isCampaign() && state.rules.winWave > 0 ? state.rules.winWave : Integer.MAX_VALUE)); i++) {
|
||||||
final int index = i;
|
final int index = i;
|
||||||
|
|
||||||
table.table(waveRow -> {
|
body.table(waveRow -> {
|
||||||
waveRow.background(Tex.underline);
|
waveRow.left();
|
||||||
|
|
||||||
waveRow.add(index+"").update(label -> {
|
waveRow.add(index+"").update(label -> {
|
||||||
Color color = Pal.accent;
|
Color color = Pal.accent;
|
||||||
if (state.wave == index) color = Color.red;
|
if (state.wave == index) color = Color.red;
|
||||||
else if (state.wave - 1 == index && state.enemies > 0) color = Color.red.cpy().shiftHue(Time.time);
|
else if (state.wave - 1 == index && state.enemies > 0) color = Color.red.cpy().shiftHue(Time.time);
|
||||||
|
|
||||||
label.setColor(label.color.cpy().lerp(color, Time.delta));
|
label.setColor(color);
|
||||||
});
|
});
|
||||||
waveRow.table(t -> {
|
waveRow.table(unitTable -> {
|
||||||
|
unitTable.center();
|
||||||
|
|
||||||
if (state.rules.spawns.find(g -> g.getSpawned(index-1) > 0) == null) {
|
if (state.rules.spawns.find(g -> g.getSpawned(index-1) > 0) == null) {
|
||||||
if (settings.getBool("emptywave")) t.add(bundle.get("empty")).center();
|
if (settings.getBool("emptywave")) unitTable.add(bundle.get("empty"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjectIntMap<SpawnGroup> groups = getWaveGroup(index-1);
|
ObjectIntMap<SpawnGroup> groups = getWaveGroup(index-1);
|
||||||
|
|
||||||
int row = 0;
|
int row = 0;
|
||||||
|
int max = Math.max(1, Math.round(window.getWidth()/2/8));
|
||||||
for (SpawnGroup group : groups.keys()) {
|
for (SpawnGroup group : groups.keys()) {
|
||||||
int spawners = state.rules.waveTeam.cores().size + (group.type.flying ? spawner.countFlyerSpawns() : spawner.countGroundSpawns());
|
int spawners = state.rules.waveTeam.cores().size + (group.type.flying ? spawner.countFlyerSpawns() : spawner.countGroundSpawns());
|
||||||
int amount = groups.get(group);
|
int amount = groups.get(group);
|
||||||
t.stack(
|
unitTable.stack(
|
||||||
new Table(ttt -> {
|
new Table(ttt -> {
|
||||||
ttt.center();
|
ttt.center();
|
||||||
ttt.image(group.type.uiIcon).size(iconMed);
|
ttt.image(group.type.uiIcon).size(iconMed);
|
||||||
@@ -125,12 +145,15 @@ public class WaveDisplay extends Window {
|
|||||||
if (group.effect != null && group.effect != StatusEffects.none)
|
if (group.effect != null && group.effect != StatusEffects.none)
|
||||||
to.add(bundle.get("shar-stat.waveStatus") + group.effect.emoji() + "[stat]" + group.effect.localizedName).row();
|
to.add(bundle.get("shar-stat.waveStatus") + group.effect.emoji() + "[stat]" + group.effect.localizedName).row();
|
||||||
}));
|
}));
|
||||||
if (++row % 4 == 0) t.row();
|
if(row++ % max == max-1){
|
||||||
|
unitTable.row();
|
||||||
}
|
}
|
||||||
});
|
|
||||||
});
|
|
||||||
table.row();
|
|
||||||
}
|
}
|
||||||
|
}).growX().margin(12f);
|
||||||
|
}).growX().row();
|
||||||
|
body.image().height(4f).color(Pal.gray).growX().row();
|
||||||
|
}
|
||||||
|
}).grow().margin(40f);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user