mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-10 03:59:26 +02:00
is it releasable?
This commit is contained in:
@@ -1,28 +1,25 @@
|
|||||||
package informatis.ui.draws;
|
package informatis.ui.draws;
|
||||||
|
|
||||||
import informatis.ui.FreeBar;
|
import arc.math.geom.*;
|
||||||
import arc.graphics.g2d.Lines;
|
import informatis.SUtils;
|
||||||
import arc.math.Angles;
|
import informatis.ui.*;
|
||||||
import arc.math.Mathf;
|
import arc.graphics.g2d.*;
|
||||||
import arc.scene.style.TextureRegionDrawable;
|
import arc.math.*;
|
||||||
import arc.scene.ui.layout.Scl;
|
import arc.scene.style.*;
|
||||||
import arc.struct.Seq;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.util.Align;
|
import arc.struct.*;
|
||||||
import arc.util.Tmp;
|
import arc.util.*;
|
||||||
import mindustry.Vars;
|
import mindustry.Vars;
|
||||||
import mindustry.ai.Pathfinder;
|
import mindustry.ai.*;
|
||||||
import mindustry.ai.RtsAI;
|
|
||||||
import mindustry.ai.types.*;
|
import mindustry.ai.types.*;
|
||||||
import mindustry.entities.units.UnitController;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.game.Team;
|
import mindustry.game.*;
|
||||||
import mindustry.gen.Groups;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.Pal;
|
import mindustry.graphics.*;
|
||||||
import mindustry.logic.LUnitControl;
|
import mindustry.logic.*;
|
||||||
import mindustry.ui.Fonts;
|
import mindustry.ui.*;
|
||||||
import mindustry.world.Tile;
|
import mindustry.world.*;
|
||||||
import mindustry.world.blocks.storage.CoreBlock;
|
import mindustry.world.blocks.storage.*;
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
import static informatis.SUtils.*;
|
import static informatis.SUtils.*;
|
||||||
import static arc.Core.settings;
|
import static arc.Core.settings;
|
||||||
@@ -47,7 +44,6 @@ public class UnitDraw extends OverDraw {
|
|||||||
|
|
||||||
Groups.unit.each(u-> isInCamera(u.x, u.y, u.hitSize), u -> {
|
Groups.unit.each(u-> isInCamera(u.x, u.y, u.hitSize), u -> {
|
||||||
UnitController c = u.controller();
|
UnitController c = u.controller();
|
||||||
RtsAI rts = u.team.data().rtsAi;
|
|
||||||
|
|
||||||
if(settings.getBool("logicLine") && c instanceof LogicAI ai && (ai.control == LUnitControl.approach || ai.control == LUnitControl.move)) {
|
if(settings.getBool("logicLine") && c instanceof LogicAI ai && (ai.control == LUnitControl.approach || ai.control == LUnitControl.move)) {
|
||||||
Lines.stroke(1, u.team.color);
|
Lines.stroke(1, u.team.color);
|
||||||
@@ -56,17 +52,21 @@ public class UnitDraw extends OverDraw {
|
|||||||
Lines.line(u.x(), u.y(), ai.controller.x, ai.controller.y);
|
Lines.line(u.x(), u.y(), ai.controller.x, ai.controller.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(settings.getBool("unitLine") && !u.type.flying && !(c instanceof MinerAI || c instanceof BuilderAI || c instanceof RepairAI || c instanceof DefenderAI || c instanceof FlyingAI)) {
|
if(c instanceof CommandAI com && com.hasCommand()) {
|
||||||
|
Lines.stroke(1, u.team.color);
|
||||||
|
|
||||||
|
Lines.line(u.x(), u.y(), com.targetPos.x, com.targetPos.y);
|
||||||
|
}
|
||||||
|
else if(settings.getBool("unitLine") && !u.type.flying && !(c instanceof MinerAI || c instanceof BuilderAI || c instanceof RepairAI || c instanceof DefenderAI || c instanceof FlyingAI)) {
|
||||||
Lines.stroke(1, u.team.color);
|
Lines.stroke(1, u.team.color);
|
||||||
|
|
||||||
otherCores = Groups.build.count(b -> b instanceof CoreBlock.CoreBuild && b.team != u.team);
|
otherCores = Groups.build.count(b -> b instanceof CoreBlock.CoreBuild && b.team != u.team);
|
||||||
pathTiles.clear();
|
pathTiles.clear();
|
||||||
getNextTile(u.tileOn(), u.controller() instanceof SuicideAI ? 0 : u.pathType(), u.team, u.pathType());
|
getNextTile(u.tileOn(), u.controller() instanceof SuicideAI ? 0 : u.pathType(), u.team, u.pathType());
|
||||||
pathTiles.filter(Objects::nonNull);
|
|
||||||
for(int i = 0; i < pathTiles.size-1; i++) {
|
for(int i = 0; i < pathTiles.size-1; i++) {
|
||||||
Tile from = pathTiles.get(i);
|
Tile from = pathTiles.get(i);
|
||||||
Tile to = pathTiles.get(i + 1);
|
Tile to = pathTiles.get(i + 1);
|
||||||
if(isOutCamera(from.worldx(), from.worldy())) continue;
|
if(from == null || to == null || isOutCamera(from.worldx(), from.worldy())) continue;
|
||||||
Lines.line(from.worldx(), from.worldy(), to.worldx(), to.worldy());
|
Lines.line(from.worldx(), from.worldy(), to.worldx(), to.worldy());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -87,25 +87,22 @@ public class UnitDraw extends OverDraw {
|
|||||||
pathTiles.clear();
|
pathTiles.clear();
|
||||||
otherCores = Groups.build.count(b -> b instanceof CoreBlock.CoreBuild && b.team != enemyTeam);
|
otherCores = Groups.build.count(b -> b instanceof CoreBlock.CoreBuild && b.team != enemyTeam);
|
||||||
getNextTile(t, p, enemyTeam, Pathfinder.fieldCore);
|
getNextTile(t, p, enemyTeam, Pathfinder.fieldCore);
|
||||||
pathTiles.filter(Objects::nonNull);
|
|
||||||
|
|
||||||
for(int i = 0; i < pathTiles.size-1; i++) {
|
for(int i = 0; i < pathTiles.size-1; i++) {
|
||||||
Tile from = pathTiles.get(i);
|
Tile from = pathTiles.get(i);
|
||||||
Tile to = pathTiles.get(i + 1);
|
Tile to = pathTiles.get(i + 1);
|
||||||
if(isOutCamera(from.worldx(), from.worldy())) continue;
|
if(from == null || to == null || isOutCamera(from.worldx(), from.worldy())) continue;
|
||||||
Lines.line(from.worldx(), from.worldy(), to.worldx(), to.worldy());
|
Lines.line(from.worldx(), from.worldy(), to.worldx(), to.worldy());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Tile getNextTile(Tile tile, int cost, Team team, int finder) {
|
void getNextTile(Tile tile, int cost, Team team, int finder) {
|
||||||
Pathfinder.Flowfield field = pathfinder.getField(team, cost, Mathf.clamp(finder, 0, 0));
|
Pathfinder.Flowfield field = pathfinder.getField(team, cost, Mathf.clamp(finder, 0, 0));
|
||||||
Tile tile1 = pathfinder.getTargetTile(tile, field);
|
Tile tile1 = pathfinder.getTargetTile(tile, field);
|
||||||
pathTiles.add(tile1);
|
pathTiles.add(tile1);
|
||||||
if(tile1 == tile || tile1 == null ||
|
if(tile1 == tile || tile1 == null ||
|
||||||
(finder == 0 && (otherCores != Groups.build.count(b -> b instanceof CoreBlock.CoreBuild && b.team != team) || tile1.build instanceof CoreBlock.CoreBuild)))
|
(finder == 0 && (otherCores != Groups.build.count(b -> b instanceof CoreBlock.CoreBuild && b.team != team) || tile1.build instanceof CoreBlock.CoreBuild))) return;
|
||||||
return tile1;
|
getNextTile(tile1, cost, team, finder);
|
||||||
return getNextTile(tile1, cost, team, finder);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package informatis.ui.window;
|
|||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
import arc.func.*;
|
import arc.func.*;
|
||||||
|
import arc.math.Mathf;
|
||||||
import arc.scene.*;
|
import arc.scene.*;
|
||||||
import arc.scene.event.*;
|
import arc.scene.event.*;
|
||||||
import informatis.core.*;
|
import informatis.core.*;
|
||||||
@@ -43,7 +44,7 @@ public class UnitWindow extends Window {
|
|||||||
super(Icon.units, "unit");
|
super(Icon.units, "unit");
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: add new UnitInfoDisplay(), new WeaponDisplay();
|
//TODO: add weapons
|
||||||
@Override
|
@Override
|
||||||
protected void build(Table table) {
|
protected void build(Table table) {
|
||||||
table.top().background(Styles.black8);
|
table.top().background(Styles.black8);
|
||||||
@@ -81,82 +82,87 @@ public class UnitWindow extends Window {
|
|||||||
}).margin(12f);
|
}).margin(12f);
|
||||||
}).margin(12f).row();
|
}).margin(12f).row();
|
||||||
|
|
||||||
if(target instanceof Payloadc || target instanceof Statusc) {
|
table.image().color((target == null ? player.unit() : target).team().color).visible(()->target instanceof Payloadc || target instanceof Statusc).height(4f).growX().row();
|
||||||
table.image().color((target == null ? player.unit() : target).team().color).height(4f).growX().row();
|
|
||||||
|
|
||||||
table.table(state -> {
|
table.table(state -> {
|
||||||
state.left();
|
state.left();
|
||||||
final Cons<Table> rebuildPayload = t -> {
|
final Cons<Table> rebuildPayload = t -> {
|
||||||
t.left();
|
t.left();
|
||||||
if (target instanceof Payloadc payload) {
|
if (target instanceof Payloadc payloader) {
|
||||||
Seq<Payload> payloads = payload.payloads();
|
Seq<Payload> payloads = payloader.payloads();
|
||||||
for (int i = 0, m = payload.payloads().size; i < m; i++) {
|
for (int i = 0, m = payloader.payloads().size; i < m; i++) {
|
||||||
t.image(payloads.get(i).icon()).size(iconSmall);
|
Payload payload = payloads.get(i);
|
||||||
if ((i + 1) % Math.max(6, Math.round((window.getWidth() - 24) / iconSmall)) == 0) t.row();
|
Image image = new Image(payload.icon());
|
||||||
|
image.clicked(()->ui.content.show(payload.content()));
|
||||||
|
image.hovered(()->image.setColor(Tmp.c1.set(image.color).lerp(Color.lightGray, Mathf.clamp(Time.delta))));
|
||||||
|
image.exited(()->image.setColor(Tmp.c1.set(image.color).lerp(Color.white, Mathf.clamp(Time.delta))));
|
||||||
|
t.add(image).size(iconSmall).tooltip(l -> l.label(() -> payload.content().localizedName).style(Styles.outlineLabel));
|
||||||
|
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) return;
|
||||||
|
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()) {
|
||||||
|
Image image = new Image(effect.uiIcon);
|
||||||
|
image.clicked(()->ui.content.show(effect));
|
||||||
|
image.hovered(()->image.setColor(Tmp.c1.set(image.color).lerp(Color.lightGray, Mathf.clamp(Time.delta))));
|
||||||
|
image.exited(()->image.setColor(Tmp.c1.set(image.color).lerp(Color.white, Mathf.clamp(Time.delta))));
|
||||||
|
t.add(image).size(iconSmall).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 Cons<Table> rebuildStatus = t -> {
|
final float[] lastWidth1 = {0};
|
||||||
t.top().left();
|
state.table(rebuildPayload).update(t -> {
|
||||||
if (target instanceof Statusc st) {
|
t.left();
|
||||||
Bits applied = st.statusBits();
|
if (lastWidth1[0] != window.getWidth()) {
|
||||||
if (applied != null) {
|
lastWidth1[0] = window.getWidth();
|
||||||
Seq<StatusEffect> contents = Vars.content.statusEffects();
|
t.clear();
|
||||||
for (int i = 0, m = Vars.content.statusEffects().size; i < m; i++) {
|
rebuildPayload.get(t);
|
||||||
StatusEffect effect = contents.get(i);
|
} else if (target instanceof Payloadc payload) {
|
||||||
if (applied.get(effect.id) && !effect.isHidden()) {
|
if (usedPayload != payload.payloadUsed()) {
|
||||||
t.image(effect.uiIcon).size(iconSmall).get()
|
usedPayload = payload.payloadUsed();
|
||||||
.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();
|
t.clear();
|
||||||
rebuildPayload.get(t);
|
rebuildPayload.get(t);
|
||||||
}
|
}
|
||||||
}).grow().row();
|
} else {
|
||||||
|
usedPayload = -1;
|
||||||
|
t.clear();
|
||||||
|
rebuildPayload.get(t);
|
||||||
|
}
|
||||||
|
}).grow().row();
|
||||||
|
|
||||||
final float[] lastWidth2 = {0};
|
final float[] lastWidth2 = {0};
|
||||||
state.table(rebuildStatus).update(t -> {
|
state.table(rebuildStatus).update(t -> {
|
||||||
t.left();
|
t.left();
|
||||||
if (lastWidth2[0] != window.getWidth()) {
|
if (lastWidth2[0] != window.getWidth()) {
|
||||||
lastWidth2[0] = window.getWidth();
|
lastWidth2[0] = window.getWidth();
|
||||||
t.clear();
|
t.clear();
|
||||||
rebuildStatus.get(t);
|
rebuildStatus.get(t);
|
||||||
} else if (target instanceof Statusc st) {
|
} else if (target instanceof Statusc st) {
|
||||||
Bits applied = st.statusBits();
|
Bits applied = st.statusBits();
|
||||||
if (applied != null && !statuses.equals(applied)) {
|
if (applied != null && !statuses.equals(applied)) {
|
||||||
statuses.set(applied);
|
statuses.set(applied);
|
||||||
t.clear();
|
|
||||||
rebuildStatus.get(t);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
statuses.clear();
|
|
||||||
t.clear();
|
t.clear();
|
||||||
rebuildStatus.get(t);
|
rebuildStatus.get(t);
|
||||||
}
|
}
|
||||||
}).grow();
|
} else {
|
||||||
}).pad(12f).growX().row();
|
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();
|
table.image().color((target==null?player.unit():target).team().color).height(4f).growX().row();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user