refactoring, add width/height in element debugger

This commit is contained in:
Sharlotte
2022-09-28 09:03:53 +09:00
parent 5c7c719721
commit a8b484f9ca
12 changed files with 47 additions and 27 deletions

View File

@@ -5,5 +5,5 @@ set PATH_FROM=C:\Users\jun\Documents\GitHub\Informatis
setlocal setlocal
set PATH_TO=C:\Users\jun\AppData\Roaming\Mindustry set PATH_TO=C:\Users\jun\AppData\Roaming\Mindustry
if exist %PATH_TO%\mods\raw-Informatis.jar del %PATH_TO%\mods\raw-Informatis.jar if exist %PATH_TO%\mods\InformatisDesktop.jar del %PATH_TO%\mods\InformatisDesktop.jar
xcopy %PATH_FROM%\build\libs\raw-Informatis.jar %PATH_TO%\mods\ /k /y xcopy %PATH_FROM%\build\libs\InformatisDesktop.jar %PATH_TO%\mods\ /k /y

View File

@@ -28,15 +28,16 @@ public class Informatis extends Mod {
}); });
Events.run(Trigger.update, () -> { Events.run(Trigger.update, () -> {
target = getTarget(); //TODO: why not just use Events in its own class constructor?
for (Window window : windows) { for (Window window : windows) {
if(window instanceof Updatable u) u.update(); window.update();
} }
//TODO: target should be not global variable anymore for multiple window system
target = getTarget();
if((input.keyDown(KeyCode.shiftRight) || input.keyDown(KeyCode.shiftLeft))) { if((input.keyDown(KeyCode.shiftRight) || input.keyDown(KeyCode.shiftLeft))) {
if(input.keyTap(KeyCode.r)) { if(input.keyTap(KeyCode.r)) {
if(target==getTarget()) locked = !locked; if(target == getTarget()) locked = !locked;
target = getTarget(); target = getTarget();
} }
} }

View File

@@ -1,9 +1,15 @@
package informatis.draws; package informatis.draws;
import arc.Core;
import arc.graphics.Color;
import arc.input.KeyCode; import arc.input.KeyCode;
import arc.math.Angles; import arc.math.Angles;
import arc.math.geom.Geometry; import arc.math.geom.Geometry;
import arc.scene.style.TextureRegionDrawable; import arc.scene.style.TextureRegionDrawable;
import arc.util.Time;
import arc.util.Tmp;
import mindustry.Vars;
import mindustry.content.Fx;
import mindustry.entities.Units; import mindustry.entities.Units;
import mindustry.game.Team; import mindustry.game.Team;
import mindustry.gen.*; import mindustry.gen.*;
@@ -28,6 +34,10 @@ public class UtilDraw extends OverDraw {
super.draw(); super.draw();
if(!enabled) return; if(!enabled) return;
if(!mobile && !Vars.state.isPaused() && settings.getBool("gaycursor"))
Fx.mine.at(Core.input.mouseWorldX(), Core.input.mouseWorldY(), Tmp.c2.set(Color.red).shiftHue(Time.time * 1.5f));
if(settings.getBool("autoShooting")) { if(settings.getBool("autoShooting")) {
Unit unit = player.unit(); Unit unit = player.unit();
if (unit.type == null) return; if (unit.type == null) return;

View File

@@ -1,5 +0,0 @@
package informatis.ui;
public interface Updatable {
void update();
}

View File

@@ -1,20 +1,28 @@
package informatis.ui.fragments; package informatis.ui.fragments;
import arc.graphics.Color;
import arc.graphics.g2d.Draw; import arc.graphics.g2d.Draw;
import arc.graphics.g2d.Font;
import arc.graphics.g2d.Lines; import arc.graphics.g2d.Lines;
import arc.math.Angles;
import arc.scene.Element; import arc.scene.Element;
import arc.scene.Group; import arc.scene.Group;
import arc.scene.event.Touchable; import arc.scene.event.Touchable;
import arc.scene.ui.layout.Scl;
import arc.struct.SnapshotSeq; import arc.struct.SnapshotSeq;
import arc.util.Align;
import arc.util.Time;
import arc.util.Tmp; import arc.util.Tmp;
import mindustry.graphics.Layer; import mindustry.graphics.Layer;
import mindustry.graphics.Pal; import mindustry.graphics.Pal;
import mindustry.ui.Fonts;
import static arc.Core.scene; import static arc.Core.scene;
import static arc.Core.settings; import static arc.Core.settings;
public class ElementViewFragment extends Element { public class ElementViewFragment extends Element {
Group root; Group root;
Element selected;
public ElementViewFragment() { public ElementViewFragment() {
this(scene.root); this(scene.root);
@@ -32,16 +40,27 @@ public class ElementViewFragment extends Element {
Draw.z(Layer.max); Draw.z(Layer.max);
Lines.stroke(1); Lines.stroke(1);
addRect(root.getChildren()); addRect(root.getChildren());
selected.localToStageCoordinates(Tmp.v1.set(0, 0));
Draw.color(Tmp.c1.set(Color.red).shiftHue(Time.time * 1.5f));
Lines.stroke(1.5f);
Lines.rect(Tmp.v1.x, Tmp.v1.y, selected.getWidth(), selected.getHeight());
Fonts.outline.draw(selected.getWidth() + ", " + selected.getHeight(), Tmp.v1.x, Tmp.v1.y,
Pal.accent, 1f, false, Align.center);
} }
void addRect(SnapshotSeq<Element> elements) { void addRect(SnapshotSeq<Element> elements) {
elements.each(elem-> { elements.each(elem-> {
elem.updateVisibility(); elem.updateVisibility();
if(elem.visible || settings.getBool("hiddenElem")) { if(elem.visible || settings.getBool("hiddenElem")) {
Draw.color();
Lines.stroke(1);
elem.localToStageCoordinates(Tmp.v1.set(0, 0)); elem.localToStageCoordinates(Tmp.v1.set(0, 0));
if(elem.hasMouse()) { if(elem.hasMouse()) {
Draw.color(Pal.accent); Draw.color(Pal.accent);
Lines.stroke(3); Lines.stroke(3);
selected = elem;
} }
if(elem.hasScroll()) { if(elem.hasScroll()) {
Draw.color(Pal.lancerLaser); Draw.color(Pal.lancerLaser);
@@ -52,8 +71,7 @@ public class ElementViewFragment extends Element {
Lines.stroke(5); Lines.stroke(5);
} }
Lines.rect(Tmp.v1.x, Tmp.v1.y, elem.getWidth(), elem.getHeight()); Lines.rect(Tmp.v1.x, Tmp.v1.y, elem.getWidth(), elem.getHeight());
Draw.color();
Lines.stroke(1);
if(elem instanceof Group group) addRect(group.getChildren()); if(elem instanceof Group group) addRect(group.getChildren());
} }
}); });

View File

@@ -20,13 +20,12 @@ 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 informatis.ui.Updatable;
import static arc.Core.*; import static arc.Core.*;
import static mindustry.Vars.*; import static mindustry.Vars.*;
import static mindustry.Vars.ui; import static mindustry.Vars.ui;
public class QuickSchemFragment extends Table implements Updatable { public class QuickSchemFragment extends Table {
static float schemScrollPos, tagScrollPos; static float schemScrollPos, tagScrollPos;
static boolean schemShown; static boolean schemShown;
static Schematic firstSchematic; static Schematic firstSchematic;
@@ -40,7 +39,6 @@ public class QuickSchemFragment extends Table implements Updatable {
table.add(this); table.add(this);
} }
@Override
public void update() { public void update() {
heat += Time.delta; heat += Time.delta;
if(heat>=60f) { if(heat>=60f) {

View File

@@ -23,7 +23,7 @@ import mindustry.world.blocks.storage.*;
import static mindustry.Vars.*; import static mindustry.Vars.*;
public class CoreWindow extends Window implements Updatable { public class CoreWindow extends Window {
Vec2 scrollPos = new Vec2(0, 0); Vec2 scrollPos = new Vec2(0, 0);
Table window; Table window;
float heat; float heat;
@@ -44,7 +44,6 @@ public class CoreWindow extends Window implements Updatable {
Events.on(EventType.WorldLoadEvent.class, e -> resetUsed()); Events.on(EventType.WorldLoadEvent.class, e -> resetUsed());
} }
@Override
public void update() { public void update() {
heat += Time.delta; heat += Time.delta;
if(heat >= 60f) { if(heat >= 60f) {

View File

@@ -31,7 +31,7 @@ import static informatis.ui.windows.MapEditorWindow.drawTeam;
import static informatis.ui.windows.Windows.editorTable; import static informatis.ui.windows.Windows.editorTable;
import static mindustry.Vars.*; import static mindustry.Vars.*;
public class MapEditorWindow extends Window implements Updatable { public class MapEditorWindow extends Window {
Vec2 scrollPos = new Vec2(0, 0); Vec2 scrollPos = new Vec2(0, 0);
TextField search; TextField search;
EditorTool tool; EditorTool tool;
@@ -145,7 +145,6 @@ public class MapEditorWindow extends Window implements Updatable {
}).growY(); }).growY();
} }
@Override
public void update() { public void update() {
//TODO make it more responsive, time -> width delta detect //TODO make it more responsive, time -> width delta detect
heat += Time.delta; heat += Time.delta;

View File

@@ -17,7 +17,7 @@ import mindustry.ui.*;
import static mindustry.Vars.*; import static mindustry.Vars.*;
public class PlayerWindow extends Window implements Updatable { public class PlayerWindow extends Window {
Vec2 scrollPos = new Vec2(0, 0); Vec2 scrollPos = new Vec2(0, 0);
TextField search; TextField search;
ImageButton.ImageButtonStyle ustyle; ImageButton.ImageButtonStyle ustyle;
@@ -48,7 +48,6 @@ public class PlayerWindow extends Window implements Updatable {
table.add(new OverScrollPane(rebuild(), Styles.noBarPane, scrollPos).disableScroll(true, false)).grow().name("player-pane"); table.add(new OverScrollPane(rebuild(), Styles.noBarPane, scrollPos).disableScroll(true, false)).grow().name("player-pane");
} }
@Override
public void update() { public void update() {
heat += Time.delta; heat += Time.delta;
if(heat >= 60f) { if(heat >= 60f) {

View File

@@ -10,7 +10,7 @@ import mindustry.gen.*;
import mindustry.graphics.*; import mindustry.graphics.*;
import mindustry.ui.*; import mindustry.ui.*;
public class ToolWindow extends Window implements Updatable { public class ToolWindow extends Window {
Vec2 scrollPos = new Vec2(0, 0); Vec2 scrollPos = new Vec2(0, 0);
OverDraw selected; OverDraw selected;
float heat; float heat;
@@ -33,7 +33,6 @@ public class ToolWindow extends Window implements Updatable {
}).growY(); }).growY();
} }
@Override
public void update() { public void update() {
heat += Time.delta; heat += Time.delta;
if(heat >= 60f) { if(heat >= 60f) {

View File

@@ -22,12 +22,13 @@ 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 {
static Vec2 scrollPos = new Vec2(0, 0); static Vec2 scrollPos = new Vec2(0, 0);
float heat; float heat;
public WaveWindow() { public WaveWindow() {
super(Icon.waves, "wave"); super(Icon.waves, "wave");
height = 300;
} }
@Override @Override
@@ -93,7 +94,6 @@ public class WaveWindow extends Window implements Updatable {
}); });
} }
@Override
public void update() { public void update() {
heat += Time.delta; heat += Time.delta;
if(heat >= 60f) { if(heat >= 60f) {

View File

@@ -139,4 +139,6 @@ public class Window extends Table {
public void toggle(){ public void toggle(){
shown = !shown; shown = !shown;
} }
public void update() { }
} }