mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-15 17:56:24 +02:00
wave window
This commit is contained in:
408
src/UnitInfo/ui/windows/UnitDisplay.java
Normal file
408
src/UnitInfo/ui/windows/UnitDisplay.java
Normal file
@@ -0,0 +1,408 @@
|
||||
package UnitInfo.ui.windows;
|
||||
|
||||
import UnitInfo.SVars;
|
||||
import UnitInfo.core.BarInfo;
|
||||
import UnitInfo.ui.SBar;
|
||||
import UnitInfo.ui.SIcons;
|
||||
import UnitInfo.ui.Updatable;
|
||||
import UnitInfo.ui.windows.WindowTable;
|
||||
import arc.Core;
|
||||
import arc.func.Prov;
|
||||
import arc.graphics.Color;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.input.KeyCode;
|
||||
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.ui.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.Bits;
|
||||
import arc.struct.Seq;
|
||||
import arc.util.*;
|
||||
import mindustry.Vars;
|
||||
import mindustry.ai.formations.FormationPattern;
|
||||
import mindustry.core.UI;
|
||||
import mindustry.entities.units.WeaponMount;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.Pal;
|
||||
import mindustry.type.StatusEffect;
|
||||
import mindustry.type.Weapon;
|
||||
import mindustry.ui.Styles;
|
||||
import mindustry.world.blocks.ConstructBlock;
|
||||
import mindustry.world.blocks.defense.ForceProjector;
|
||||
import mindustry.world.blocks.defense.turrets.*;
|
||||
import mindustry.world.blocks.distribution.MassDriver;
|
||||
import mindustry.world.blocks.payloads.Payload;
|
||||
import mindustry.world.blocks.power.*;
|
||||
|
||||
import static UnitInfo.SVars.clear;
|
||||
import static UnitInfo.SVars.modUiScale;
|
||||
import static arc.Core.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class UnitDisplay extends WindowTable implements Updatable {
|
||||
static Seq<Color> lastColors = Seq.with(Color.clear,Color.clear,Color.clear,Color.clear,Color.clear,Color.clear);
|
||||
static final Rect scissor = new Rect();
|
||||
float scrollPos;
|
||||
|
||||
public UnitDisplay() {
|
||||
super("Unit Display", Icon.units, t -> {});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void build() {
|
||||
top();
|
||||
topBar();
|
||||
|
||||
//TODO: add new UnitInfoDisplay(), new WeaponDisplay();
|
||||
table(Styles.black8, t -> {
|
||||
t.table(Tex.underline2, tt -> {
|
||||
tt.stack(
|
||||
new Table(ttt -> {
|
||||
Prov<TextureRegionDrawable> reg = () -> {
|
||||
TextureRegion region = clear;
|
||||
Teamc target = getTarget();
|
||||
if (target instanceof Unit u && u.type != null) region = u.type.uiIcon;
|
||||
else if (target instanceof Building b) {
|
||||
if (target instanceof ConstructBlock.ConstructBuild cb)
|
||||
region = cb.current.uiIcon;
|
||||
else if (b.block != null) region = b.block.uiIcon;
|
||||
}
|
||||
return new TextureRegionDrawable(region);
|
||||
};
|
||||
Drawable img = reg.get();
|
||||
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(SVars.hud.locked ? Color.red.shiftHue(2 * 60 % Time.delta) : Color.white));
|
||||
i.getStyle().imageDown = reg.get().tint(Tmp.c1.mul(Color.darkGray));
|
||||
i.layout();
|
||||
}).size(4 * 8f).get().parent = null;
|
||||
}),
|
||||
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).get().parent = null;
|
||||
})
|
||||
);
|
||||
|
||||
tt.label(() -> {
|
||||
String name = "";
|
||||
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 ConstructBlock.ConstructBuild cb)
|
||||
name = cb.current.localizedName;
|
||||
else name = b.block.localizedName;
|
||||
}
|
||||
return "[accent]" + (name.length() > 13 ? name.substring(0, 13) + "..." : name) + "[]";
|
||||
}).get().parent = null;
|
||||
|
||||
tt.addListener(new Tooltip(to -> {
|
||||
Teamc target = getTarget();
|
||||
|
||||
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 == null
|
||||
? "(" + 0 + ", " + 0 + ")"
|
||||
: "(" + Strings.fixed(target.x() / tilesize, 2) + ", " + Strings.fixed(target.y() / tilesize, 2) + ")").row();
|
||||
}));
|
||||
tt.update(() -> tt.setBackground(((NinePatchDrawable) Tex.underline2).tint(getTarget() == null ? Color.gray : getTarget().team().color))).parent = null;
|
||||
}).row();
|
||||
ScrollPane pane = t.pane(Styles.nonePane, new Table(tt -> {
|
||||
for (int i = 0; i < 6; i++) {
|
||||
addBar(tt, i);
|
||||
tt.row();
|
||||
}
|
||||
}).left()).top().right().grow().get();
|
||||
pane.parent = null;
|
||||
pane.update(() -> {
|
||||
Element result = scene.hit(input.mouseX(), input.mouseY(), true);
|
||||
if(pane.hasScroll() && (result == null || !result.isDescendantOf(pane)))
|
||||
scene.setScrollFocus(null);
|
||||
scrollPos = pane.getScrollY();
|
||||
});
|
||||
|
||||
pane.setOverscroll(false, false);
|
||||
pane.setScrollingDisabled(true, false);
|
||||
pane.setScrollYForce(scrollPos);
|
||||
}).top().right().grow().get().parent = null;
|
||||
resizeButton();
|
||||
}
|
||||
|
||||
public static Teamc getTarget() {
|
||||
return SVars.hud == null ? null : SVars.hud.getTarget();
|
||||
}
|
||||
|
||||
public void lockTarget() {
|
||||
SVars.hud.locked = !SVars.hud.locked;
|
||||
SVars.hud.lockedTarget = SVars.hud.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
|
||||
public void setEvent() {
|
||||
if((input.keyDown(KeyCode.shiftRight) || input.keyDown(KeyCode.shiftLeft))) {
|
||||
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);
|
||||
return out;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public TextureRegion getRegions(int i){
|
||||
Teamc target = getTarget();
|
||||
TextureRegion region = clear;
|
||||
|
||||
if(i == 0){
|
||||
if(target instanceof Healthc) region = SIcons.health;
|
||||
} else if(i == 1){
|
||||
if(target instanceof Turret.TurretBuild ||
|
||||
target instanceof MassDriver.MassDriverBuild){
|
||||
region = SIcons.reload;
|
||||
} else if((target instanceof Unit unit && unit.type != null) ||
|
||||
target instanceof ForceProjector.ForceBuild){
|
||||
region = SIcons.shield;
|
||||
} else if(target instanceof PowerNode.PowerNodeBuild ||
|
||||
target instanceof PowerGenerator.GeneratorBuild){
|
||||
region = SIcons.power;
|
||||
}
|
||||
} else if(i == 2){
|
||||
if(target instanceof ItemTurret.ItemTurretBuild){
|
||||
region = SIcons.ammo;
|
||||
} else if(target instanceof LiquidTurret.LiquidTurretBuild){
|
||||
region = SIcons.liquid;
|
||||
} else if(target instanceof PowerTurret.PowerTurretBuild ||
|
||||
target instanceof PowerNode.PowerNodeBuild){
|
||||
region = SIcons.power;
|
||||
} else if((target instanceof Building b && b.block.hasItems) ||
|
||||
(target instanceof Unit unit && unit.type != null)){
|
||||
region = SIcons.item;
|
||||
}
|
||||
} else if(i == 3){
|
||||
if(target instanceof PowerNode.PowerNodeBuild){
|
||||
region = SIcons.power;
|
||||
}
|
||||
} else if(i == 4){
|
||||
if(target instanceof PowerNode.PowerNodeBuild){
|
||||
region = SIcons.power;
|
||||
} else if(target instanceof Building b && b.block.hasLiquids){
|
||||
region = SIcons.liquid;
|
||||
}
|
||||
} else if(i == 5){
|
||||
if(target instanceof Unit unit && state.rules.unitAmmo && unit.type != null){
|
||||
region = SIcons.ammo;
|
||||
}else if(target instanceof PowerNode.PowerNodeBuild ||
|
||||
(target instanceof Building b && b.block.consumes.hasPower())){
|
||||
region = SIcons.power;
|
||||
}
|
||||
}
|
||||
|
||||
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 {
|
||||
public WeaponDisplay() {
|
||||
table().update(tt -> {
|
||||
tt.clear();
|
||||
if(getTarget() instanceof Unit u && u.type != null && u.hasWeapons()) {
|
||||
for(int r = 0; r < u.type.weapons.size; r++){
|
||||
Weapon weapon = u.type.weapons.get(r);
|
||||
WeaponMount mount = u.mounts[r];
|
||||
int finalR = r;
|
||||
tt.table(ttt -> {
|
||||
ttt.left();
|
||||
if((1 + finalR) % 4 == 0) ttt.row();
|
||||
ttt.stack(
|
||||
new Table(o -> {
|
||||
o.left();
|
||||
o.add(new Image(!weapon.name.equals("") && weapon.outlineRegion.found() ? weapon.outlineRegion : u.type.uiIcon){
|
||||
@Override
|
||||
public void draw(){
|
||||
validate();
|
||||
float x = this.x;
|
||||
float y = this.y;
|
||||
float scaleX = this.scaleX;
|
||||
float scaleY = this.scaleY;
|
||||
Draw.color(color);
|
||||
Draw.alpha(parentAlpha * color.a);
|
||||
|
||||
if(getDrawable() instanceof TransformDrawable){
|
||||
float rotation = getRotation();
|
||||
if(scaleX != 1 || scaleY != 1 || rotation != 0){
|
||||
getDrawable().draw(x + imageX, y + imageY, originX - imageX, originY - imageY, imageWidth, imageHeight, scaleX, scaleY, rotation);
|
||||
return;
|
||||
}
|
||||
}
|
||||
y -= (mount.reload) / weapon.reload * weapon.recoil;
|
||||
if(getDrawable() != null)
|
||||
getDrawable().draw(x + imageX, y + imageY, imageWidth * scaleX, imageHeight * scaleY);
|
||||
}
|
||||
}).size(Scl.scl(modUiScale) * iconLarge);
|
||||
}),
|
||||
new Table(h -> {
|
||||
h.defaults().growX().height(Scl.scl(modUiScale) * 9f).width(Scl.scl(modUiScale) * iconLarge).padTop(Scl.scl(modUiScale) * 18f);
|
||||
h.add(new SBar(
|
||||
() -> "",
|
||||
() -> Pal.accent.cpy().lerp(Color.orange, mount.reload / weapon.reload),
|
||||
() -> mount.reload / weapon.reload).rect().init());
|
||||
h.pack();
|
||||
})
|
||||
);
|
||||
}).pad(4);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
static class UnitInfoDisplay extends Table {
|
||||
public 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,170 +1,138 @@
|
||||
package UnitInfo.ui.windows;
|
||||
|
||||
import UnitInfo.SVars;
|
||||
import UnitInfo.ui.OverScrollPane;
|
||||
import arc.Events;
|
||||
import arc.graphics.Color;
|
||||
import arc.input.KeyCode;
|
||||
import arc.math.Mathf;
|
||||
import arc.scene.Element;
|
||||
import arc.math.geom.Vec2;
|
||||
import arc.scene.event.HandCursorListener;
|
||||
import arc.scene.style.NinePatchDrawable;
|
||||
import arc.scene.event.Touchable;
|
||||
import arc.scene.ui.*;
|
||||
import arc.scene.ui.layout.*;
|
||||
import arc.struct.ObjectIntMap;
|
||||
import arc.struct.Seq;
|
||||
import arc.util.Scaling;
|
||||
import arc.util.Time;
|
||||
import arc.util.Tmp;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.content.StatusEffects;
|
||||
import mindustry.game.EventType;
|
||||
import mindustry.game.SpawnGroup;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.Pal;
|
||||
import mindustry.ui.*;
|
||||
|
||||
import static UnitInfo.SVars.modUiScale;
|
||||
import static arc.Core.*;
|
||||
import static arc.Core.settings;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
|
||||
public class WaveDisplay extends Table {
|
||||
static float waveScrollPos;
|
||||
static Table table = new Table();
|
||||
public class WaveDisplay extends WindowTable {
|
||||
static Vec2 waveScrollPos = new Vec2(0, 0);
|
||||
|
||||
public WaveDisplay() {
|
||||
fillParent = true;
|
||||
visibility = () -> 1 == SVars.hud.uiIndex;
|
||||
super("Wave Display", Icon.waves, t -> {});
|
||||
}
|
||||
|
||||
defaults().size(Scl.scl(modUiScale) * 35 * 8f);
|
||||
table(Tex.button, t -> {
|
||||
ScrollPane pane = t.pane(Styles.nonePane, rebuild()).get();
|
||||
pane.update(() -> {
|
||||
if (pane.hasScroll()) {
|
||||
Element result = scene.hit(input.mouseX(), input.mouseY(), true);
|
||||
if (result == null || !result.isDescendantOf(pane)) {
|
||||
scene.setScrollFocus(null);
|
||||
}
|
||||
}
|
||||
waveScrollPos = pane.getScrollY();
|
||||
});
|
||||
pane.setOverscroll(false, false);
|
||||
pane.setScrollingDisabled(true, false);
|
||||
pane.setScrollYForce(waveScrollPos);
|
||||
@Override
|
||||
public void build() {
|
||||
top();
|
||||
topBar();
|
||||
|
||||
update(() -> {
|
||||
NinePatchDrawable patch = (NinePatchDrawable) Tex.button;
|
||||
t.setBackground(patch.tint(Tmp.c1.set(patch.getPatch().getColor()).a(settings.getInt("uiopacity") / 100f)));
|
||||
table(Styles.black8, t -> {
|
||||
ScrollPane pane = new OverScrollPane(rebuild(), Styles.nonePane, waveScrollPos).disableScroll(true, false);
|
||||
t.add(pane).get().parent = null;
|
||||
Events.on(EventType.WorldLoadEvent.class, e -> {
|
||||
pane.clearChildren();
|
||||
pane.setWidget(rebuild());
|
||||
});
|
||||
}).padRight(Scl.scl(modUiScale) * 70 * 8f);
|
||||
Events.on(EventType.WaveEvent.class, e -> {
|
||||
pane.clearChildren();
|
||||
pane.setWidget(rebuild());
|
||||
});
|
||||
}).top().right().grow().get().parent = null;
|
||||
|
||||
resizeButton();
|
||||
}
|
||||
|
||||
public ObjectIntMap<SpawnGroup> getWaveGroup(int index) {
|
||||
ObjectIntMap<SpawnGroup> groups = new ObjectIntMap<>();
|
||||
for (SpawnGroup group : state.rules.spawns) {
|
||||
if (group.getSpawned(index) <= 0) continue;
|
||||
SpawnGroup sameTypeKey = groups.keys().toArray().find(g -> g.type == group.type && g.effect != StatusEffects.boss);
|
||||
if (sameTypeKey != null) groups.increment(sameTypeKey, sameTypeKey.getSpawned(index));
|
||||
else groups.put(group, group.getSpawned(index));
|
||||
}
|
||||
Seq<SpawnGroup> groupSorted = groups.keys().toArray().copy().sort((g1, g2) -> {
|
||||
int boss = Boolean.compare(g1.effect != StatusEffects.boss, g2.effect != StatusEffects.boss);
|
||||
if (boss != 0) return boss;
|
||||
int hitSize = Float.compare(-g1.type.hitSize, -g2.type.hitSize);
|
||||
if (hitSize != 0) return hitSize;
|
||||
return Integer.compare(-g1.type.id, -g2.type.id);
|
||||
});
|
||||
ObjectIntMap<SpawnGroup> groupsTmp = new ObjectIntMap<>();
|
||||
groupSorted.each(g -> groupsTmp.put(g, groups.get(g)));
|
||||
|
||||
return groupsTmp;
|
||||
}
|
||||
|
||||
public Table rebuild(){
|
||||
table.clear();
|
||||
int winWave = state.isCampaign() && state.rules.winWave > 0 ? state.rules.winWave : Integer.MAX_VALUE;
|
||||
for(int i = settings.getBool("pastwave") ? 0 : state.wave - 1; i <= Math.min(state.wave + settings.getInt("wavemax"), winWave - 2); i++){
|
||||
final int j = i;
|
||||
if(!settings.getBool("emptywave") && state.rules.spawns.find(g -> g.getSpawned(j) > 0) == null) continue;
|
||||
table.table(table1 -> {
|
||||
table1.stack(
|
||||
return new Table(table -> {
|
||||
table.touchable = Touchable.enabled;
|
||||
for (int i = settings.getBool("pastwave") ? 0 : state.wave - 1;
|
||||
i <= Math.min(state.wave + settings.getInt("wavemax"), (state.isCampaign() && state.rules.winWave > 0 ? state.rules.winWave : Integer.MAX_VALUE) - 2);
|
||||
i++) {
|
||||
final int j = i;
|
||||
|
||||
table.stack(
|
||||
new Table(t -> {
|
||||
Label label = new Label(() -> "[#" + (state.wave == j ? Color.red.toString() : Pal.accent.toString()) + "]" + j + "[]");
|
||||
label.setFontScale(Scl.scl(modUiScale));
|
||||
t.add(label).padRight(Scl.scl(modUiScale) * 24 * 8f);
|
||||
t.label(() -> "[#" + (state.wave == j ? Color.red.toString() : Pal.accent.toString()) + "]" + j + "[]").padRight(24 * 8f);
|
||||
}),
|
||||
new Table(Tex.underline, t -> {
|
||||
t.marginLeft(Scl.scl(modUiScale) * 3 * 8f);
|
||||
if(settings.getBool("emptywave") && state.rules.spawns.find(g -> g.getSpawned(j) > 0) == null) {
|
||||
t.center();
|
||||
Label label = new Label(bundle.get("empty"));
|
||||
label.setFontScale(Scl.scl(modUiScale));
|
||||
t.add(label);
|
||||
if (settings.getBool("emptywave") && state.rules.spawns.find(g -> g.getSpawned(j) > 0) == null) {
|
||||
t.add(bundle.get("empty")).center();
|
||||
return;
|
||||
}
|
||||
|
||||
ObjectIntMap<SpawnGroup> groups = new ObjectIntMap<>();
|
||||
for(SpawnGroup group : state.rules.spawns) {
|
||||
if(group.getSpawned(j) <= 0) continue;
|
||||
SpawnGroup sameTypeKey = groups.keys().toArray().find(g -> g.type == group.type && g.effect != StatusEffects.boss);
|
||||
if(sameTypeKey != null) groups.increment(sameTypeKey, sameTypeKey.getSpawned(j));
|
||||
else groups.put(group, group.getSpawned(j));
|
||||
}
|
||||
Seq<SpawnGroup> groupSorted = groups.keys().toArray().copy().sort((g1, g2) -> {
|
||||
int boss = Boolean.compare(g1.effect != StatusEffects.boss, g2.effect != StatusEffects.boss);
|
||||
if(boss != 0) return boss;
|
||||
int hitSize = Float.compare(-g1.type.hitSize, -g2.type.hitSize);
|
||||
if(hitSize != 0) return hitSize;
|
||||
return Integer.compare(-g1.type.id, -g2.type.id);
|
||||
});
|
||||
ObjectIntMap<SpawnGroup> groupsTmp = new ObjectIntMap<>();
|
||||
groupSorted.each(g -> groupsTmp.put(g, groups.get(g)));
|
||||
ObjectIntMap<SpawnGroup> groups = getWaveGroup(j-2);
|
||||
|
||||
int row = 0;
|
||||
for(SpawnGroup group : groupsTmp.keys()){
|
||||
for (SpawnGroup group : groups.keys()) {
|
||||
int spawners = state.rules.waveTeam.cores().size + (group.type.flying ? spawner.countFlyerSpawns() : spawner.countGroundSpawns());
|
||||
int amount = groupsTmp.get(group);
|
||||
t.table(tt -> {
|
||||
Image image = new Image(group.type.uiIcon).setScaling(Scaling.fit);
|
||||
tt.stack(
|
||||
new Table(ttt -> {
|
||||
ttt.center();
|
||||
ttt.add(image).size(iconMed * Scl.scl(modUiScale));
|
||||
ttt.pack();
|
||||
}),
|
||||
int amount = groups.get(group);
|
||||
t.stack(
|
||||
new Table(ttt -> {
|
||||
ttt.center();
|
||||
ttt.image(group.type.uiIcon).size(iconMed);
|
||||
ttt.pack();
|
||||
}),
|
||||
|
||||
new Table(ttt -> {
|
||||
ttt.bottom().left();
|
||||
Label label = new Label(() -> amount + "");
|
||||
label.setFontScale(Scl.scl(modUiScale) * 0.9f);
|
||||
Label multi = new Label(() -> "[gray]x" + spawners);
|
||||
multi.setFontScale(Scl.scl(modUiScale) * 0.7f);
|
||||
ttt.add(label).padTop(2f);
|
||||
ttt.add(multi).padTop(10f);
|
||||
ttt.pack();
|
||||
}),
|
||||
new Table(ttt -> {
|
||||
ttt.bottom().left();
|
||||
ttt.add(amount+"").padTop(2f).fontScale(0.9f);
|
||||
ttt.add("[gray]x"+spawners).padTop(10f).fontScale(0.7f);
|
||||
ttt.pack();
|
||||
}),
|
||||
|
||||
new Table(ttt -> {
|
||||
ttt.top().right();
|
||||
Image image1 = new Image(Icon.warning.getRegion()).setScaling(Scaling.fit);
|
||||
image1.update(() -> {
|
||||
image1.setColor(Tmp.c2.set(Color.orange).lerp(Color.scarlet, Mathf.absin(Time.time, 2f, 1f)));
|
||||
});
|
||||
ttt.add(image1).size(Scl.scl(modUiScale) * 12f);
|
||||
ttt.visible(() -> group.effect == StatusEffects.boss);
|
||||
ttt.pack();
|
||||
})
|
||||
).pad(2f * Scl.scl(modUiScale));
|
||||
tt.clicked(() -> {
|
||||
if(input.keyDown(KeyCode.shiftLeft) && Fonts.getUnicode(group.type.name) != 0){
|
||||
app.setClipboardText((char)Fonts.getUnicode(group.type.name) + "");
|
||||
ui.showInfoFade("@copied");
|
||||
}else{
|
||||
ui.content.show(group.type);
|
||||
}
|
||||
});
|
||||
if(!mobile){
|
||||
HandCursorListener listener = new HandCursorListener();
|
||||
tt.addListener(listener);
|
||||
tt.update(() -> {
|
||||
image.color.lerp(!listener.isOver() ? Color.lightGray : Color.white, Mathf.clamp(0.4f * Time.delta));
|
||||
});
|
||||
}
|
||||
tt.addListener(new Tooltip(ttt -> ttt.table(Styles.black6, to -> {
|
||||
to.margin(4f).left();
|
||||
to.add("[stat]" + group.type.localizedName + "[]").row();
|
||||
to.row();
|
||||
to.add(bundle.format("shar-stat-waveAmount", amount + " [lightgray]x" + spawners + "[]")).row();
|
||||
to.add(bundle.format("shar-stat-waveShield", group.getShield(j))).row();
|
||||
if(group.effect != null && group.effect != StatusEffects.none)
|
||||
to.add(bundle.get("shar-stat.waveStatus") + group.effect.emoji() + "[stat]" + group.effect.localizedName).row();
|
||||
})));
|
||||
});
|
||||
if(++row % 4 == 0) t.row();
|
||||
new Table(ttt -> {
|
||||
ttt.top().right();
|
||||
ttt.image(Icon.warning.getRegion()).update(img->img.setColor(Tmp.c2.set(Color.orange).lerp(Color.scarlet, Mathf.absin(Time.time, 2f, 1f)))).size(12f);
|
||||
ttt.visible(() -> group.effect == StatusEffects.boss);
|
||||
ttt.pack();
|
||||
})
|
||||
).pad(2f).get().addListener(new Tooltip(to -> {
|
||||
to.background(Styles.black6);
|
||||
to.margin(4f).left();
|
||||
to.add("[stat]" + group.type.localizedName + "[]").row();
|
||||
to.row();
|
||||
to.add(bundle.format("shar-stat-waveAmount", amount + " [lightgray]x" + spawners + "[]")).row();
|
||||
to.add(bundle.format("shar-stat-waveShield", group.getShield(j))).row();
|
||||
if (group.effect != null && group.effect != StatusEffects.none)
|
||||
to.add(bundle.get("shar-stat.waveStatus") + group.effect.emoji() + "[stat]" + group.effect.localizedName).row();
|
||||
}));
|
||||
if (++row % 4 == 0) t.row();
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
table.row();
|
||||
}
|
||||
|
||||
return table;
|
||||
table.row();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package UnitInfo.ui.windows;
|
||||
|
||||
import UnitInfo.ui.UnitDisplay;
|
||||
|
||||
public class WindowTables {
|
||||
public static WindowTable unitTable = new UnitDisplay();
|
||||
public static WindowTable
|
||||
unitTable = new UnitDisplay(),
|
||||
waveTable = new WaveDisplay();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user