diff --git a/core/assets/version.properties b/core/assets/version.properties index 5e49680142..978f831df5 100644 --- a/core/assets/version.properties +++ b/core/assets/version.properties @@ -1,7 +1,7 @@ #Autogenerated file. Do not modify. -#Thu Mar 15 12:52:13 EDT 2018 +#Thu Mar 15 14:23:19 EDT 2018 version=release -androidBuildCode=388 +androidBuildCode=412 name=Mindustry code=3.4 build=custom build diff --git a/core/src/io/anuke/mindustry/core/Renderer.java b/core/src/io/anuke/mindustry/core/Renderer.java index ba37bc6e2b..51c95ffcda 100644 --- a/core/src/io/anuke/mindustry/core/Renderer.java +++ b/core/src/io/anuke/mindustry/core/Renderer.java @@ -408,7 +408,8 @@ public class Renderer extends RendererModule{ if((input.recipe != null && state.inventory.hasItems(input.recipe.requirements) && (!ui.hasMouse() || android) && control.input().drawPlace())){ - input.placeMode.draw(control.input().getBlockX(), control.input().getBlockY(), control.input().getBlockEndX(), control.input().getBlockEndY()); + input.placeMode.draw(control.input().getBlockX(), control.input().getBlockY(), + control.input().getBlockEndX(), control.input().getBlockEndY()); Lines.stroke(1f); Draw.color(Color.SCARLET); @@ -424,9 +425,15 @@ public class Renderer extends RendererModule{ if(input.breakMode == PlaceMode.holdDelete) input.breakMode.draw(tilex, tiley, 0, 0); - }else if(input.breakMode.delete && control.input().drawPlace() && input.recipe == null){ - input.breakMode.draw(control.input().getBlockX(), control.input().getBlockY(), - control.input().getBlockEndX(), control.input().getBlockEndY()); + }else if(input.breakMode.delete && control.input().drawPlace() + && (input.recipe == null || !state.inventory.hasItems(input.recipe.requirements)) + && (input.placeMode.delete || input.breakMode.both)){ + + if(input.breakMode == PlaceMode.holdDelete) + input.breakMode.draw(tilex, tiley, 0, 0); + else + input.breakMode.draw(control.input().getBlockX(), control.input().getBlockY(), + control.input().getBlockEndX(), control.input().getBlockEndY()); } if(ui.toolfrag.confirming){ diff --git a/core/src/io/anuke/mindustry/input/AndroidInput.java b/core/src/io/anuke/mindustry/input/AndroidInput.java index 704705bb4e..7a859da9f1 100644 --- a/core/src/io/anuke/mindustry/input/AndroidInput.java +++ b/core/src/io/anuke/mindustry/input/AndroidInput.java @@ -20,9 +20,9 @@ public class AndroidInput extends InputHandler{ public float lmousex, lmousey; public float mousex, mousey; public boolean brokeBlock = false; + public boolean placing = false; private boolean enableHold = false; - private boolean placing = false; private float warmup; private float warmupDelay = 20; @@ -48,6 +48,7 @@ public class AndroidInput extends InputHandler{ }else if(pointer == 0 && !breakMode.pan && breaking() && drawPlace()){ breakMode.released(getBlockX(), getBlockY(), getBlockEndX(), getBlockEndY()); } + placing = false; return false; } diff --git a/core/src/io/anuke/mindustry/input/GestureHandler.java b/core/src/io/anuke/mindustry/input/GestureHandler.java index 558f5afd93..dc1fbdbfca 100644 --- a/core/src/io/anuke/mindustry/input/GestureHandler.java +++ b/core/src/io/anuke/mindustry/input/GestureHandler.java @@ -47,7 +47,7 @@ public class GestureHandler extends GestureAdapter{ if(control.showCursor() && !Inputs.keyDown("select")) return false; if(!control.showCursor() && !(control.input().recipe != null - && state.inventory.hasItems(control.input().recipe.requirements) && control.input().placeMode.lockCamera) && + && control.input().placeMode.lockCamera) && !(control.input().recipe == null && control.input().breakMode.lockCamera)){ float dx = deltaX*Core.camera.zoom/Core.cameraScale, dy = deltaY*Core.camera.zoom/Core.cameraScale; player.x -= dx; diff --git a/core/src/io/anuke/mindustry/input/PlaceMode.java b/core/src/io/anuke/mindustry/input/PlaceMode.java index a6e69adad7..b092ec86f7 100644 --- a/core/src/io/anuke/mindustry/input/PlaceMode.java +++ b/core/src/io/anuke/mindustry/input/PlaceMode.java @@ -164,7 +164,6 @@ public enum PlaceMode{ } public void released(int tilex, int tiley, int endx, int endy){ - process(tilex, tiley, endx, endy); tilex = this.tilex; tiley = this.tiley; endx = this.endx; endy = this.endy; diff --git a/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java b/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java index 39427f4cf3..c25fa3a103 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/PlacementFragment.java @@ -4,6 +4,7 @@ import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.math.Interpolation; import com.badlogic.gdx.utils.Align; import io.anuke.mindustry.core.GameState.State; +import io.anuke.mindustry.input.AndroidInput; import io.anuke.mindustry.input.InputHandler; import io.anuke.mindustry.input.PlaceMode; import io.anuke.ucore.core.Core; @@ -128,7 +129,7 @@ public class PlacementFragment implements Fragment{ defaults().padBottom(-5.5f); - new imagebutton("icon-" + mode.name(), "toggle", 10 * 3, () -> { + ImageButton button = new imagebutton("icon-" + mode.name(), "toggle", 10 * 3, () -> { control.input().resetCursor(); input.breakMode = mode; input.lastBreakMode = mode; @@ -138,7 +139,15 @@ public class PlacementFragment implements Fragment{ input.placeMode = input.lastPlaceMode; } modeText(Bundles.format("text.mode.break", mode.toString())); - }).group(breakGroup).get().setName(mode.name()); + }).group(breakGroup).get(); + + button.setName(mode.name()); + button.released(() -> { + //TODO hack + if(mode == PlaceMode.areaDelete){ + ((AndroidInput)input).placing = false; + } + }); } }}.end().get(); @@ -215,6 +224,7 @@ public class PlacementFragment implements Fragment{ if(!show){ control.input().breakMode = PlaceMode.none; + if(control.input().placeMode.delete) control.input().placeMode = PlaceMode.none; breaktable.actions(Actions.translateBy(-breaktable.getWidth() - 5, 0, dur, in), Actions.call(() -> shown = false)); }else{ shown = true;