Change area-delete to work with rightclick on desktop

This commit is contained in:
Anuken
2017-12-16 19:35:50 -05:00
parent ac17a2fcc4
commit f2027cd58c
5 changed files with 20 additions and 15 deletions

View File

@@ -9,7 +9,7 @@ import io.anuke.mindustry.entities.Player;
import io.anuke.ucore.scene.ui.layout.Unit;
public class Vars{
public static final boolean testAndroid = true;
public static final boolean testAndroid = false;
//shorthand for whether or not this is running on android
public static final boolean android = (Gdx.app.getType() == ApplicationType.Android) || testAndroid;
//shorthand for whether or not this is running on GWT

View File

@@ -108,8 +108,7 @@ public class Control extends Module{
"pause", Keys.SPACE,
"dash", Keys.SHIFT_LEFT,
"rotate_right", Keys.R,
"rotate_left", Keys.E,
"area_delete_mode", Keys.Q
"rotate_left", Keys.E
);
for(int i = 0; i < Vars.saveSlots; i ++){

View File

@@ -330,8 +330,8 @@ public class Tutorial{
blockPlaceX = 2;
blockPlaceY = -2;
text = !Vars.android ?
"You can delete blocks by holding the [orange]right mouse button[] on the block you want to delete. Try deleting this conveyor.":
"You can delete blocks by [orange]tapping and holding[] on the block you want to delete. Try deleting this conveyor.";
"You can delete blocks by clicking the [orange]right mouse button[] on the block you want to delete. Try deleting this conveyor.":
"You can delete blocks by [orange]selecting the crosshair[] in the [orange]break mode menu[] in the bottom left and tapping a block. Try deleting this conveyor.";
}
},
/*
@@ -645,7 +645,7 @@ public class Tutorial{
},
end{
{
text = "And that concludes the tutorial! Good luck!";
text = "And that concludes the tutorial! Good luck!";
canBack = false;
}
};

View File

@@ -21,6 +21,7 @@ import io.anuke.ucore.util.Mathf;
public class DesktopInput extends InputHandler{
int mousex, mousey;
int endx, endy;
private boolean enableHold = false;
@Override public float getCursorEndX(){ return endx; }
@Override public float getCursorEndY(){ return endy; }
@@ -29,7 +30,7 @@ public class DesktopInput extends InputHandler{
@Override
public boolean touchDown (int screenX, int screenY, int pointer, int button){
if(button == Buttons.LEFT){
if((button == Buttons.LEFT && player.recipe != null) || (button == Buttons.RIGHT)){
Vector2 vec = Graphics.world(screenX, screenY);
mousex = (int)vec.x;
mousey = (int)vec.y;
@@ -38,7 +39,11 @@ public class DesktopInput extends InputHandler{
}
public boolean touchUp(int screenX, int screenY, int pointer, int button){
player.placeMode.released(getBlockX(), getBlockY(), getBlockEndX(), getBlockEndY());
if(button == Buttons.LEFT){
player.placeMode.released(getBlockX(), getBlockY(), getBlockEndX(), getBlockEndY());
}else if(button == Buttons.RIGHT){
player.breakMode.released(getBlockX(), getBlockY(), getBlockEndX(), getBlockEndY());
}
return false;
}
@@ -46,10 +51,11 @@ public class DesktopInput extends InputHandler{
public void update(){
if(player.isDead()) return;
if(!Inputs.buttonDown(Buttons.LEFT)){
if(!Inputs.buttonDown(Buttons.LEFT) && !Inputs.buttonDown(Buttons.RIGHT)){
mousex = (int)Graphics.mouseWorld().x;
mousey = (int)Graphics.mouseWorld().y;
}
endx = Gdx.input.getX();
endy = Gdx.input.getY();
@@ -69,10 +75,10 @@ public class DesktopInput extends InputHandler{
player.rotation ++;
}
if(Inputs.keyDown("area_delete_mode")){
player.placeMode = PlaceMode.areaDelete;
if(Inputs.buttonDown(Buttons.RIGHT)){
player.breakMode = PlaceMode.areaDelete;
}else{
player.placeMode = PlaceMode.hold;
player.breakMode = PlaceMode.hold;
}
player.rotation = Mathf.mod(player.rotation, 4);
@@ -105,7 +111,7 @@ public class DesktopInput extends InputHandler{
}
//block breaking
if(Inputs.buttonDown(Buttons.RIGHT) && cursor != null && validBreak(tilex(), tiley())){
if(enableHold && Inputs.buttonDown(Buttons.RIGHT) && cursor != null && validBreak(tilex(), tiley())){
Tile tile = cursor;
player.breaktime += Timers.delta();
if(player.breaktime >= tile.getBreakTime()){