diff --git a/core/src/io/anuke/mindustry/Vars.java b/core/src/io/anuke/mindustry/Vars.java index 8cb39dbe34..ab3e403cdd 100644 --- a/core/src/io/anuke/mindustry/Vars.java +++ b/core/src/io/anuke/mindustry/Vars.java @@ -40,7 +40,7 @@ public class Vars{ //how much the zoom changes every zoom button press public static final int zoomScale = Math.round(Unit.dp.scl(1)); //if true, player speed will be increased, massive amounts of resources will be given on start, and other debug options will be available - public static boolean debug = true; + public static boolean debug = false; //whether the player can clip through walls public static boolean noclip = false; //whether to draw chunk borders diff --git a/core/src/io/anuke/mindustry/entities/enemies/Enemy.java b/core/src/io/anuke/mindustry/entities/enemies/Enemy.java index fc8a6e5f7f..51c0acfcdd 100644 --- a/core/src/io/anuke/mindustry/entities/enemies/Enemy.java +++ b/core/src/io/anuke/mindustry/entities/enemies/Enemy.java @@ -206,7 +206,7 @@ public class Enemy extends DestructibleEntity{ float minv = 0.07f; - if(Math.abs(xvelocity) < minv && Math.abs(yvelocity) < minv && node > 0 && target == null){ + if(Vector2.dst(xvelocity, yvelocity, 0, 0) < minv && node > 0 && target == null){ idletime += Timers.delta(); }else{ idletime = 0; diff --git a/core/src/io/anuke/mindustry/mapeditor/MapEditorDialog.java b/core/src/io/anuke/mindustry/mapeditor/MapEditorDialog.java index 5f31da6593..743aff0bec 100644 --- a/core/src/io/anuke/mindustry/mapeditor/MapEditorDialog.java +++ b/core/src/io/anuke/mindustry/mapeditor/MapEditorDialog.java @@ -49,6 +49,7 @@ public class MapEditorDialog extends Dialog{ Pixmap pixmap = new Pixmap(file); if(verifySize(pixmap)){ editor.setPixmap(pixmap); + view.clearStack(); }else{ Vars.ui.showError("[orange]Invalid image dimensions![]\nValid map dimensions: " + Arrays.toString(MapEditor.validMapSizes)); } @@ -89,6 +90,7 @@ public class MapEditorDialog extends Dialog{ copy.texture = new Texture(copy.pixmap); editor.beginEdit(copy); Vars.ui.hideLoading(); + view.clearStack(); }); }); @@ -98,6 +100,7 @@ public class MapEditorDialog extends Dialog{ Vars.ui.showLoading(); Timers.run(10f, ()->{ editor.resize(x, y); + view.clearStack(); Vars.ui.hideLoading(); }); } @@ -112,6 +115,7 @@ public class MapEditorDialog extends Dialog{ Vars.world.maps().saveAndReload(editor.getMap(), editor.pixmap()); loadDialog.rebuild(); Vars.ui.hideLoading(); + view.clearStack(); }); }else{ Vars.ui.hideLoading(); @@ -131,9 +135,14 @@ public class MapEditorDialog extends Dialog{ editor.beginEdit(new Map()); blockgroup.getButtons().get(2).setChecked(true); Core.scene.setScrollFocus(view); + view.clearStack(); }); } - + + public MapView getView() { + return view; + } + public void resetSaved(){ saved = false; } diff --git a/core/src/io/anuke/mindustry/mapeditor/MapGenerateDialog.java b/core/src/io/anuke/mindustry/mapeditor/MapGenerateDialog.java index 965fd7858d..5ea5494992 100644 --- a/core/src/io/anuke/mindustry/mapeditor/MapGenerateDialog.java +++ b/core/src/io/anuke/mindustry/mapeditor/MapGenerateDialog.java @@ -62,14 +62,12 @@ public class MapGenerateDialog extends FloatingDialog{ content().add(pane).fillY(); buttons().defaults().size(170f, 50f).pad(4f); - buttons().addButton("Back", () -> hide()); + buttons().addButton("Back", this::hide); buttons().addButton("Randomize", () ->{ editor.getFilter().randomize(); apply(); }); - buttons().addButton("Update", () ->{ - apply(); - }); + buttons().addButton("Update", this::apply); buttons().addButton("Apply", () ->{ Vars.ui.showLoading(); @@ -77,6 +75,7 @@ public class MapGenerateDialog extends FloatingDialog{ editor.applyFilter(); Vars.ui.hideLoading(); Vars.ui.getEditorDialog().resetSaved(); + Vars.ui.getEditorDialog().getView().clearStack(); hide(); }); }); @@ -93,7 +92,7 @@ public class MapGenerateDialog extends FloatingDialog{ private void apply(){ loading = true; - Timers.run(3f, ()->{ + Timers.run(3f, () -> { editor.applyFilterPreview(); loading = false; }); diff --git a/core/src/io/anuke/mindustry/mapeditor/MapView.java b/core/src/io/anuke/mindustry/mapeditor/MapView.java index 06fede8a3b..ba6c3e2ddf 100644 --- a/core/src/io/anuke/mindustry/mapeditor/MapView.java +++ b/core/src/io/anuke/mindustry/mapeditor/MapView.java @@ -24,6 +24,7 @@ public class MapView extends Element implements GestureListener{ private MapEditor editor; private EditorTool tool = EditorTool.pencil; private OperationStack stack = new OperationStack(); + private PixelOperation op; private Bresenham2 br = new Bresenham2(); private float offsetx, offsety; private float zoom = 1f; @@ -59,7 +60,9 @@ public class MapView extends Element implements GestureListener{ if(tool.edit){ Vars.ui.getEditorDialog().resetSaved(); } - + + op = new PixelOperation(editor.pixmap()); + drawing = true; return true; } @@ -67,6 +70,8 @@ public class MapView extends Element implements GestureListener{ @Override public void touchUp (InputEvent event, float x, float y, int pointer, int button) { drawing = false; + stack.add(op); + op = null; } @Override diff --git a/core/src/io/anuke/mindustry/mapeditor/PixelOperation.java b/core/src/io/anuke/mindustry/mapeditor/PixelOperation.java new file mode 100644 index 0000000000..026204ab3c --- /dev/null +++ b/core/src/io/anuke/mindustry/mapeditor/PixelOperation.java @@ -0,0 +1,24 @@ +package io.anuke.mindustry.mapeditor; + +import com.badlogic.gdx.graphics.Pixmap; + +public class PixelOperation extends DrawOperation { + + public PixelOperation(Pixmap pixmap){ + super(pixmap); + } + + public void add() { + + } + + @Override + public void undo() { + + } + + @Override + public void redo() { + + } +}