From 1316c9235aa62a6912f4e4a90cb1a6f9c91d2993 Mon Sep 17 00:00:00 2001 From: Anuken Date: Sat, 9 Mar 2019 19:43:33 -0500 Subject: [PATCH] Made inventory hide on second tap / Mobile rotation arrow --- .../io/anuke/mindustry/input/MobileInput.java | 37 +++++++++- core/src/io/anuke/mindustry/type/Item.java | 3 - .../ui/fragments/BlockInventoryFragment.java | 4 ++ desktop/build.gradle | 72 +++++++++---------- 4 files changed, 75 insertions(+), 41 deletions(-) diff --git a/core/src/io/anuke/mindustry/input/MobileInput.java b/core/src/io/anuke/mindustry/input/MobileInput.java index bd9350b4dd..0e742a987c 100644 --- a/core/src/io/anuke/mindustry/input/MobileInput.java +++ b/core/src/io/anuke/mindustry/input/MobileInput.java @@ -19,6 +19,7 @@ import io.anuke.arc.math.geom.Vector2; import io.anuke.arc.scene.ui.layout.Table; import io.anuke.arc.util.Align; import io.anuke.arc.util.Time; +import io.anuke.arc.util.Tmp; import io.anuke.mindustry.content.Blocks; import io.anuke.mindustry.content.Fx; import io.anuke.mindustry.core.GameState.State; @@ -218,6 +219,23 @@ public class MobileInput extends InputHandler implements GestureListener{ } } + void drawPlaceArrow(Block block, int x, int y, int rotation){ + if(!block.rotate) return; + Draw.color(!validPlace(x, y, block, rotation) ? Pal.removeBack : Pal.accentBack); + Draw.rect(Core.atlas.find("place-arrow"), + x * tilesize + block.offset(), + y * tilesize + block.offset() - 1, + Core.atlas.find("place-arrow").getWidth() * Draw.scl, + Core.atlas.find("place-arrow").getHeight() * Draw.scl, rotation * 90 - 90); + + Draw.color(!validPlace(x, y, block, rotation) ? Pal.remove : Pal.accent); + Draw.rect(Core.atlas.find("place-arrow"), + x * tilesize + block.offset(), + y * tilesize + block.offset(), + Core.atlas.find("place-arrow").getWidth() * Draw.scl, + Core.atlas.find("place-arrow").getHeight() * Draw.scl, rotation * 90 - 90); + } + //endregion //region UI and drawing @@ -311,10 +329,18 @@ public class MobileInput extends InputHandler implements GestureListener{ request.scale = Mathf.lerpDelta(request.scale, 1f, 0.2f); request.redness = Mathf.lerpDelta(request.redness, 0f, 0.2f); }else{ - request.scale = Mathf.lerpDelta(request.scale, 0.5f, 0.1f); - request.redness = Mathf.lerpDelta(request.redness, 1f, 0.2f); + request.scale = Mathf.lerpDelta(request.scale, 0.6f, 0.1f); + request.redness = Mathf.lerpDelta(request.redness, 0.9f, 0.2f); } + Tmp.c1.set(Draw.getMixColor()); + + if(!request.remove && request == lastPlaced && request.block != null){ + Draw.mixcol(); + drawPlaceArrow(request.block, tile.x, tile.y, request.rotation); + } + + Draw.mixcol(Tmp.c1, 1f); drawRequest(request); //draw last placed request @@ -334,12 +360,19 @@ public class MobileInput extends InputHandler implements GestureListener{ //draw placing if(mode == placing && block != null){ + NormalizeDrawResult dresult = PlaceUtils.normalizeDrawArea(block, lineStartX, lineStartY, tileX, tileY, true, maxLength, lineScale); Lines.rect(dresult.x, dresult.y, dresult.x2 - dresult.x, dresult.y2 - dresult.y); NormalizeResult result = PlaceUtils.normalizeArea(lineStartX, lineStartY, tileX, tileY, rotation, true, maxLength); + { + int x = lineStartX + result.getLength() * Mathf.sign(tileX - lineStartX) * Mathf.num(result.isX()); + int y = lineStartY + result.getLength() * Mathf.sign(tileY - lineStartY) * Mathf.num(!result.isX()); + drawPlaceArrow(block, x, y, result.rotation); + } + //go through each cell and draw the block to place if valid for(int i = 0; i <= result.getLength(); i += block.size){ int x = lineStartX + i * Mathf.sign(tileX - lineStartX) * Mathf.num(result.isX()); diff --git a/core/src/io/anuke/mindustry/type/Item.java b/core/src/io/anuke/mindustry/type/Item.java index b11b5d0884..986a74a75c 100644 --- a/core/src/io/anuke/mindustry/type/Item.java +++ b/core/src/io/anuke/mindustry/type/Item.java @@ -7,7 +7,6 @@ import io.anuke.arc.graphics.g2d.TextureRegion; import io.anuke.arc.scene.ui.layout.Table; import io.anuke.mindustry.Vars; import io.anuke.mindustry.game.UnlockableContent; -import io.anuke.mindustry.graphics.Pal; import io.anuke.mindustry.ui.ContentDisplay; public class Item extends UnlockableContent implements Comparable{ @@ -24,8 +23,6 @@ public class Item extends UnlockableContent implements Comparable{ public float radioactivity; /**drill hardness of the item*/ public int hardness = 0; - /**the burning color of this item. TODO unused; implement*/ - public Color flameColor = Pal.darkFlame.cpy(); /** * base material cost of this item, used for calculating place times * 1 cost = 1 tick added to build time diff --git a/core/src/io/anuke/mindustry/ui/fragments/BlockInventoryFragment.java b/core/src/io/anuke/mindustry/ui/fragments/BlockInventoryFragment.java index 039d5f1152..4d65d33136 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/BlockInventoryFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/BlockInventoryFragment.java @@ -66,6 +66,10 @@ public class BlockInventoryFragment extends Fragment{ } public void showFor(Tile t){ + if(this.tile == t.target()){ + hide(); + return; + } this.tile = t.target(); if(tile == null || tile.entity == null || !tile.block().isAccessible() || tile.entity.items.total() == 0) return; diff --git a/desktop/build.gradle b/desktop/build.gradle index c614bdfdaa..48aa4e3236 100644 --- a/desktop/build.gradle +++ b/desktop/build.gradle @@ -69,12 +69,6 @@ task dist(type: Jar){ } } -task clearOut(type: Delete){ - doLast{ - delete "packr-out/" - } -} - //note: call desktop:dist beforehand task packrCmd(){ @@ -102,35 +96,41 @@ task packrCmd(){ } } -task fixMac(type: Copy){ - dependsOn "packrCmd" - - into "packr-out/" + appName + ".app/Contents/" - from "packr-out/Contents/" - - doLast{ - delete{ - delete "packr-out/Contents/" - } - } -} - -task fixWindows32(type: Copy){ - dependsOn "packrCmd" - - into "packr-out/jre/bin/" - from JDK_DIR + "zip.dll" - rename("zip.dll", "ojdkbuild_zlib.dll") - - doLast{ - copy{ - into "packr-out/jre/bin/" - from JDK_DIR + "zip.dll" - } - } -} - task packrZip(){ + task clearOut(type: Delete){ + doLast{ + delete "packr-out/" + } + } + + task fixMac(type: Copy){ + dependsOn "packrCmd" + + into "packr-out/" + appName + ".app/Contents/" + from "packr-out/Contents/" + + doLast{ + delete{ + delete "packr-out/Contents/" + } + } + } + + task fixWindows32(type: Copy){ + dependsOn "packrCmd" + + into "packr-out/jre/bin/" + from JDK_DIR + "zip.dll" + rename("zip.dll", "ojdkbuild_zlib.dll") + + doLast{ + copy{ + into "packr-out/jre/bin/" + from JDK_DIR + "zip.dll" + } + } + } + dependsOn "packrCmd" finalizedBy "clearOut" @@ -144,12 +144,12 @@ task packrZip(){ dependsOn "fixWindows32" } - task zip(type: Zip){ + task rzip(type: Zip){ from "packr-out/" archiveName "$appName-${getPlatform()}-${getVersionString()}.zip" destinationDir(file("packr-export")) } - finalizedBy 'zip' + finalizedBy 'rzip' } }