mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-10 12:09:27 +02:00
Merge branch 'Sharlottes:master' into master
This commit is contained in:
@@ -4,27 +4,19 @@ import arc.graphics.g2d.*;
|
|||||||
import arc.math.Mathf;
|
import arc.math.Mathf;
|
||||||
import arc.scene.style.*;
|
import arc.scene.style.*;
|
||||||
import arc.struct.Seq;
|
import arc.struct.Seq;
|
||||||
import arc.util.Nullable;
|
import arc.util.*;
|
||||||
import arc.util.Strings;
|
|
||||||
import mindustry.Vars;
|
import mindustry.Vars;
|
||||||
import mindustry.core.UI;
|
import mindustry.core.UI;
|
||||||
import mindustry.entities.bullet.BulletType;
|
import mindustry.entities.bullet.*;
|
||||||
import mindustry.entities.bullet.LightningBulletType;
|
import mindustry.gen.*;
|
||||||
import mindustry.gen.BlockUnitUnit;
|
|
||||||
import mindustry.gen.Groups;
|
|
||||||
import mindustry.gen.Teamc;
|
|
||||||
import mindustry.gen.Unit;
|
|
||||||
import mindustry.type.UnitType;
|
import mindustry.type.UnitType;
|
||||||
import mindustry.type.weapons.PointDefenseWeapon;
|
import mindustry.type.weapons.*;
|
||||||
import mindustry.type.weapons.RepairBeamWeapon;
|
|
||||||
import mindustry.world.Tile;
|
import mindustry.world.Tile;
|
||||||
|
|
||||||
import java.lang.reflect.*;
|
import java.lang.reflect.*;
|
||||||
|
|
||||||
import static unitinfo.SVars.locked;
|
import static unitinfo.SVars.*;
|
||||||
import static unitinfo.SVars.target;
|
import static arc.Core.*;
|
||||||
import static arc.Core.input;
|
|
||||||
import static arc.Core.settings;
|
|
||||||
import static mindustry.Vars.player;
|
import static mindustry.Vars.player;
|
||||||
|
|
||||||
public class SUtils {
|
public class SUtils {
|
||||||
@@ -84,7 +76,7 @@ public class SUtils {
|
|||||||
return b.speed * a * Mathf.pow(1 - b.drag, b.lifetime / 2) * b.lifetime +
|
return b.speed * a * Mathf.pow(1 - b.drag, b.lifetime / 2) * b.lifetime +
|
||||||
Math.max(b.lightning > 0 || b instanceof LightningBulletType ? (b.lightningLength + b.lightningLengthRand) * 6 : 0,
|
Math.max(b.lightning > 0 || b instanceof LightningBulletType ? (b.lightningLength + b.lightningLengthRand) * 6 : 0,
|
||||||
b.fragBullet != null ? bulletRange(b.fragBullet) * b.fragLifeMax * b.fragVelocityMax : b.splashDamageRadius);
|
b.fragBullet != null ? bulletRange(b.fragBullet) * b.fragLifeMax * b.fragVelocityMax : b.splashDamageRadius);
|
||||||
};
|
}
|
||||||
|
|
||||||
public static float unitRange(UnitType u) {
|
public static float unitRange(UnitType u) {
|
||||||
final float[] mrng = {0};
|
final float[] mrng = {0};
|
||||||
@@ -100,4 +92,14 @@ public class SUtils {
|
|||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
return field.get(ut);
|
return field.get(ut);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static boolean isOutCamera(float x, float y) {
|
||||||
|
return !isInCamera(x, y, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isInCamera(float x, float y, float size) {
|
||||||
|
Tmp.r2.setCentered(x, y, size);
|
||||||
|
return Tmp.r1.overlaps(Tmp.r2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
package unitinfo;
|
package unitinfo;
|
||||||
|
|
||||||
import unitinfo.core.*;
|
import unitinfo.shaders.*;
|
||||||
import unitinfo.shaders.LineShader;
|
|
||||||
import unitinfo.shaders.RangeShader;
|
|
||||||
import arc.graphics.g2d.TextureRegion;
|
import arc.graphics.g2d.TextureRegion;
|
||||||
import mindustry.gen.Teamc;
|
import mindustry.gen.Teamc;
|
||||||
|
|
||||||
@@ -11,10 +9,8 @@ import static arc.Core.atlas;
|
|||||||
public class SVars {
|
public class SVars {
|
||||||
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 = new RangeShader();
|
||||||
public static LineShader lineShader;
|
|
||||||
public static Teamc target;
|
public static Teamc target;
|
||||||
public static boolean locked;
|
public static boolean locked;
|
||||||
public static boolean jsonGen = false;
|
|
||||||
public static float uiResumeRate = 3 * 60f; //default 3s
|
public static float uiResumeRate = 3 * 60f; //default 3s
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,109 +0,0 @@
|
|||||||
package unitinfo.core;
|
|
||||||
|
|
||||||
import arc.Core;
|
|
||||||
import arc.struct.Seq;
|
|
||||||
import arc.util.*;
|
|
||||||
import mindustry.*;
|
|
||||||
import mindustry.ctype.*;
|
|
||||||
import mindustry.entities.abilities.*;
|
|
||||||
import mindustry.entities.bullet.*;
|
|
||||||
import mindustry.type.*;
|
|
||||||
import mindustry.world.*;
|
|
||||||
import org.hjson.*;
|
|
||||||
|
|
||||||
import java.lang.reflect.*;
|
|
||||||
|
|
||||||
import static mindustry.Vars.modDirectory;
|
|
||||||
|
|
||||||
public class ContentJSON {
|
|
||||||
static JsonValue parse(Object object) {
|
|
||||||
if(object instanceof Integer val) return JsonObject.valueOf(val);
|
|
||||||
else if(object instanceof Double val) return JsonObject.valueOf(val);
|
|
||||||
else if(object instanceof Float val) return JsonObject.valueOf(val);
|
|
||||||
else if(object instanceof Long val) return JsonObject.valueOf(val);
|
|
||||||
else if(object instanceof String val) return JsonObject.valueOf(val);
|
|
||||||
else if(object instanceof Boolean val) return JsonObject.valueOf(val);
|
|
||||||
else if(object instanceof Content) {
|
|
||||||
if(object instanceof Block c) return getContent(c, Block.class, new JsonObject());
|
|
||||||
if(object instanceof BulletType c) return getContent(c, BulletType.class, new JsonObject());
|
|
||||||
if(object instanceof Item c) return getContent(c, Item.class, new JsonObject());
|
|
||||||
if(object instanceof Liquid c) return getContent(c, Liquid.class, new JsonObject());
|
|
||||||
if(object instanceof UnitType c) return getContent(c, UnitType.class, new JsonObject());
|
|
||||||
if(object instanceof Weather c) return getContent(c, Weather.class, new JsonObject());
|
|
||||||
}
|
|
||||||
else if(object instanceof Weapon val) return getContent(val, new JsonObject());
|
|
||||||
else if(object instanceof Ability val) return getContent(val, new JsonObject());
|
|
||||||
else if(object instanceof Seq seq && seq.any()) {
|
|
||||||
JsonArray array = new JsonArray();
|
|
||||||
for(int i = 0; i < seq.size; i++) {
|
|
||||||
if(seq.get(i) != null) array.add(parse(seq.get(i)));
|
|
||||||
}
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if(object.getClass().isArray()) {
|
|
||||||
JsonArray array = new JsonArray();
|
|
||||||
for(int i = 0; i < Array.getLength(object); i++) {
|
|
||||||
if(Array.get(object, i) != null) array.add(parse(Array.get(object, i)));
|
|
||||||
}
|
|
||||||
return array;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return JsonObject.valueOf(object.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
static <T extends Object> JsonObject getContent(T cont, JsonObject obj) {
|
|
||||||
return getContent(cont, cont.getClass(), obj);
|
|
||||||
}
|
|
||||||
|
|
||||||
static JsonObject getContent(Object cont, Class objClass, JsonObject obj) {
|
|
||||||
obj.add("type", objClass.getName());
|
|
||||||
for(Field field : objClass.getFields()){
|
|
||||||
if(Modifier.isStatic(field.getModifiers())) continue;
|
|
||||||
try {
|
|
||||||
String name = field.getName();
|
|
||||||
Object object = field.get(cont);
|
|
||||||
Object preval = obj.get(name);
|
|
||||||
if(preval != null) obj.set(name, preval + " or " + object);
|
|
||||||
else {
|
|
||||||
if(object == null) obj.add(name, "null");
|
|
||||||
else if(!cont.getClass().isAssignableFrom(field.get(cont).getClass()) && !field.get(cont).getClass().isAssignableFrom(cont.getClass())){
|
|
||||||
obj.add(name, parse(object));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} catch(Throwable e) {
|
|
||||||
try {
|
|
||||||
Log.info(e + " ### " + cont + " ### " + objClass + " ### " + cont.getClass() + " ### " + field.get(cont));
|
|
||||||
} catch (IllegalAccessException ex) {
|
|
||||||
ex.printStackTrace();
|
|
||||||
}
|
|
||||||
obj.add(field.getName(), "### ERROR ###");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void save() {
|
|
||||||
for(Seq<Content> content : Vars.content.getContentMap()) {
|
|
||||||
if(content.isEmpty()) continue;
|
|
||||||
|
|
||||||
JsonObject data = new JsonObject();
|
|
||||||
content.each(cont -> {
|
|
||||||
JsonObject obj = new JsonObject();
|
|
||||||
getContent(cont, obj);
|
|
||||||
|
|
||||||
String name = cont.toString();
|
|
||||||
if(cont instanceof MappableContent mapCont) name = mapCont.name;
|
|
||||||
data.add(name, obj);
|
|
||||||
});
|
|
||||||
try {
|
|
||||||
modDirectory.child("unitinfo").child(content.peek().getContentType().toString() + ".json").writeString(data.toString(Stringify.FORMATTED));
|
|
||||||
} catch (Throwable e){
|
|
||||||
Log.warn(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Log.info("JSON file is completely updated!");
|
|
||||||
Core.app.exit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package unitinfo.ui;
|
package unitinfo.core;
|
||||||
|
|
||||||
import arc.func.Boolf;
|
import arc.func.Boolf;
|
||||||
import arc.func.Cons;
|
import arc.func.Cons;
|
||||||
@@ -12,10 +12,9 @@ import mindustry.content.Blocks;
|
|||||||
import mindustry.game.Team;
|
import mindustry.game.Team;
|
||||||
import mindustry.world.Block;
|
import mindustry.world.Block;
|
||||||
import mindustry.world.Tile;
|
import mindustry.world.Tile;
|
||||||
import unitinfo.ui.windows.MapEditorDisplay;
|
import unitinfo.ui.windows.*;
|
||||||
|
|
||||||
import static unitinfo.ui.windows.MapEditorDisplay.drawTeam;
|
import static unitinfo.ui.windows.MapEditorWindow.*;
|
||||||
import static unitinfo.ui.windows.MapEditorDisplay.drawBlock;
|
|
||||||
import static unitinfo.ui.windows.Windows.editorTable;
|
import static unitinfo.ui.windows.Windows.editorTable;
|
||||||
import static mindustry.Vars.world;
|
import static mindustry.Vars.world;
|
||||||
|
|
||||||
@@ -114,7 +113,7 @@ public enum EditorTool{
|
|||||||
|
|
||||||
Boolf<Tile> tester;
|
Boolf<Tile> tester;
|
||||||
Cons<Tile> setter;
|
Cons<Tile> setter;
|
||||||
Block drawBlock = MapEditorDisplay.drawBlock;
|
Block drawBlock = MapEditorWindow.drawBlock;
|
||||||
|
|
||||||
if(drawBlock.isOverlay()){
|
if(drawBlock.isOverlay()){
|
||||||
Block dest = tile.overlay();
|
Block dest = tile.overlay();
|
||||||
@@ -1,29 +1,22 @@
|
|||||||
package unitinfo.core;
|
package unitinfo.core;
|
||||||
|
|
||||||
import arc.input.KeyCode;
|
import arc.input.KeyCode;
|
||||||
import arc.scene.ui.layout.Table;
|
|
||||||
import unitinfo.shaders.*;
|
|
||||||
import unitinfo.ui.*;
|
import unitinfo.ui.*;
|
||||||
import unitinfo.ui.draws.OverDraws;
|
import unitinfo.ui.draws.OverDraws;
|
||||||
import unitinfo.ui.windows.*;
|
import unitinfo.ui.windows.*;
|
||||||
import arc.*;
|
import arc.*;
|
||||||
import arc.struct.*;
|
|
||||||
import mindustry.*;
|
import mindustry.*;
|
||||||
import mindustry.game.EventType.*;
|
import mindustry.game.EventType.*;
|
||||||
import mindustry.mod.*;
|
import mindustry.mod.*;
|
||||||
|
|
||||||
import static unitinfo.SVars.*;
|
import static unitinfo.SVars.*;
|
||||||
import static arc.Core.*;
|
import static arc.Core.*;
|
||||||
import static mindustry.Vars.*;
|
|
||||||
import static unitinfo.SUtils.*;
|
import static unitinfo.SUtils.*;
|
||||||
import static unitinfo.ui.windows.WindowManager.windows;
|
import static unitinfo.ui.WindowManager.windows;
|
||||||
|
|
||||||
public class Main extends Mod {
|
public class Main extends Mod {
|
||||||
@Override
|
@Override
|
||||||
public void init(){
|
public void init(){
|
||||||
turretRange = new RangeShader();
|
|
||||||
lineShader = new LineShader();
|
|
||||||
|
|
||||||
Core.app.post(() -> {
|
Core.app.post(() -> {
|
||||||
Mods.ModMeta meta = Vars.mods.locateMod("unitinfo").meta;
|
Mods.ModMeta meta = Vars.mods.locateMod("unitinfo").meta;
|
||||||
meta.displayName = "[#B5FFD9]Unit Information[]";
|
meta.displayName = "[#B5FFD9]Unit Information[]";
|
||||||
@@ -31,49 +24,35 @@ public class Main extends Mod {
|
|||||||
meta.description = bundle.get("shar-description");
|
meta.description = bundle.get("shar-description");
|
||||||
});
|
});
|
||||||
|
|
||||||
Events.run(Trigger.class, () -> {
|
Events.run(Trigger.update, () -> {
|
||||||
try {
|
try {
|
||||||
BarInfo.getInfo(getTarget());
|
BarInfo.getInfo(getTarget());
|
||||||
} catch (IllegalAccessException | NoSuchFieldException err) {
|
} catch (IllegalAccessException | NoSuchFieldException err) {
|
||||||
err.printStackTrace();
|
err.printStackTrace();
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
Events.run(Trigger.update, () -> {
|
|
||||||
target = getTarget();
|
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.keyDown(KeyCode.shiftRight) || input.keyDown(KeyCode.shiftLeft))) {
|
||||||
if(input.keyTap(KeyCode.r)) lockTarget();
|
if(input.keyTap(KeyCode.r)) {
|
||||||
|
if(target==getTarget()) locked = !locked;
|
||||||
|
target = getTarget();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Events.on(ClientLoadEvent.class, e -> {
|
Events.on(ClientLoadEvent.class, e -> {
|
||||||
Windows.load();
|
Windows.load();
|
||||||
|
|
||||||
SettingS.init();
|
SettingS.init();
|
||||||
WindowManager.init();
|
WindowManager.init();
|
||||||
|
DisplayManager.init();
|
||||||
OverDraws.init();
|
OverDraws.init();
|
||||||
OverDrawer.setEvent();
|
OverDrawer.init();
|
||||||
|
|
||||||
Seq.with(scene.root,
|
|
||||||
ui.picker, ui.editor, ui.controls, ui.restart, ui.join, ui.discord,
|
|
||||||
ui.load, ui.custom, ui.language, ui.database, ui.settings, ui.host,
|
|
||||||
ui.paused, ui.about, ui.bans, ui.admins, ui.traces, ui.maps, ui.content,
|
|
||||||
ui.planet, ui.research, ui.mods, ui.schematics, ui.logic
|
|
||||||
).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();
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void lockTarget() {
|
|
||||||
if(target==getTarget()) locked = !locked;
|
|
||||||
target = getTarget();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ import static mindustry.Vars.*;
|
|||||||
|
|
||||||
public class OverDrawer {
|
public class OverDrawer {
|
||||||
|
|
||||||
public static void setEvent(){
|
public static void init(){
|
||||||
Events.run(EventType.Trigger.draw, () -> {
|
Events.run(EventType.Trigger.draw, () -> {
|
||||||
float sin = Mathf.absin(Time.time, 6f, 1f);
|
float sin = Mathf.absin(Time.time, 6f, 1f);
|
||||||
|
|
||||||
@@ -67,13 +67,4 @@ public class OverDrawer {
|
|||||||
for(OverDraw drawer : OverDraws.all) drawer.draw();
|
for(OverDraw drawer : OverDraws.all) drawer.draw();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isOutCamera(float x, float y) {
|
|
||||||
return !isInCamera(x, y, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isInCamera(float x, float y, float size) {
|
|
||||||
Tmp.r2.setCentered(x, y, size);
|
|
||||||
return Tmp.r1.overlaps(Tmp.r2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,9 +106,6 @@ public class SettingS {
|
|||||||
Seq<Seq<SharSetting>> settingSeq = new Seq<>();
|
Seq<Seq<SharSetting>> settingSeq = new Seq<>();
|
||||||
Seq<SharSetting> tapSeq = new Seq<>();
|
Seq<SharSetting> tapSeq = new Seq<>();
|
||||||
addGraphicSlideSetting("barstyle", 0, 0, 5, 1, s -> s == 0 ? bundle.get("default-bar") : s + bundle.get("th-bar"), tapSeq);
|
addGraphicSlideSetting("barstyle", 0, 0, 5, 1, s -> s == 0 ? bundle.get("default-bar") : s + bundle.get("th-bar"), tapSeq);
|
||||||
addGraphicTypeSetting("wavemax", 0, 200,100, true, () -> true, s -> s + "waves", tapSeq);
|
|
||||||
addGraphicCheckSetting("pastwave", false, tapSeq);
|
|
||||||
addGraphicCheckSetting("emptywave", true, tapSeq);
|
|
||||||
addGraphicCheckSetting("schem", !mobile, tapSeq);
|
addGraphicCheckSetting("schem", !mobile, tapSeq);
|
||||||
|
|
||||||
//TODO: remove all drawing settings
|
//TODO: remove all drawing settings
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
package unitinfo.shaders;
|
|
||||||
|
|
||||||
import arc.Core;
|
|
||||||
import arc.graphics.gl.Shader;
|
|
||||||
import arc.scene.ui.layout.Scl;
|
|
||||||
import arc.util.Time;
|
|
||||||
import mindustry.Vars;
|
|
||||||
|
|
||||||
public class LineShader extends Shader {
|
|
||||||
public LineShader() {
|
|
||||||
super(Core.files.internal("shaders/screenspace.vert"), Vars.tree.get("shaders/line.frag"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply(){
|
|
||||||
setUniformf("u_dp", Scl.scl(1f));
|
|
||||||
setUniformf("u_time", Time.time / Scl.scl(1f));
|
|
||||||
setUniformf("u_offset",
|
|
||||||
Core.camera.position.x - Core.camera.width / 2,
|
|
||||||
Core.camera.position.y - Core.camera.height / 2);
|
|
||||||
setUniformf("u_texsize", Core.camera.width, Core.camera.height);
|
|
||||||
setUniformf("u_invsize", 1f/Core.camera.width, 1f/Core.camera.height);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
28
src/unitinfo/ui/DisplayManager.java
Normal file
28
src/unitinfo/ui/DisplayManager.java
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
package unitinfo.ui;
|
||||||
|
|
||||||
|
import arc.scene.ui.layout.Table;
|
||||||
|
import arc.struct.Seq;
|
||||||
|
import unitinfo.ui.display.ElementDisplay;
|
||||||
|
import unitinfo.ui.display.SchemDisplay;
|
||||||
|
import unitinfo.ui.display.WaveInfoDisplay;
|
||||||
|
|
||||||
|
import static arc.Core.scene;
|
||||||
|
import static mindustry.Vars.ui;
|
||||||
|
|
||||||
|
public class DisplayManager {
|
||||||
|
public static void init() {
|
||||||
|
//layout debug
|
||||||
|
Seq.with(scene.root,
|
||||||
|
ui.picker, ui.editor, ui.controls, ui.restart, ui.join, ui.discord,
|
||||||
|
ui.load, ui.custom, ui.language, ui.database, ui.settings, ui.host,
|
||||||
|
ui.paused, ui.about, ui.bans, ui.admins, ui.traces, ui.maps, ui.content,
|
||||||
|
ui.planet, ui.research, ui.mods, ui.schematics, ui.logic
|
||||||
|
).each(dialog-> dialog.addChild(new ElementDisplay(dialog)));
|
||||||
|
|
||||||
|
//schem quick-slot
|
||||||
|
Table table = ((Table) scene.find("minimap/position")).row();
|
||||||
|
table.add(new SchemDisplay());
|
||||||
|
new WaveInfoDisplay().addWaveInfoTable();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,11 @@
|
|||||||
package unitinfo.ui.windows;
|
package unitinfo.ui;
|
||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.*;
|
import mindustry.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
|
import unitinfo.ui.windows.Window;
|
||||||
|
|
||||||
public class WindowManager {
|
public class WindowManager {
|
||||||
public static Seq<Window> windows = new Seq<>();
|
public static Seq<Window> windows = new Seq<>();
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package unitinfo.ui;
|
package unitinfo.ui.display;
|
||||||
|
|
||||||
import arc.graphics.g2d.Draw;
|
import arc.graphics.g2d.Draw;
|
||||||
import arc.graphics.g2d.Lines;
|
import arc.graphics.g2d.Lines;
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package unitinfo.ui;
|
package unitinfo.ui.display;
|
||||||
|
|
||||||
import unitinfo.SUtils;
|
import unitinfo.SUtils;
|
||||||
import arc.Core;
|
import arc.Core;
|
||||||
@@ -20,6 +20,7 @@ import mindustry.gen.*;
|
|||||||
import mindustry.graphics.Pal;
|
import mindustry.graphics.Pal;
|
||||||
import mindustry.ui.Styles;
|
import mindustry.ui.Styles;
|
||||||
import mindustry.ui.dialogs.*;
|
import mindustry.ui.dialogs.*;
|
||||||
|
import unitinfo.ui.Updatable;
|
||||||
|
|
||||||
import static arc.Core.*;
|
import static arc.Core.*;
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
@@ -1,10 +1,13 @@
|
|||||||
package unitinfo.ui;
|
package unitinfo.ui.display;
|
||||||
|
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.Pal;
|
import mindustry.graphics.Pal;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
|
import mindustry.world.Block;
|
||||||
|
import mindustry.world.Tile;
|
||||||
|
import mindustry.world.blocks.environment.Floor;
|
||||||
|
|
||||||
import static unitinfo.SUtils.*;
|
import static unitinfo.SUtils.*;
|
||||||
import static unitinfo.SVars.*;
|
import static unitinfo.SVars.*;
|
||||||
@@ -20,11 +23,33 @@ public class WaveInfoDisplay {
|
|||||||
table.table(head -> {
|
table.table(head -> {
|
||||||
head.table(image -> {
|
head.table(image -> {
|
||||||
image.left();
|
image.left();
|
||||||
image.image(() -> getTile() == null || getTile().floor().uiIcon == error ? clear : getTile().floor().uiIcon).size(iconSmall);
|
image.image(() -> {
|
||||||
image.image(() -> getTile() == null || getTile().overlay().uiIcon == error ? clear : getTile().overlay().uiIcon).size(iconSmall);
|
Tile tile = getTile();
|
||||||
image.image(() -> getTile() == null || getTile().block().uiIcon == error ? clear : getTile().block().uiIcon).size(iconSmall);
|
if(tile == null) return clear;
|
||||||
|
Floor floor = tile.floor();
|
||||||
|
if(floor.uiIcon == error) return clear;
|
||||||
|
return floor.uiIcon;
|
||||||
|
}).size(iconSmall);
|
||||||
|
image.image(() -> {
|
||||||
|
Tile tile = getTile();
|
||||||
|
if(tile == null) return clear;
|
||||||
|
Floor floor = tile.overlay();
|
||||||
|
if(floor.uiIcon == error) return clear;
|
||||||
|
return floor.uiIcon;
|
||||||
|
}).size(iconSmall);
|
||||||
|
image.image(() -> {
|
||||||
|
Tile tile = getTile();
|
||||||
|
if(tile == null) return clear;
|
||||||
|
Block floor = tile.block();
|
||||||
|
if(floor.uiIcon == error) return clear;
|
||||||
|
return floor.uiIcon;
|
||||||
|
}).size(iconSmall);
|
||||||
});
|
});
|
||||||
head.label(() -> Strings.format("(@, @)", getTile() == null ? "NaN" : getTile().x, getTile() == null ? "NaN" : getTile().y)).center();
|
head.label(() -> {
|
||||||
|
Tile tile = getTile();
|
||||||
|
if(tile == null) return "(NaN, NaN)";
|
||||||
|
return Strings.format("(@, @)", tile.x, tile.y);
|
||||||
|
}).center();
|
||||||
});
|
});
|
||||||
table.row();
|
table.row();
|
||||||
table.image().height(4f).color(Pal.gray).growX().row();
|
table.image().height(4f).color(Pal.gray).growX().row();
|
||||||
@@ -3,7 +3,7 @@ package unitinfo.ui.draws;
|
|||||||
import arc.scene.style.TextureRegionDrawable;
|
import arc.scene.style.TextureRegionDrawable;
|
||||||
import mindustry.gen.Groups;
|
import mindustry.gen.Groups;
|
||||||
|
|
||||||
import static unitinfo.core.OverDrawer.isInCamera;
|
import static unitinfo.SUtils.*;
|
||||||
import static arc.Core.settings;
|
import static arc.Core.settings;
|
||||||
|
|
||||||
public class BlockDraw extends OverDraw {
|
public class BlockDraw extends OverDraw {
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import mindustry.world.blocks.defense.turrets.TractorBeamTurret;
|
|||||||
import mindustry.world.blocks.defense.turrets.Turret;
|
import mindustry.world.blocks.defense.turrets.Turret;
|
||||||
|
|
||||||
import static unitinfo.SVars.turretRange;
|
import static unitinfo.SVars.turretRange;
|
||||||
import static unitinfo.core.OverDrawer.isInCamera;
|
import static unitinfo.SUtils.*;
|
||||||
import static arc.Core.*;
|
import static arc.Core.*;
|
||||||
import static mindustry.Vars.player;
|
import static mindustry.Vars.player;
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,7 @@ import mindustry.world.blocks.units.CommandCenter;
|
|||||||
|
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import static unitinfo.core.OverDrawer.isInCamera;
|
import static unitinfo.SUtils.*;
|
||||||
import static unitinfo.core.OverDrawer.isOutCamera;
|
|
||||||
import static arc.Core.settings;
|
import static arc.Core.settings;
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
|
|||||||
@@ -26,13 +26,13 @@ import mindustry.world.blocks.storage.CoreBlock;
|
|||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class CoreDisplay extends Window implements Updatable {
|
public class CoreWindow extends Window implements Updatable {
|
||||||
Vec2 scrollPos = new Vec2(0, 0);
|
Vec2 scrollPos = new Vec2(0, 0);
|
||||||
Table window;
|
Table window;
|
||||||
float heat;
|
float heat;
|
||||||
ObjectMap<Team, ItemData> itemData = new ObjectMap<>();
|
ObjectMap<Team, ItemData> itemData = new ObjectMap<>();
|
||||||
|
|
||||||
public CoreDisplay() {
|
public CoreWindow() {
|
||||||
super(Icon.list, "core");
|
super(Icon.list, "core");
|
||||||
resetUsed();
|
resetUsed();
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,12 @@
|
|||||||
package unitinfo.ui.windows;
|
package unitinfo.ui.windows;
|
||||||
|
|
||||||
import arc.Events;
|
import arc.Events;
|
||||||
import arc.graphics.g2d.Draw;
|
import arc.graphics.g2d.*;
|
||||||
import arc.graphics.g2d.Lines;
|
|
||||||
import arc.math.geom.Geometry;
|
import arc.math.geom.Geometry;
|
||||||
import mindustry.editor.MapEditor;
|
import mindustry.editor.MapEditor;
|
||||||
import mindustry.game.EventType;
|
import mindustry.game.EventType;
|
||||||
import mindustry.graphics.Layer;
|
import mindustry.graphics.Layer;
|
||||||
|
import unitinfo.core.EditorTool;
|
||||||
import unitinfo.ui.*;
|
import unitinfo.ui.*;
|
||||||
import arc.Core;
|
import arc.Core;
|
||||||
import arc.func.*;
|
import arc.func.*;
|
||||||
@@ -31,7 +31,7 @@ import mindustry.world.*;
|
|||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class MapEditorDisplay 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;
|
Table window;
|
||||||
TextField search;
|
TextField search;
|
||||||
@@ -39,13 +39,14 @@ public class MapEditorDisplay extends Window implements Updatable {
|
|||||||
final Vec2[][] brushPolygons = new Vec2[MapEditor.brushSizes.length][0];
|
final Vec2[][] brushPolygons = new Vec2[MapEditor.brushSizes.length][0];
|
||||||
float heat;
|
float heat;
|
||||||
float brushSize = -1;
|
float brushSize = -1;
|
||||||
boolean hold = false;
|
|
||||||
int pastX, pastY;
|
boolean drawing;
|
||||||
|
int lastx, lasty;
|
||||||
|
|
||||||
public static Team drawTeam = Team.sharded;
|
public static Team drawTeam = Team.sharded;
|
||||||
public static Block drawBlock = Blocks.router;
|
public static Block drawBlock = Blocks.router;
|
||||||
|
|
||||||
public MapEditorDisplay() {
|
public MapEditorWindow() {
|
||||||
super(Icon.map, "editor");
|
super(Icon.map, "editor");
|
||||||
|
|
||||||
for(int i = 0; i < MapEditor.brushSizes.length; i++){
|
for(int i = 0; i < MapEditor.brushSizes.length; i++){
|
||||||
@@ -71,8 +72,9 @@ public class MapEditorDisplay extends Window implements Updatable {
|
|||||||
Draw.reset();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Tile tile = world.tileWorld(Core.input.mouseWorldX(), Core.input.mouseWorldY());
|
||||||
|
if(tile == null || tool == null || brushSize < 1) return;
|
||||||
|
|
||||||
if(tool==null) return;
|
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for(int i = 0; i < MapEditor.brushSizes.length; i++){
|
for(int i = 0; i < MapEditor.brushSizes.length; i++){
|
||||||
if(brushSize == MapEditor.brushSizes[i]){
|
if(brushSize == MapEditor.brushSizes[i]){
|
||||||
@@ -83,31 +85,24 @@ public class MapEditorDisplay extends Window implements Updatable {
|
|||||||
Lines.stroke(Scl.scl(2f), Pal.accent);
|
Lines.stroke(Scl.scl(2f), Pal.accent);
|
||||||
|
|
||||||
if((!drawBlock.isMultiblock() || tool == EditorTool.eraser) && tool != EditorTool.fill){
|
if((!drawBlock.isMultiblock() || tool == EditorTool.eraser) && tool != EditorTool.fill){
|
||||||
if(tool == EditorTool.line && hold){
|
if(tool == EditorTool.line && drawing){
|
||||||
Vec2 v = Core.input.mouseWorld();
|
Lines.poly(brushPolygons[index], lastx, lasty, scaling);
|
||||||
Lines.poly(brushPolygons[index], pastX, pastY, scaling);
|
Lines.poly(brushPolygons[index], tile.x*8, tile.y*8, scaling);
|
||||||
float vx = Mathf.floor(v.x/8)*8-4, vy = Mathf.floor(v.y/8)*8-4;
|
|
||||||
Lines.poly(brushPolygons[index], vx, vy, scaling);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if((tool.edit || (tool == EditorTool.line && !hold)) && (!mobile || hold)){
|
if((tool.edit || (tool == EditorTool.line && !drawing)) && (!mobile || drawing)){
|
||||||
//pencil square outline
|
|
||||||
Vec2 v = Core.input.mouseWorld();
|
|
||||||
float vx = Mathf.floor(v.x/8)*8-4, vy = Mathf.floor(v.y/8)*8-4;
|
|
||||||
if(tool == EditorTool.pencil && tool.mode == 1){
|
if(tool == EditorTool.pencil && tool.mode == 1){
|
||||||
Lines.square(vx, vy, scaling * (brushSize + 0.5f));
|
Lines.square(tile.x*8, tile.y*8, scaling * (brushSize + 0.5f));
|
||||||
}else{
|
}else{
|
||||||
Lines.poly(brushPolygons[index], vx, vy, scaling);
|
Lines.poly(brushPolygons[index], tile.x*8-4, tile.y*8-4, scaling);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if((tool.edit || tool == EditorTool.line) && (!mobile || hold)){
|
if((tool.edit || tool == EditorTool.line) && (!mobile || drawing)){
|
||||||
Vec2 v = Core.input.mouseWorld();
|
|
||||||
float vx = Mathf.floor(v.x/8)*8-4, vy = Mathf.floor(v.y/8)*8-4;
|
|
||||||
float offset = (drawBlock.size % 2 == 0 ? scaling / 2f : 0f);
|
float offset = (drawBlock.size % 2 == 0 ? scaling / 2f : 0f);
|
||||||
Lines.square(
|
Lines.square(
|
||||||
vx + scaling / 2f + offset,
|
tile.x*8 + scaling / 2f + offset,
|
||||||
vy + scaling / 2f + offset,
|
tile.y*8 + scaling / 2f + offset,
|
||||||
scaling * drawBlock.size / 2f);
|
scaling * drawBlock.size / 2f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -137,29 +132,21 @@ public class MapEditorDisplay extends Window implements Updatable {
|
|||||||
heat = 0f;
|
heat = 0f;
|
||||||
resetPane();
|
resetPane();
|
||||||
}
|
}
|
||||||
if(tool != null && drawBlock != null && !hasMouse()) {
|
|
||||||
|
Tile tile = world.tileWorld(Core.input.mouseWorldX(), Core.input.mouseWorldY());
|
||||||
|
if(tile == null || tool == null || brushSize < 1 || drawBlock == null || hasMouse()) return;
|
||||||
if(Core.input.isTouched()) {
|
if(Core.input.isTouched()) {
|
||||||
if(!(!mobile&&Core.input.keyDown(KeyCode.mouseLeft))) return;
|
if((tool == EditorTool.line && drawing) || (!mobile && !Core.input.keyDown(KeyCode.mouseLeft))) return;
|
||||||
if(tool== EditorTool.line) {
|
drawing = true;
|
||||||
if(!hold) {
|
lastx = tile.x;
|
||||||
pastX = Mathf.round(Core.input.mouseWorldX() / 8);
|
lasty = tile.y;
|
||||||
pastY = Mathf.round(Core.input.mouseWorldY() / 8);
|
tool.touched(lastx, lasty);
|
||||||
}
|
|
||||||
hold = true;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
pastX = Mathf.round(Core.input.mouseWorldX() / 8);
|
if(tool == EditorTool.line && drawing) tool.touchedLine(lastx, lasty, tile.x, tile.y);
|
||||||
pastY = Mathf.round(Core.input.mouseWorldY() / 8);
|
drawing = false;
|
||||||
}
|
lastx = -1;
|
||||||
|
lasty = -1;
|
||||||
tool.touched(pastX, pastY);
|
|
||||||
}
|
|
||||||
else if(tool== EditorTool.line) {
|
|
||||||
if(hold&&pastX>=0&&pastY>=0) tool.touchedLine(pastX, pastY, Mathf.round(Core.input.mouseWorldX() / 8), Mathf.round(Core.input.mouseWorldY() / 8));
|
|
||||||
hold = false;
|
|
||||||
pastX = -1;
|
|
||||||
pastY = -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,7 +171,7 @@ public class MapEditorDisplay extends Window implements Updatable {
|
|||||||
tools.top().left();
|
tools.top().left();
|
||||||
tools.table(title -> title.left().background(Tex.underline2).add("Tools [accent]"+(tool==null?"":tool.name())+"[]")).growX().row();
|
tools.table(title -> title.left().background(Tex.underline2).add("Tools [accent]"+(tool==null?"":tool.name())+"[]")).growX().row();
|
||||||
tools.table(bt->{
|
tools.table(bt->{
|
||||||
Cons<unitinfo.ui.EditorTool> addTool = tool -> {
|
Cons<EditorTool> addTool = tool -> {
|
||||||
ImageButton button = new ImageButton(ui.getIcon(tool.name()), Styles.clearTogglei);
|
ImageButton button = new ImageButton(ui.getIcon(tool.name()), Styles.clearTogglei);
|
||||||
button.clicked(() -> {
|
button.clicked(() -> {
|
||||||
button.toggle();
|
button.toggle();
|
||||||
@@ -203,11 +190,11 @@ public class MapEditorDisplay extends Window implements Updatable {
|
|||||||
bt.stack(button, mode);
|
bt.stack(button, mode);
|
||||||
};
|
};
|
||||||
|
|
||||||
addTool.get(unitinfo.ui.EditorTool.line);
|
addTool.get(EditorTool.line);
|
||||||
addTool.get(unitinfo.ui.EditorTool.pencil);
|
addTool.get(EditorTool.pencil);
|
||||||
addTool.get(unitinfo.ui.EditorTool.eraser);
|
addTool.get(EditorTool.eraser);
|
||||||
addTool.get(unitinfo.ui.EditorTool.fill);
|
addTool.get(EditorTool.fill);
|
||||||
addTool.get(unitinfo.ui.EditorTool.spray);
|
addTool.get(EditorTool.spray);
|
||||||
|
|
||||||
ImageButton grid = new ImageButton(Icon.grid, Styles.clearTogglei);
|
ImageButton grid = new ImageButton(Icon.grid, Styles.clearTogglei);
|
||||||
grid.clicked(() -> {
|
grid.clicked(() -> {
|
||||||
@@ -20,14 +20,14 @@ import mindustry.ui.*;
|
|||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
|
|
||||||
public class PlayerDisplay 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;
|
||||||
ImageButton.ImageButtonStyle ustyle;
|
ImageButton.ImageButtonStyle ustyle;
|
||||||
@Nullable Player target;
|
@Nullable Player target;
|
||||||
float heat;
|
float heat;
|
||||||
|
|
||||||
public PlayerDisplay() {
|
public PlayerWindow() {
|
||||||
super(Icon.players, "player");
|
super(Icon.players, "player");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -13,12 +13,12 @@ import mindustry.gen.Tex;
|
|||||||
import mindustry.graphics.Pal;
|
import mindustry.graphics.Pal;
|
||||||
import mindustry.ui.Styles;
|
import mindustry.ui.Styles;
|
||||||
|
|
||||||
public class ToolDisplay extends Window implements Updatable {
|
public class ToolWindow extends Window implements Updatable {
|
||||||
Vec2 scrollPos = new Vec2(0, 0);
|
Vec2 scrollPos = new Vec2(0, 0);
|
||||||
OverDraw selected;
|
OverDraw selected;
|
||||||
float heat;
|
float heat;
|
||||||
|
|
||||||
public ToolDisplay() {
|
public ToolWindow() {
|
||||||
super(Icon.edit, "tool");
|
super(Icon.edit, "tool");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,12 +30,12 @@ import static unitinfo.SVars.*;
|
|||||||
import static unitinfo.SUtils.*;
|
import static unitinfo.SUtils.*;
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
class UnitDisplay extends Window {
|
class UnitWindow extends Window {
|
||||||
final 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);
|
||||||
final Rect scissor = new Rect();
|
final Rect scissor = new Rect();
|
||||||
Vec2 scrollPos;
|
Vec2 scrollPos;
|
||||||
|
|
||||||
public UnitDisplay() {
|
public UnitWindow() {
|
||||||
super(Icon.units, "unit");
|
super(Icon.units, "unit");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,7 +69,10 @@ class UnitDisplay extends Window {
|
|||||||
}
|
}
|
||||||
image.setDrawable(region);
|
image.setDrawable(region);
|
||||||
});
|
});
|
||||||
image.clicked(Main::lockTarget);
|
image.clicked(()->{
|
||||||
|
if(target==getTarget()) locked = !locked;
|
||||||
|
target = getTarget();
|
||||||
|
});
|
||||||
|
|
||||||
tt.add(image).size(iconMed).padRight(12f);
|
tt.add(image).size(iconMed).padRight(12f);
|
||||||
tt.label(() -> {
|
tt.label(() -> {
|
||||||
@@ -86,7 +89,7 @@ class UnitDisplay extends Window {
|
|||||||
to.label(() -> target == null ? "(" + 0 + ", " + 0 + ")" : "(" + Strings.fixed(target.x() / tilesize, 2) + ", " + Strings.fixed(target.y() / tilesize, 2) + ")").row();
|
to.label(() -> target == null ? "(" + 0 + ", " + 0 + ")" : "(" + Strings.fixed(target.x() / tilesize, 2) + ", " + Strings.fixed(target.y() / tilesize, 2) + ")").row();
|
||||||
to.label(() -> target instanceof Unit u ? "[accent]"+ Strings.fixed(u.armor, 0) + "[] Armor" : "");
|
to.label(() -> target instanceof Unit u ? "[accent]"+ Strings.fixed(u.armor, 0) + "[] Armor" : "");
|
||||||
})).margin(12f).row();
|
})).margin(12f).row();
|
||||||
table.image().height(4f).color(player.team().color).growX().row();
|
table.image().height(4f).color((target==null?player.unit():target).team().color).growX().row();
|
||||||
table.add(new OverScrollPane(new Table(bars -> {
|
table.add(new OverScrollPane(new Table(bars -> {
|
||||||
bars.top();
|
bars.top();
|
||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
package unitinfo.ui.windows;
|
package unitinfo.ui.windows;
|
||||||
|
|
||||||
|
import mindustry.Vars;
|
||||||
import mindustry.game.Team;
|
import mindustry.game.Team;
|
||||||
|
import mindustry.type.UnitType;
|
||||||
import unitinfo.ui.OverScrollPane;
|
import unitinfo.ui.OverScrollPane;
|
||||||
import arc.Events;
|
import arc.Events;
|
||||||
import arc.graphics.Color;
|
import arc.graphics.Color;
|
||||||
@@ -24,12 +26,12 @@ import static arc.Core.settings;
|
|||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
|
|
||||||
public class WaveDisplay 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;
|
Table window;
|
||||||
float heat;
|
float heat;
|
||||||
|
|
||||||
public WaveDisplay() {
|
public WaveWindow() {
|
||||||
super(Icon.waves, "wave");
|
super(Icon.waves, "wave");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -38,9 +40,54 @@ public class WaveDisplay extends Window implements Updatable {
|
|||||||
window = table;
|
window = table;
|
||||||
|
|
||||||
table.top().background(Styles.black8);
|
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).grow().name("wave-pane");
|
table.add(pane).grow().name("wave-pane").row();
|
||||||
|
table.table(total -> {
|
||||||
|
total.left();
|
||||||
|
total.label(()->"~"+state.wave+"+");
|
||||||
|
total.field(""+settings.getInt("wavemax"), f->{
|
||||||
|
String str = f.replaceAll("\\D", "");
|
||||||
|
if(str.isEmpty()) settings.put("wavemax", 0);
|
||||||
|
else settings.put("wavemax", Integer.parseInt(str));
|
||||||
|
});
|
||||||
|
total.table().update(units->{
|
||||||
|
units.clear();
|
||||||
|
units.center();
|
||||||
|
|
||||||
|
if(Groups.unit.count(u->u.team==state.rules.waveTeam) <= 0) {
|
||||||
|
units.add("[lightgray]<Empty>[]");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int row = 0;
|
||||||
|
int max = Math.max(1, Math.round(window.getWidth()/2/8/2));
|
||||||
|
for (UnitType unit : Vars.content.units()) {
|
||||||
|
int amount = Groups.unit.count(u->u.type==unit&&u.team==state.rules.waveTeam);
|
||||||
|
if(amount<=0) continue;
|
||||||
|
units.stack(
|
||||||
|
new Table(ttt -> {
|
||||||
|
ttt.center();
|
||||||
|
ttt.image(unit.uiIcon).size(iconMed);
|
||||||
|
ttt.pack();
|
||||||
|
}),
|
||||||
|
|
||||||
|
new Table(ttt -> {
|
||||||
|
ttt.bottom().left();
|
||||||
|
ttt.add(amount + "").padTop(2f).fontScale(0.9f);
|
||||||
|
ttt.pack();
|
||||||
|
})
|
||||||
|
).pad(2f);
|
||||||
|
if(row++ % max == max-1){
|
||||||
|
units.row();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).growX();
|
||||||
|
}).growX().row();
|
||||||
|
table.image().height(4f).color(Pal.gray).growX().row();
|
||||||
|
table.table(option->{
|
||||||
|
option.check("Show empty wave", settings.getBool("emptywave"), b->settings.put("emptywave", b)).margin(4f);
|
||||||
|
option.check("Show previous wave", settings.getBool("pastwave"), b->settings.put("pastwave", b)).margin(4f);
|
||||||
|
});
|
||||||
Events.on(EventType.WorldLoadEvent.class, e -> {
|
Events.on(EventType.WorldLoadEvent.class, e -> {
|
||||||
pane.clearChildren();
|
pane.clearChildren();
|
||||||
pane.setWidget(rebuild());
|
pane.setWidget(rebuild());
|
||||||
@@ -90,6 +137,8 @@ public class WaveDisplay extends Window implements Updatable {
|
|||||||
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++) {
|
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;
|
||||||
|
|
||||||
|
if (state.rules.spawns.find(g -> g.getSpawned(index-1) > 0) == null && !settings.getBool("emptywave")) continue;
|
||||||
|
|
||||||
body.table(waveRow -> {
|
body.table(waveRow -> {
|
||||||
waveRow.left();
|
waveRow.left();
|
||||||
|
|
||||||
@@ -10,6 +10,7 @@ import arc.scene.ui.layout.*;
|
|||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
|
import unitinfo.ui.WindowManager;
|
||||||
|
|
||||||
public class Window extends Table{
|
public class Window extends Table{
|
||||||
public TextureRegionDrawable icon;
|
public TextureRegionDrawable icon;
|
||||||
|
|||||||
@@ -1,25 +1,14 @@
|
|||||||
package unitinfo.ui.windows;
|
package unitinfo.ui.windows;
|
||||||
|
|
||||||
import arc.util.*;
|
|
||||||
import mindustry.gen.*;
|
|
||||||
import unitinfo.ui.windows.*;
|
|
||||||
|
|
||||||
public class Windows {
|
public class Windows {
|
||||||
public static MapEditorDisplay editorTable;
|
public static MapEditorWindow editorTable;
|
||||||
|
|
||||||
public static void load(){
|
public static void load(){
|
||||||
new UnitDisplay();
|
new UnitWindow();
|
||||||
new WaveDisplay();
|
new WaveWindow();
|
||||||
new CoreDisplay();
|
new CoreWindow();
|
||||||
new PlayerDisplay();
|
new PlayerWindow();
|
||||||
new ToolDisplay();
|
new ToolWindow();
|
||||||
editorTable = new MapEditorDisplay();
|
editorTable = new MapEditorWindow();
|
||||||
new Window(Icon.box, "test-window", t -> {
|
|
||||||
t.labelWrap(() -> t.parent.x + ", " + t.parent.y).top().right().growX();
|
|
||||||
t.row();
|
|
||||||
t.labelWrap(() -> t.parent.getWidth() + ", " + t.parent.getHeight()).top().right().growX();
|
|
||||||
t.row();
|
|
||||||
t.labelWrap(() -> "T: " + Time.time).top().right().growX();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user