mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-10 12:09:27 +02:00
code clean up
This commit is contained in:
@@ -55,12 +55,11 @@ public class SUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static <T extends Number> String formatNumber(T number){
|
public static <T extends Number> String formatNumber(T number){
|
||||||
if(number instanceof Integer integ) return integ.toString();
|
|
||||||
if(number.longValue() % 10 == 0) return String.valueOf(number.intValue());
|
|
||||||
return formatNumber(number, 1);
|
return formatNumber(number, 1);
|
||||||
}
|
}
|
||||||
public static <T extends Number> String formatNumber(T number, int step){
|
public static <T extends Number> String formatNumber(T number, int step){
|
||||||
if(number.intValue() >= 1000) return UI.formatAmount(number.longValue());
|
if(number.intValue() >= 1000) return UI.formatAmount(number.longValue());
|
||||||
|
if(number instanceof Integer || number.longValue() % 10 == 0) return String.valueOf(number.intValue());
|
||||||
return Strings.fixed(number.floatValue(), step);
|
return Strings.fixed(number.floatValue(), step);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ public class SBar extends Element{
|
|||||||
Floatp fraction;
|
Floatp fraction;
|
||||||
String name = "";
|
String name = "";
|
||||||
float value, lastValue, blink;
|
float value, lastValue, blink;
|
||||||
final Color blinkColor = new Color();
|
Color blinkColor = new Color(), lastColor = new Color();
|
||||||
NinePatchDrawable bar, top;
|
NinePatchDrawable bar, top;
|
||||||
float spriteWidth;
|
float spriteWidth;
|
||||||
|
|
||||||
@@ -31,6 +31,7 @@ public class SBar extends Element{
|
|||||||
this.fraction = ()->fraction;
|
this.fraction = ()->fraction;
|
||||||
this.name = Core.bundle.get(name, name);
|
this.name = Core.bundle.get(name, name);
|
||||||
this.blinkColor.set(color);
|
this.blinkColor.set(color);
|
||||||
|
this.lastColor = color;
|
||||||
lastValue = value = fraction;
|
lastValue = value = fraction;
|
||||||
setColor(color);
|
setColor(color);
|
||||||
init();
|
init();
|
||||||
@@ -48,6 +49,29 @@ public class SBar extends Element{
|
|||||||
try{
|
try{
|
||||||
this.name = name.get();
|
this.name = name.get();
|
||||||
this.blinkColor.set(color.get());
|
this.blinkColor.set(color.get());
|
||||||
|
this.lastColor.set(color.get());
|
||||||
|
setColor(color.get());
|
||||||
|
}catch(Exception e){ //getting the fraction may involve referring to invalid data
|
||||||
|
this.name = "";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
|
||||||
|
//dynamic bar
|
||||||
|
public SBar(Prov<String> name, Prov<Color> color, Prov<Color> lastColor, Floatp fraction){
|
||||||
|
this.fraction = fraction;
|
||||||
|
try{
|
||||||
|
lastValue = value = Mathf.clamp(fraction.get());
|
||||||
|
}catch(Exception e){ //getting the fraction may involve referring to invalid data
|
||||||
|
lastValue = value = 0f;
|
||||||
|
}
|
||||||
|
this.name = name.get();
|
||||||
|
update(() -> {
|
||||||
|
try{
|
||||||
|
this.name = name.get();
|
||||||
|
this.blinkColor.set(color.get());
|
||||||
|
this.lastColor.set(lastColor.get());
|
||||||
setColor(color.get());
|
setColor(color.get());
|
||||||
}catch(Exception e){ //getting the fraction may involve referring to invalid data
|
}catch(Exception e){ //getting the fraction may involve referring to invalid data
|
||||||
this.name = "";
|
this.name = "";
|
||||||
@@ -61,6 +85,7 @@ public class SBar extends Element{
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: clean up
|
||||||
public SBar init(){
|
public SBar init(){
|
||||||
int h = Core.settings.getInt("barstyle");
|
int h = Core.settings.getInt("barstyle");
|
||||||
|
|
||||||
@@ -129,7 +154,7 @@ public class SBar extends Element{
|
|||||||
Draw.colorl(0.1f);
|
Draw.colorl(0.1f);
|
||||||
bar.draw(x, y, width, height);
|
bar.draw(x, y, width, height);
|
||||||
|
|
||||||
Draw.color(Tmp.c1.set(color).mul(Pal.lightishGray), blinkColor, blink);
|
Draw.color(Tmp.c1.set(lastColor).mul(Pal.lightishGray), blinkColor, blink);
|
||||||
float topWidth = width * value;
|
float topWidth = width * value;
|
||||||
if(topWidth > spriteWidth){
|
if(topWidth > spriteWidth){
|
||||||
top.draw(x, y, topWidth, height);
|
top.draw(x, y, topWidth, height);
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
package informatis.ui;
|
package informatis.ui;
|
||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
|
import arc.scene.ui.layout.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
|
||||||
import mindustry.*;
|
import mindustry.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import informatis.ui.window.Window;
|
import informatis.ui.window.*;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class WindowManager {
|
public class WindowManager {
|
||||||
public static Seq<Window> windows = new Seq<>();
|
public static Seq<Window> windows = new Seq<>();
|
||||||
|
|
||||||
public static void init(){
|
public static void init(){
|
||||||
Log.info(windows.size);
|
|
||||||
|
|
||||||
Vars.ui.hudGroup.fill(t -> {
|
Vars.ui.hudGroup.fill(t -> {
|
||||||
t.name = "Windows";
|
t.name = "Windows";
|
||||||
for(Window window : windows){
|
for(Window window : windows){
|
||||||
|
|||||||
@@ -1,28 +1,25 @@
|
|||||||
package informatis.ui.window;
|
package informatis.ui.window;
|
||||||
|
|
||||||
import arc.Events;
|
import arc.*;
|
||||||
import mindustry.game.EventType;
|
import mindustry.game.*;
|
||||||
import informatis.ui.*;
|
import informatis.ui.*;
|
||||||
import arc.Core;
|
import arc.graphics.*;
|
||||||
import arc.graphics.Color;
|
import arc.math.*;
|
||||||
import arc.math.Mathf;
|
import arc.math.geom.*;
|
||||||
import arc.math.geom.Vec2;
|
import arc.scene.event.*;
|
||||||
import arc.scene.event.HandCursorListener;
|
|
||||||
import arc.scene.ui.*;
|
import arc.scene.ui.*;
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.struct.Seq;
|
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.Vars;
|
import mindustry.*;
|
||||||
import mindustry.content.UnitTypes;
|
import mindustry.content.*;
|
||||||
import mindustry.core.UI;
|
import mindustry.core.*;
|
||||||
import mindustry.game.Team;
|
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.Pal;
|
import mindustry.graphics.*;
|
||||||
import mindustry.input.DesktopInput;
|
import mindustry.input.*;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.ui.Styles;
|
import mindustry.ui.*;
|
||||||
import mindustry.world.blocks.storage.CoreBlock;
|
import mindustry.world.blocks.storage.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
|
|||||||
@@ -2,41 +2,35 @@ package informatis.ui.window;
|
|||||||
|
|
||||||
import arc.Events;
|
import arc.Events;
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.math.geom.Geometry;
|
import arc.math.geom.*;
|
||||||
import arc.scene.Element;
|
import arc.scene.*;
|
||||||
import arc.scene.style.Drawable;
|
import arc.scene.style.*;
|
||||||
import arc.struct.ObjectMap;
|
import arc.struct.*;
|
||||||
import mindustry.editor.MapEditor;
|
|
||||||
import mindustry.game.EventType;
|
|
||||||
import mindustry.graphics.Layer;
|
|
||||||
import informatis.core.EditorTool;
|
import informatis.core.EditorTool;
|
||||||
|
import mindustry.editor.*;
|
||||||
|
import mindustry.game.*;
|
||||||
|
import mindustry.graphics.*;
|
||||||
import informatis.ui.*;
|
import informatis.ui.*;
|
||||||
import arc.Core;
|
import arc.*;
|
||||||
import arc.func.*;
|
import arc.func.*;
|
||||||
import arc.graphics.Color;
|
import arc.graphics.*;
|
||||||
import arc.input.KeyCode;
|
import arc.input.*;
|
||||||
import arc.math.Mathf;
|
import arc.math.*;
|
||||||
import arc.math.geom.Vec2;
|
import arc.scene.event.*;
|
||||||
import arc.scene.event.Touchable;
|
|
||||||
import arc.scene.style.TextureRegionDrawable;
|
|
||||||
import arc.scene.ui.*;
|
import arc.scene.ui.*;
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.scene.utils.Elem;
|
import arc.scene.utils.*;
|
||||||
import arc.struct.Seq;
|
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.Vars;
|
import mindustry.*;
|
||||||
import mindustry.content.Blocks;
|
import mindustry.content.*;
|
||||||
import mindustry.game.Team;
|
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.Pal;
|
import mindustry.ui.*;
|
||||||
import mindustry.ui.Styles;
|
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class MapEditorWindow extends Window implements Updatable {
|
public class MapEditorWindow extends Window implements Updatable {
|
||||||
Vec2 scrollPos = new Vec2(0, 0);
|
Vec2 scrollPos = new Vec2(0, 0);
|
||||||
Table window;
|
|
||||||
TextField search;
|
TextField search;
|
||||||
EditorTool tool;
|
EditorTool tool;
|
||||||
final Vec2[][] brushPolygons = new Vec2[MapEditor.brushSizes.length][0];
|
final Vec2[][] brushPolygons = new Vec2[MapEditor.brushSizes.length][0];
|
||||||
@@ -152,6 +146,7 @@ public class MapEditorWindow extends Window implements Updatable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
|
//TODO make it more responsive, time -> width delta detect
|
||||||
heat += Time.delta;
|
heat += Time.delta;
|
||||||
if(heat >= 60f) {
|
if(heat >= 60f) {
|
||||||
heat = 0f;
|
heat = 0f;
|
||||||
|
|||||||
@@ -1,25 +1,22 @@
|
|||||||
package informatis.ui.window;
|
package informatis.ui.window;
|
||||||
|
|
||||||
import informatis.ui.OverScrollPane;
|
import informatis.ui.*;
|
||||||
import informatis.ui.Updatable;
|
import arc.*;
|
||||||
import arc.Core;
|
import arc.graphics.*;
|
||||||
import arc.graphics.Color;
|
import arc.graphics.g2d.*;
|
||||||
import arc.graphics.g2d.Draw;
|
import arc.math.geom.*;
|
||||||
import arc.graphics.g2d.Lines;
|
|
||||||
import arc.math.geom.Vec2;
|
|
||||||
import arc.scene.ui.*;
|
import arc.scene.ui.*;
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.scene.utils.Elem;
|
import arc.scene.utils.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.Pal;
|
import mindustry.graphics.*;
|
||||||
import mindustry.input.DesktopInput;
|
import mindustry.input.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
|
|
||||||
public class PlayerWindow extends Window implements Updatable {
|
public class PlayerWindow extends Window implements Updatable {
|
||||||
Vec2 scrollPos = new Vec2(0, 0);
|
Vec2 scrollPos = new Vec2(0, 0);
|
||||||
TextField search;
|
TextField search;
|
||||||
|
|||||||
@@ -1,17 +1,14 @@
|
|||||||
package informatis.ui.window;
|
package informatis.ui.window;
|
||||||
|
|
||||||
import informatis.ui.OverScrollPane;
|
import informatis.ui.*;
|
||||||
import informatis.ui.Updatable;
|
import informatis.ui.draws.*;
|
||||||
import informatis.ui.draws.OverDraw;
|
import arc.math.geom.*;
|
||||||
import informatis.ui.draws.OverDraws;
|
import arc.scene.ui.*;
|
||||||
import arc.math.geom.Vec2;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.scene.ui.ScrollPane;
|
import arc.util.*;
|
||||||
import arc.scene.ui.layout.Table;
|
import mindustry.gen.*;
|
||||||
import arc.util.Time;
|
import mindustry.graphics.*;
|
||||||
import mindustry.gen.Icon;
|
import mindustry.ui.*;
|
||||||
import mindustry.gen.Tex;
|
|
||||||
import mindustry.graphics.Pal;
|
|
||||||
import mindustry.ui.Styles;
|
|
||||||
|
|
||||||
public class ToolWindow extends Window implements Updatable {
|
public class ToolWindow extends Window implements Updatable {
|
||||||
Vec2 scrollPos = new Vec2(0, 0);
|
Vec2 scrollPos = new Vec2(0, 0);
|
||||||
|
|||||||
@@ -1,61 +1,54 @@
|
|||||||
package informatis.ui.window;
|
package informatis.ui.window;
|
||||||
|
|
||||||
import arc.Core;
|
import arc.*;
|
||||||
import arc.scene.Element;
|
import arc.func.*;
|
||||||
import arc.scene.event.InputEvent;
|
import arc.scene.*;
|
||||||
import arc.scene.event.InputListener;
|
import arc.scene.event.*;
|
||||||
import arc.scene.utils.Disableable;
|
|
||||||
import informatis.core.*;
|
import informatis.core.*;
|
||||||
import informatis.ui.*;
|
import informatis.ui.*;
|
||||||
import arc.graphics.Color;
|
import arc.graphics.Color;
|
||||||
import arc.graphics.g2d.*;
|
import arc.graphics.g2d.*;
|
||||||
import arc.math.geom.*;
|
|
||||||
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.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import informatis.ui.widgets.RectWidget;
|
import informatis.ui.widgets.*;
|
||||||
import mindustry.Vars;
|
import mindustry.*;
|
||||||
import mindustry.core.UI;
|
import mindustry.core.*;
|
||||||
import mindustry.entities.units.WeaponMount;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.Pal;
|
import mindustry.graphics.*;
|
||||||
import mindustry.type.StatusEffect;
|
import mindustry.type.*;
|
||||||
import mindustry.type.Weapon;
|
import mindustry.ui.*;
|
||||||
import mindustry.ui.Styles;
|
import mindustry.world.blocks.*;
|
||||||
import mindustry.world.blocks.ConstructBlock;
|
import mindustry.world.blocks.payloads.*;
|
||||||
import mindustry.world.blocks.payloads.Payload;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import static informatis.SVars.*;
|
import static informatis.SVars.*;
|
||||||
import static informatis.SUtils.*;
|
import static informatis.SUtils.*;
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
|
public class UnitWindow extends Window {
|
||||||
|
final Seq<Color> lastColors = new Seq<>();
|
||||||
class UnitWindow extends Window {
|
Teamc latestTarget;
|
||||||
final Seq<Color> lastColors = Seq.with(Color.clear,Color.clear,Color.clear,Color.clear,Color.clear,Color.clear);
|
|
||||||
Teamc latestTarget = getTarget();
|
|
||||||
int barSize = 6;
|
|
||||||
ScrollPane barPane;
|
ScrollPane barPane;
|
||||||
Table window;
|
|
||||||
|
|
||||||
|
private int barSize = 6;
|
||||||
|
private float usedPayload;
|
||||||
private float barScrollPos;
|
private float barScrollPos;
|
||||||
|
private final Bits statuses = new Bits();
|
||||||
|
|
||||||
public UnitWindow() {
|
public UnitWindow() {
|
||||||
super(Icon.units, "unit");
|
super(Icon.units, "unit");
|
||||||
window = this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: add new UnitInfoDisplay(), new WeaponDisplay();
|
//TODO: add new UnitInfoDisplay(), new WeaponDisplay();
|
||||||
@Override
|
@Override
|
||||||
protected void build(Table table) {
|
protected void build(Table table) {
|
||||||
table.top().background(Styles.black8);
|
table.top().background(Styles.black8);
|
||||||
table.table(tt -> {
|
table.table(title -> {
|
||||||
tt.center();
|
title.center();
|
||||||
Image image = RectWidget.build();
|
Image image = RectWidget.build();
|
||||||
image.update(()->{
|
image.update(()->{
|
||||||
TextureRegion region = clear;
|
TextureRegion region = clear;
|
||||||
@@ -70,8 +63,8 @@ class UnitWindow extends Window {
|
|||||||
if(target == getTarget()) locked = !locked;
|
if(target == getTarget()) locked = !locked;
|
||||||
target = getTarget();
|
target = getTarget();
|
||||||
});
|
});
|
||||||
tt.add(image).size(iconMed).padRight(12f);
|
title.add(image).size(iconMed).padRight(12f);
|
||||||
tt.label(() -> {
|
title.label(() -> {
|
||||||
if (target instanceof Unit u && u.type != null) return u.type.localizedName;
|
if (target instanceof Unit u && u.type != null) return 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) return cb.current.localizedName;
|
if (target instanceof ConstructBlock.ConstructBuild cb) return cb.current.localizedName;
|
||||||
@@ -81,22 +74,106 @@ class UnitWindow extends Window {
|
|||||||
}).color(Pal.accent);
|
}).color(Pal.accent);
|
||||||
}).tooltip(tool -> {
|
}).tooltip(tool -> {
|
||||||
tool.background(Styles.black6);
|
tool.background(Styles.black6);
|
||||||
tool.table().update(to -> {
|
tool.table(to -> {
|
||||||
to.clear();
|
to.label(() -> target instanceof Unit u ? u.isPlayer() ? u.getPlayer().name : "AI" : "").row();
|
||||||
if(target instanceof Unit u) {
|
to.label(() -> target.tileX() + ", " + target.tileY()).row();
|
||||||
to.add(u.isPlayer() ? u.getPlayer().name : "AI").row();
|
to.label(() -> target instanceof Unit u ? "[accent]"+ Strings.fixed(u.armor, 0) + "[] Armor" : "");
|
||||||
to.add(target.tileX() + ", " + target.tileY()).row();
|
|
||||||
to.add("[accent]"+ Strings.fixed(u.armor, 0) + "[] Armor");
|
|
||||||
}
|
|
||||||
}).margin(12f);
|
}).margin(12f);
|
||||||
}).margin(12f).row();
|
}).margin(12f).row();
|
||||||
table.image().height(4f).color((target==null?player.unit():target).team().color).growX().row();
|
|
||||||
|
if(target instanceof Payloadc || target instanceof Statusc) {
|
||||||
|
table.image().color((target == null ? player.unit() : target).team().color).height(4f).growX().row();
|
||||||
|
|
||||||
|
table.table(state -> {
|
||||||
|
state.left();
|
||||||
|
final Cons<Table> rebuildPayload = t -> {
|
||||||
|
t.left();
|
||||||
|
if (target instanceof Payloadc payload) {
|
||||||
|
Seq<Payload> payloads = payload.payloads();
|
||||||
|
for (int i = 0, m = payload.payloads().size; i < m; i++) {
|
||||||
|
t.image(payloads.get(i).icon()).size(iconSmall);
|
||||||
|
if ((i + 1) % Math.max(6, Math.round((window.getWidth() - 24) / iconSmall)) == 0) t.row();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
final Cons<Table> rebuildStatus = t -> {
|
||||||
|
t.top().left();
|
||||||
|
if (target instanceof Statusc st) {
|
||||||
|
Bits applied = st.statusBits();
|
||||||
|
if (applied != null) {
|
||||||
|
Seq<StatusEffect> contents = Vars.content.statusEffects();
|
||||||
|
for (int i = 0, m = Vars.content.statusEffects().size; i < m; i++) {
|
||||||
|
StatusEffect effect = contents.get(i);
|
||||||
|
if (applied.get(effect.id) && !effect.isHidden()) {
|
||||||
|
t.image(effect.uiIcon).size(iconSmall).get()
|
||||||
|
.addListener(new Tooltip(l -> l.label(() -> effect.localizedName + " [lightgray]" + UI.formatTime(st.getDuration(effect))).style(Styles.outlineLabel)));
|
||||||
|
}
|
||||||
|
if (i + 1 % Math.max(6, Math.round((window.getWidth() - 24) / iconSmall)) == 0) t.row();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
final float[] lastWidth1 = {0};
|
||||||
|
state.table(rebuildPayload).update(t -> {
|
||||||
|
t.left();
|
||||||
|
if (lastWidth1[0] != window.getWidth()) {
|
||||||
|
lastWidth1[0] = window.getWidth();
|
||||||
|
t.clear();
|
||||||
|
rebuildPayload.get(t);
|
||||||
|
} else if (target instanceof Payloadc payload) {
|
||||||
|
if (usedPayload != payload.payloadUsed()) {
|
||||||
|
usedPayload = payload.payloadUsed();
|
||||||
|
t.clear();
|
||||||
|
rebuildPayload.get(t);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
usedPayload = -1;
|
||||||
|
t.clear();
|
||||||
|
rebuildPayload.get(t);
|
||||||
|
}
|
||||||
|
}).grow().row();
|
||||||
|
|
||||||
|
final float[] lastWidth2 = {0};
|
||||||
|
state.table(rebuildStatus).update(t -> {
|
||||||
|
t.left();
|
||||||
|
if (lastWidth2[0] != window.getWidth()) {
|
||||||
|
lastWidth2[0] = window.getWidth();
|
||||||
|
t.clear();
|
||||||
|
rebuildStatus.get(t);
|
||||||
|
} else if (target instanceof Statusc st) {
|
||||||
|
Bits applied = st.statusBits();
|
||||||
|
if (applied != null && !statuses.equals(applied)) {
|
||||||
|
statuses.set(applied);
|
||||||
|
t.clear();
|
||||||
|
rebuildStatus.get(t);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
statuses.clear();
|
||||||
|
t.clear();
|
||||||
|
rebuildStatus.get(t);
|
||||||
|
}
|
||||||
|
}).grow();
|
||||||
|
}).pad(12f).growX().row();
|
||||||
|
}
|
||||||
|
|
||||||
|
table.image().color((target==null?player.unit():target).team().color).height(4f).growX().row();
|
||||||
|
|
||||||
barPane = new ScrollPane(buildBarList(), Styles.noBarPane);
|
barPane = new ScrollPane(buildBarList(), Styles.noBarPane);
|
||||||
barPane.update(() -> {
|
barPane.update(() -> {
|
||||||
|
//rebuild whole bar table
|
||||||
if(latestTarget != target) {
|
if(latestTarget != target) {
|
||||||
latestTarget = target;
|
for (int i = 0; i < barSize; i++) {
|
||||||
barPane.setWidget(buildBarList());
|
Color color = i >= BarInfo.data.size ? Color.clear : BarInfo.data.get(i).color;
|
||||||
Log.info("updated");
|
if (i >= lastColors.size) lastColors.add(color);
|
||||||
|
else lastColors.set(i, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(((Table) barPane.getWidget()).getChildren().size-1 != barSize) {
|
||||||
|
latestTarget = target;
|
||||||
|
barPane.setWidget(buildBarList());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(barPane.hasScroll()){
|
if(barPane.hasScroll()){
|
||||||
Element result = Core.scene.hit(Core.input.mouseX(), Core.input.mouseY(), true);
|
Element result = Core.scene.hit(Core.input.mouseX(), Core.input.mouseY(), true);
|
||||||
@@ -108,7 +185,7 @@ class UnitWindow extends Window {
|
|||||||
});
|
});
|
||||||
barPane.setScrollingDisabledX(true);
|
barPane.setScrollingDisabledX(true);
|
||||||
barPane.setScrollYForce(barScrollPos);
|
barPane.setScrollYForce(barScrollPos);
|
||||||
table.add(barPane).growX().padTop(12f);
|
table.add(barPane).grow().padTop(12f);
|
||||||
}
|
}
|
||||||
|
|
||||||
Table buildBarList() {
|
Table buildBarList() {
|
||||||
@@ -127,23 +204,18 @@ class UnitWindow extends Window {
|
|||||||
|
|
||||||
Table addBar(int index) {
|
Table addBar(int index) {
|
||||||
return new Table(bar -> {
|
return new Table(bar -> {
|
||||||
if(index >= BarInfo.data.size) {
|
bar.add(new SBar(
|
||||||
bar.add(new SBar("[lightgray]<Empty>[]", Color.clear, 0)).height(4 * 8f).growX();
|
() -> index >= BarInfo.data.size ? "[lightgray]<Empty>[]" : BarInfo.data.get(index).name,
|
||||||
return;
|
() -> index >= BarInfo.data.size ? Color.clear : BarInfo.data.get(index).color,
|
||||||
}
|
() -> lastColors.get(index),
|
||||||
|
() -> index >= BarInfo.data.size ? 0 : BarInfo.data.get(index).number)
|
||||||
bar.update(()->{
|
).height(4 * 8f).growX();
|
||||||
BarInfo.BarData data = BarInfo.data.get(index);
|
if(index >= BarInfo.data.size) return;
|
||||||
if (index >= lastColors.size) lastColors.add(data.color);
|
|
||||||
else lastColors.set(index, data.color);
|
|
||||||
});
|
|
||||||
|
|
||||||
bar.add(new SBar(() -> BarInfo.data.get(index).name, () -> BarInfo.data.get(index).color, () -> BarInfo.data.get(index).number)).height(4 * 8f).growX();
|
|
||||||
Image icon = new Image(){
|
Image icon = new Image(){
|
||||||
@Override
|
@Override
|
||||||
public void draw() {
|
public void draw() {
|
||||||
validate();
|
validate();
|
||||||
|
if(index >= BarInfo.data.size) return;
|
||||||
float x = this.x + imageX;
|
float x = this.x + imageX;
|
||||||
float y = this.y + imageY;
|
float y = this.y + imageY;
|
||||||
float width = imageWidth * this.scaleX;
|
float width = imageWidth * this.scaleX;
|
||||||
@@ -233,55 +305,4 @@ class UnitWindow extends Window {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
static class UnitInfoDisplay extends Table {
|
|
||||||
UnitInfoDisplay() {
|
|
||||||
top();
|
|
||||||
float[] count = new float[]{-1};
|
|
||||||
table().update(t -> {
|
|
||||||
if(getTarget() instanceof Payloadc payload){
|
|
||||||
if(count[0] != payload.payloadUsed()){
|
|
||||||
t.clear();
|
|
||||||
t.top().left();
|
|
||||||
|
|
||||||
float pad = 0;
|
|
||||||
float items = payload.payloads().size;
|
|
||||||
if(8 * 2 * items + pad * items > 275f){
|
|
||||||
pad = (275f - (8 * 2) * items) / items;
|
|
||||||
}
|
|
||||||
int i = 0;
|
|
||||||
for(Payload p : payload.payloads()){
|
|
||||||
t.image(p.icon()).size(8 * 2).padRight(pad);
|
|
||||||
if(++i % 12 == 0) t.row();
|
|
||||||
}
|
|
||||||
|
|
||||||
count[0] = payload.payloadUsed();
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
count[0] = -1;
|
|
||||||
t.clear();
|
|
||||||
}
|
|
||||||
}).growX().visible(() -> getTarget() instanceof Payloadc p && p.payloadUsed() > 0).colspan(2).row();
|
|
||||||
|
|
||||||
Bits statuses = new Bits();
|
|
||||||
table().update(t -> {
|
|
||||||
t.left();
|
|
||||||
if(getTarget() instanceof Statusc st){
|
|
||||||
Bits applied = st.statusBits();
|
|
||||||
if(!statuses.equals(applied)){
|
|
||||||
t.clear();
|
|
||||||
|
|
||||||
if(applied != null){
|
|
||||||
for(StatusEffect effect : Vars.content.statusEffects()){
|
|
||||||
if(applied.get(effect.id) && !effect.isHidden()){
|
|
||||||
t.image(effect.uiIcon).size(iconSmall).get()
|
|
||||||
.addListener(new Tooltip(l -> l.label(() -> effect.localizedName + " [lightgray]" + UI.formatTime(st.getDuration(effect))).style(Styles.outlineLabel)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
statuses.set(applied);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).left();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,33 +1,29 @@
|
|||||||
package informatis.ui.window;
|
package informatis.ui.window;
|
||||||
|
|
||||||
import mindustry.Vars;
|
import mindustry.*;
|
||||||
import mindustry.type.UnitType;
|
import mindustry.type.*;
|
||||||
import informatis.ui.OverScrollPane;
|
import informatis.ui.*;
|
||||||
import arc.Events;
|
import arc.*;
|
||||||
import arc.graphics.Color;
|
import arc.graphics.*;
|
||||||
import arc.math.Mathf;
|
import arc.math.*;
|
||||||
import arc.math.geom.Vec2;
|
import arc.math.geom.*;
|
||||||
import arc.scene.event.Touchable;
|
import arc.scene.event.*;
|
||||||
import arc.scene.ui.*;
|
import arc.scene.ui.*;
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.content.StatusEffects;
|
import mindustry.content.*;
|
||||||
import mindustry.game.EventType;
|
import mindustry.game.*;
|
||||||
import mindustry.game.SpawnGroup;
|
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.Pal;
|
import mindustry.graphics.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import informatis.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 WaveWindow extends Window implements Updatable {
|
public class WaveWindow extends Window implements Updatable {
|
||||||
static Vec2 scrollPos = new Vec2(0, 0);
|
static Vec2 scrollPos = new Vec2(0, 0);
|
||||||
Table window;
|
|
||||||
float heat;
|
float heat;
|
||||||
|
|
||||||
public WaveWindow() {
|
public WaveWindow() {
|
||||||
|
|||||||
@@ -10,13 +10,14 @@ import arc.scene.ui.layout.*;
|
|||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
import informatis.ui.WindowManager;
|
import informatis.ui.*;
|
||||||
|
|
||||||
public class Window extends Table{
|
public class Window extends Table {
|
||||||
public TextureRegionDrawable icon;
|
public TextureRegionDrawable icon;
|
||||||
public int id;
|
public int id;
|
||||||
public Cons<Table> content;
|
public Cons<Table> content;
|
||||||
public boolean shown = false;
|
public boolean shown = false;
|
||||||
|
public Table window;
|
||||||
|
|
||||||
public float minWindowWidth = 160, minWindowHeight = 60;
|
public float minWindowWidth = 160, minWindowHeight = 60;
|
||||||
public float maxWindowWidth = Float.MAX_VALUE, maxWindowHeight = Float.MAX_VALUE;
|
public float maxWindowWidth = Float.MAX_VALUE, maxWindowHeight = Float.MAX_VALUE;
|
||||||
@@ -29,13 +30,14 @@ public class Window extends Table{
|
|||||||
this.content = content;
|
this.content = content;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.icon = icon;
|
this.icon = icon;
|
||||||
|
window = this;
|
||||||
|
|
||||||
titleBar();
|
titleBar();
|
||||||
pane(t -> {
|
pane(t -> {
|
||||||
t.setBackground(Styles.black5);
|
t.setBackground(Styles.black5);
|
||||||
t.top().left();
|
t.top().left();
|
||||||
build(t);
|
build(t);
|
||||||
}).grow().top().left().get().setScrollingDisabled(true, true);
|
}).grow().get().setScrollingDisabled(true, true);
|
||||||
bottomBar();
|
bottomBar();
|
||||||
|
|
||||||
setPosition(Core.graphics.getWidth() / 2f - getWidth() / 2f, Core.graphics.getHeight() / 2f - getHeight() / 2f);
|
setPosition(Core.graphics.getWidth() / 2f - getWidth() / 2f, Core.graphics.getHeight() / 2f - getHeight() / 2f);
|
||||||
@@ -88,7 +90,7 @@ public class Window extends Table{
|
|||||||
lastY = v.y;
|
lastY = v.y;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}).height(6f*8).top().grow().row();
|
}).height(48f).growX().row();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void bottomBar(){
|
protected void bottomBar(){
|
||||||
@@ -131,4 +133,4 @@ public class Window extends Table{
|
|||||||
public void toggle(){
|
public void toggle(){
|
||||||
shown = !shown;
|
shown = !shown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user