Made inventory hide on second tap / Mobile rotation arrow

This commit is contained in:
Anuken
2019-03-09 19:43:33 -05:00
parent a0905d5695
commit 1316c9235a
4 changed files with 75 additions and 41 deletions

View File

@@ -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());

View File

@@ -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<Item>{
@@ -24,8 +23,6 @@ public class Item extends UnlockableContent implements Comparable<Item>{
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

View File

@@ -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;