mirror of
https://github.com/yawaflua/Informatis.git
synced 2025-12-09 19:49:27 +02:00
refactoring, add width/height in element debugger
This commit is contained in:
@@ -5,5 +5,5 @@ set PATH_FROM=C:\Users\jun\Documents\GitHub\Informatis
|
||||
setlocal
|
||||
set PATH_TO=C:\Users\jun\AppData\Roaming\Mindustry
|
||||
|
||||
if exist %PATH_TO%\mods\raw-Informatis.jar del %PATH_TO%\mods\raw-Informatis.jar
|
||||
xcopy %PATH_FROM%\build\libs\raw-Informatis.jar %PATH_TO%\mods\ /k /y
|
||||
if exist %PATH_TO%\mods\InformatisDesktop.jar del %PATH_TO%\mods\InformatisDesktop.jar
|
||||
xcopy %PATH_FROM%\build\libs\InformatisDesktop.jar %PATH_TO%\mods\ /k /y
|
||||
|
||||
@@ -28,15 +28,16 @@ public class Informatis extends Mod {
|
||||
});
|
||||
|
||||
Events.run(Trigger.update, () -> {
|
||||
target = getTarget();
|
||||
|
||||
//TODO: why not just use Events in its own class constructor?
|
||||
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.keyTap(KeyCode.r)) {
|
||||
if(target==getTarget()) locked = !locked;
|
||||
if(target == getTarget()) locked = !locked;
|
||||
target = getTarget();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
package informatis.draws;
|
||||
|
||||
import arc.Core;
|
||||
import arc.graphics.Color;
|
||||
import arc.input.KeyCode;
|
||||
import arc.math.Angles;
|
||||
import arc.math.geom.Geometry;
|
||||
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.game.Team;
|
||||
import mindustry.gen.*;
|
||||
@@ -28,6 +34,10 @@ public class UtilDraw extends OverDraw {
|
||||
super.draw();
|
||||
|
||||
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")) {
|
||||
Unit unit = player.unit();
|
||||
if (unit.type == null) return;
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package informatis.ui;
|
||||
|
||||
public interface Updatable {
|
||||
void update();
|
||||
}
|
||||
@@ -1,20 +1,28 @@
|
||||
package informatis.ui.fragments;
|
||||
|
||||
import arc.graphics.Color;
|
||||
import arc.graphics.g2d.Draw;
|
||||
import arc.graphics.g2d.Font;
|
||||
import arc.graphics.g2d.Lines;
|
||||
import arc.math.Angles;
|
||||
import arc.scene.Element;
|
||||
import arc.scene.Group;
|
||||
import arc.scene.event.Touchable;
|
||||
import arc.scene.ui.layout.Scl;
|
||||
import arc.struct.SnapshotSeq;
|
||||
import arc.util.Align;
|
||||
import arc.util.Time;
|
||||
import arc.util.Tmp;
|
||||
import mindustry.graphics.Layer;
|
||||
import mindustry.graphics.Pal;
|
||||
import mindustry.ui.Fonts;
|
||||
|
||||
import static arc.Core.scene;
|
||||
import static arc.Core.settings;
|
||||
|
||||
public class ElementViewFragment extends Element {
|
||||
Group root;
|
||||
Element selected;
|
||||
|
||||
public ElementViewFragment() {
|
||||
this(scene.root);
|
||||
@@ -32,16 +40,27 @@ public class ElementViewFragment extends Element {
|
||||
Draw.z(Layer.max);
|
||||
Lines.stroke(1);
|
||||
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) {
|
||||
elements.each(elem-> {
|
||||
elem.updateVisibility();
|
||||
if(elem.visible || settings.getBool("hiddenElem")) {
|
||||
Draw.color();
|
||||
Lines.stroke(1);
|
||||
elem.localToStageCoordinates(Tmp.v1.set(0, 0));
|
||||
if(elem.hasMouse()) {
|
||||
Draw.color(Pal.accent);
|
||||
Lines.stroke(3);
|
||||
selected = elem;
|
||||
}
|
||||
if(elem.hasScroll()) {
|
||||
Draw.color(Pal.lancerLaser);
|
||||
@@ -52,8 +71,7 @@ public class ElementViewFragment extends Element {
|
||||
Lines.stroke(5);
|
||||
}
|
||||
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());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -20,13 +20,12 @@ import mindustry.gen.*;
|
||||
import mindustry.graphics.Pal;
|
||||
import mindustry.ui.Styles;
|
||||
import mindustry.ui.dialogs.*;
|
||||
import informatis.ui.Updatable;
|
||||
|
||||
import static arc.Core.*;
|
||||
import static mindustry.Vars.*;
|
||||
import static mindustry.Vars.ui;
|
||||
|
||||
public class QuickSchemFragment extends Table implements Updatable {
|
||||
public class QuickSchemFragment extends Table {
|
||||
static float schemScrollPos, tagScrollPos;
|
||||
static boolean schemShown;
|
||||
static Schematic firstSchematic;
|
||||
@@ -40,7 +39,6 @@ public class QuickSchemFragment extends Table implements Updatable {
|
||||
table.add(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
heat += Time.delta;
|
||||
if(heat>=60f) {
|
||||
|
||||
@@ -23,7 +23,7 @@ import mindustry.world.blocks.storage.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class CoreWindow extends Window implements Updatable {
|
||||
public class CoreWindow extends Window {
|
||||
Vec2 scrollPos = new Vec2(0, 0);
|
||||
Table window;
|
||||
float heat;
|
||||
@@ -44,7 +44,6 @@ public class CoreWindow extends Window implements Updatable {
|
||||
Events.on(EventType.WorldLoadEvent.class, e -> resetUsed());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
heat += Time.delta;
|
||||
if(heat >= 60f) {
|
||||
|
||||
@@ -31,7 +31,7 @@ import static informatis.ui.windows.MapEditorWindow.drawTeam;
|
||||
import static informatis.ui.windows.Windows.editorTable;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class MapEditorWindow extends Window implements Updatable {
|
||||
public class MapEditorWindow extends Window {
|
||||
Vec2 scrollPos = new Vec2(0, 0);
|
||||
TextField search;
|
||||
EditorTool tool;
|
||||
@@ -145,7 +145,6 @@ public class MapEditorWindow extends Window implements Updatable {
|
||||
}).growY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
//TODO make it more responsive, time -> width delta detect
|
||||
heat += Time.delta;
|
||||
|
||||
@@ -17,7 +17,7 @@ import mindustry.ui.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class PlayerWindow extends Window implements Updatable {
|
||||
public class PlayerWindow extends Window {
|
||||
Vec2 scrollPos = new Vec2(0, 0);
|
||||
TextField search;
|
||||
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");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
heat += Time.delta;
|
||||
if(heat >= 60f) {
|
||||
|
||||
@@ -10,7 +10,7 @@ import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
|
||||
public class ToolWindow extends Window implements Updatable {
|
||||
public class ToolWindow extends Window {
|
||||
Vec2 scrollPos = new Vec2(0, 0);
|
||||
OverDraw selected;
|
||||
float heat;
|
||||
@@ -33,7 +33,6 @@ public class ToolWindow extends Window implements Updatable {
|
||||
}).growY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
heat += Time.delta;
|
||||
if(heat >= 60f) {
|
||||
|
||||
@@ -22,12 +22,13 @@ import static arc.Core.*;
|
||||
import static arc.Core.settings;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class WaveWindow extends Window implements Updatable {
|
||||
public class WaveWindow extends Window {
|
||||
static Vec2 scrollPos = new Vec2(0, 0);
|
||||
float heat;
|
||||
|
||||
public WaveWindow() {
|
||||
super(Icon.waves, "wave");
|
||||
height = 300;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -93,7 +94,6 @@ public class WaveWindow extends Window implements Updatable {
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
heat += Time.delta;
|
||||
if(heat >= 60f) {
|
||||
@@ -123,7 +123,7 @@ public class WaveWindow extends Window implements Updatable {
|
||||
|
||||
return groupsTmp;
|
||||
}
|
||||
|
||||
|
||||
Table rebuild(){
|
||||
return new Table(table -> {
|
||||
table.touchable = Touchable.enabled;
|
||||
|
||||
@@ -139,4 +139,6 @@ public class Window extends Table {
|
||||
public void toggle(){
|
||||
shown = !shown;
|
||||
}
|
||||
|
||||
public void update() { }
|
||||
}
|
||||
Reference in New Issue
Block a user