Finished new placement controls
This commit is contained in:
@@ -3,7 +3,6 @@ package io.anuke.mindustry.input;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input.Keys;
|
||||
import com.badlogic.gdx.input.GestureDetector;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
|
||||
@@ -22,7 +21,7 @@ public class AndroidInput extends InputHandler{
|
||||
public float lmousex, lmousey;
|
||||
public float mousex, mousey;
|
||||
public boolean brokeBlock = false;
|
||||
private boolean placing = true;
|
||||
private boolean placing = false;
|
||||
private float warmup;
|
||||
private float warmupDelay = 20;
|
||||
|
||||
@@ -34,23 +33,19 @@ public class AndroidInput extends InputHandler{
|
||||
@Override public float getCursorEndY(){ return Gdx.input.getY(0); }
|
||||
@Override public float getCursorX(){ return mousex; }
|
||||
@Override public float getCursorY(){ return mousey; }
|
||||
@Override public boolean drawPlace(){ return placing; }
|
||||
|
||||
@Override
|
||||
public boolean keyDown(int keycode){
|
||||
if(keycode == Keys.E){
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override public boolean drawPlace(){ return placing || (player.placeMode.pan && player.recipe != null); }
|
||||
|
||||
@Override
|
||||
public boolean touchUp(int screenX, int screenY, int pointer, int button){
|
||||
//if(ui.hasMouse()) return false;
|
||||
|
||||
brokeBlock = false;
|
||||
if(placing && pointer == 0 && !player.placeMode.pan){
|
||||
player.placeMode.released(getBlockX(), getBlockY(), getBlockEndX(), getBlockEndY());
|
||||
placing = false;
|
||||
}else if(pointer == 0 && !player.breakMode.pan && player.recipe == null && drawPlace()){
|
||||
player.breakMode.released(getBlockX(), getBlockY(), getBlockEndX(), getBlockEndY());
|
||||
}
|
||||
placing = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -62,16 +57,15 @@ public class AndroidInput extends InputHandler{
|
||||
lmousex = screenX;
|
||||
lmousey = screenY;
|
||||
|
||||
if(!player.placeMode.pan){
|
||||
if(pointer == 0){
|
||||
placing = true;
|
||||
|
||||
mousex = screenX;
|
||||
mousey = screenY;
|
||||
|
||||
}else{
|
||||
placing = false;
|
||||
}
|
||||
if((!player.placeMode.pan || player.recipe == null) && pointer == 0){
|
||||
mousex = screenX;
|
||||
mousey = screenY;
|
||||
}
|
||||
|
||||
if(pointer != 0){
|
||||
placing = false;
|
||||
}else{
|
||||
placing = true;
|
||||
}
|
||||
|
||||
warmup = 0;
|
||||
|
||||
@@ -28,20 +28,27 @@ public class GestureHandler extends GestureAdapter{
|
||||
|
||||
@Override
|
||||
public boolean tap (float x, float y, int count, int button) {
|
||||
if(!player.placeMode.pan){
|
||||
if(ui.hasMouse()) return false;
|
||||
|
||||
if(!player.placeMode.pan || player.recipe == null){
|
||||
input.mousex = x;
|
||||
input.mousey = y;
|
||||
player.placeMode.tapped(input.getBlockX(), input.getBlockY());
|
||||
|
||||
if(player.recipe == null)
|
||||
player.breakMode.tapped(input.getBlockX(), input.getBlockY());
|
||||
else
|
||||
player.placeMode.tapped(input.getBlockX(), input.getBlockY());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pan(float x, float y, float deltaX, float deltaY){
|
||||
if(player.recipe == null || !Vars.control.hasItems(player.recipe.requirements) || !player.placeMode.lockCamera){
|
||||
if(!(player.recipe != null && Vars.control.hasItems(player.recipe.requirements) && player.placeMode.lockCamera) &&
|
||||
!(player.recipe == null && player.breakMode.lockCamera)){
|
||||
player.x -= deltaX*Core.camera.zoom/Core.cameraScale;
|
||||
player.y += deltaY*Core.camera.zoom/Core.cameraScale;
|
||||
}else if(player.placeMode.lockCamera){
|
||||
}else if(player.placeMode.lockCamera && (player.placeMode.pan && player.recipe != null)){
|
||||
input.mousex += deltaX;
|
||||
input.mousey += deltaY;
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ public abstract class InputHandler extends InputAdapter{
|
||||
Vars.control.addItem(tile.block().drops.item, tile.block().drops.amount);
|
||||
}
|
||||
|
||||
Effects.shake(3f, 1f, player);
|
||||
//Effects.shake(3f, 1f, player);
|
||||
Sounds.play("break");
|
||||
|
||||
if(!tile.block().isMultiblock() && !tile.isLinked()){
|
||||
|
||||
@@ -58,7 +58,6 @@ public enum PlaceMode{
|
||||
}
|
||||
|
||||
public void tapped(int tilex, int tiley){
|
||||
System.out.println("tap " + tilex + " " + tiley);
|
||||
control.getInput().tryPlaceBlock(tilex, tiley);
|
||||
}
|
||||
},
|
||||
@@ -74,6 +73,45 @@ public enum PlaceMode{
|
||||
control.getInput().tryPlaceBlock(x, y);
|
||||
}
|
||||
},
|
||||
holdDelete{
|
||||
{
|
||||
delete = true;
|
||||
shown = true;
|
||||
}
|
||||
|
||||
public void draw(int tilex, int tiley, int endx, int endy){
|
||||
Tile tile = world.tile(tilex, tiley);
|
||||
|
||||
if(tile != null && control.getInput().validBreak(tilex, tiley)){
|
||||
if(tile.isLinked())
|
||||
tile = tile.getLinked();
|
||||
Vector2 offset = tile.block().getPlaceOffset();
|
||||
float fract = player.breaktime / tile.getBreakTime();
|
||||
|
||||
if(Inputs.buttonDown(Buttons.RIGHT)){
|
||||
Draw.color(Color.YELLOW, Color.SCARLET, fract);
|
||||
Draw.linecrect(tile.worldx() + offset.x, tile.worldy() + offset.y, tile.block().width * Vars.tilesize, tile.block().height * Vars.tilesize);
|
||||
}else if(android && player.breaktime > 0){
|
||||
Draw.color(Colors.get("breakStart"), Colors.get("break"), fract);
|
||||
Draw.polygon(25, tile.worldx() + offset.x, tile.worldy() + offset.y, 4 + (1f - fract) * 26);
|
||||
}
|
||||
Draw.reset();
|
||||
}
|
||||
}
|
||||
},
|
||||
touchDelete{
|
||||
{
|
||||
shown = true;
|
||||
lockCamera = false;
|
||||
showRotate = true;
|
||||
showCancel = true;
|
||||
delete = true;
|
||||
}
|
||||
|
||||
public void tapped(int x, int y){
|
||||
control.getInput().tryDeleteBlock(x, y);
|
||||
}
|
||||
},
|
||||
areaDelete{
|
||||
int maxlen = 10;
|
||||
int tilex;
|
||||
@@ -306,27 +344,6 @@ public enum PlaceMode{
|
||||
this.tilex = tilex;
|
||||
this.tiley = tiley;
|
||||
}
|
||||
},
|
||||
breaker{
|
||||
public void draw(int tilex, int tiley, int endx, int endy){
|
||||
Tile tile = world.tile(tilex, tiley);
|
||||
|
||||
if(tile != null && control.getInput().validBreak(tilex, tiley)){
|
||||
if(tile.isLinked())
|
||||
tile = tile.getLinked();
|
||||
Vector2 offset = tile.block().getPlaceOffset();
|
||||
float fract = player.breaktime / tile.getBreakTime();
|
||||
|
||||
if(Inputs.buttonDown(Buttons.RIGHT)){
|
||||
Draw.color(Color.YELLOW, Color.SCARLET, fract);
|
||||
Draw.linecrect(tile.worldx() + offset.x, tile.worldy() + offset.y, tile.block().width * Vars.tilesize, tile.block().height * Vars.tilesize);
|
||||
}else if(android && player.breaktime > 0){
|
||||
Draw.color(Colors.get("breakStart"), Colors.get("break"), fract);
|
||||
Draw.polygon(25, tile.worldx() + offset.x, tile.worldy() + offset.y, 4 + (1f - fract) * 26);
|
||||
}
|
||||
Draw.reset();
|
||||
}
|
||||
}
|
||||
};
|
||||
public boolean lockCamera;
|
||||
public boolean pan = false;
|
||||
|
||||
Reference in New Issue
Block a user