Made desktop selection rebindable
This commit is contained in:
@@ -21,6 +21,7 @@ text.level.delete.title=Confirm Delete
|
||||
text.map.delete=Are you sure you want to delete the map "[orange]{0}[]"?
|
||||
text.level.select=Level Select
|
||||
text.level.mode=Gamemode:
|
||||
text.construction.desktop=Desktop controls have been changed.\nTo deselect a block or stop building, [accent]use space[].
|
||||
text.construction.title=Block Construction Guide
|
||||
text.construction=\
|
||||
You've just selected [accent]block construction mode[].\n\n\
|
||||
@@ -362,8 +363,9 @@ category.multiplayer.name=Multiplayer
|
||||
|
||||
keybind.move_x.name=Move x
|
||||
keybind.move_y.name=Move y
|
||||
keybind.select.name=Select
|
||||
keybind.select.name=Select/Shoot
|
||||
keybind.break.name=Break
|
||||
keybind.deselect.name=Deselect
|
||||
keybind.shoot.name=Shoot
|
||||
keybind.zoom_hold.name=Zoom Hold
|
||||
keybind.zoom.name=Zoom
|
||||
@@ -607,6 +609,10 @@ block.titan-pad.name=Titan Pad
|
||||
block.thermal-generator.name=Thermal Generator
|
||||
block.alloy-smelter.name=Alloy Smtler
|
||||
block.mend-projector.name=Mend Projector
|
||||
block.surge-wall.name=Surge Wall
|
||||
block.surge-wall-large.name=Large Surge Wall
|
||||
block.cyclone.name=Cyclone
|
||||
block.fuse.name=Fuse
|
||||
|
||||
unit.alpha-drone.name=Alpha Drone
|
||||
unit.drone.name=Drone
|
||||
|
||||
@@ -19,12 +19,12 @@ public class DefaultKeybinds{
|
||||
new Category("general"),
|
||||
"move_x", new Axis(Input.A, Input.D),
|
||||
"move_y", new Axis(Input.S, Input.W),
|
||||
//"select", Input.MOUSE_LEFT,
|
||||
//"break", Input.MOUSE_RIGHT,
|
||||
//"shoot", Input.MOUSE_LEFT,
|
||||
"select", Input.MOUSE_LEFT,
|
||||
"deselect", Input.SPACE,
|
||||
"break", Input.MOUSE_RIGHT,
|
||||
"rotate", new Axis(Input.SCROLL),
|
||||
"dash", Input.SHIFT_LEFT,
|
||||
"ability", Input.SPACE,
|
||||
"ability", Input.Q,
|
||||
"drop_unit", Input.SHIFT_LEFT,
|
||||
new Category("view"),
|
||||
"zoom_hold", Input.CONTROL_LEFT,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package io.anuke.mindustry.input;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Input.Buttons;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import io.anuke.mindustry.content.blocks.Blocks;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
@@ -149,6 +148,10 @@ public class DesktopInput extends InputHandler{
|
||||
ui.listfrag.toggle();
|
||||
}
|
||||
|
||||
if(Inputs.keyRelease(section, "select")){
|
||||
player.isShooting = false;
|
||||
}
|
||||
|
||||
if(state.is(State.menu) || ui.hasDialog()) return;
|
||||
|
||||
boolean controller = KeyBinds.getSection(section).device.type == DeviceType.controller;
|
||||
@@ -162,13 +165,15 @@ public class DesktopInput extends InputHandler{
|
||||
|
||||
if(player.isDead()) return;
|
||||
|
||||
pollInput();
|
||||
|
||||
if(recipe != null && !Settings.getBool("desktop-place-help", false)){
|
||||
ui.showInfo("Desktop controls have been changed.\nTo deselect a block or stop building, [accent]use the middle mouse button[].");
|
||||
ui.showInfo("$text.construction.desktop");
|
||||
Settings.putBool("desktop-place-help", true);
|
||||
Settings.save();
|
||||
}
|
||||
|
||||
//deslect if not placing
|
||||
//deselect if not placing
|
||||
if(!isPlacing() && mode == placing){
|
||||
mode = none;
|
||||
}
|
||||
@@ -215,57 +220,41 @@ public class DesktopInput extends InputHandler{
|
||||
cursorType = normal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean touchDown(int screenX, int screenY, int pointer, int button){
|
||||
if(player.isDead() || state.is(State.menu) || ui.hasDialog() || ui.hasMouse()) return false;
|
||||
void pollInput(){
|
||||
Tile cursor = tileAt(control.gdxInput().getX(), control.gdxInput().getY());
|
||||
if(cursor == null){
|
||||
mode = none;
|
||||
return;
|
||||
}
|
||||
|
||||
Tile cursor = tileAt(screenX, screenY);
|
||||
if(cursor == null) return false;
|
||||
|
||||
float worldx = Graphics.world(screenX, screenY).x, worldy = Graphics.world(screenX, screenY).y;
|
||||
|
||||
if(button == Buttons.LEFT){ //left = begin placing
|
||||
if(!ui.hasMouse()){
|
||||
if(Inputs.keyTap(section, "select")){
|
||||
if(isPlacing()){
|
||||
selectX = cursor.x;
|
||||
selectY = cursor.y;
|
||||
mode = placing;
|
||||
}else{
|
||||
//only begin shooting if there's no cursor event
|
||||
if(!tileTapped(cursor) && !tryTapPlayer(worldx, worldy) && player.getPlaceQueue().size == 0 && !droppingItem &&
|
||||
!tryBeginMine(cursor) && player.getMineTile() == null){
|
||||
if (!tileTapped(cursor) && !tryTapPlayer(Graphics.mouseWorld().x, Graphics.mouseWorld().y) && player.getPlaceQueue().size == 0 && !droppingItem &&
|
||||
!tryBeginMine(cursor) && player.getMineTile() == null) {
|
||||
player.isShooting = true;
|
||||
}
|
||||
}
|
||||
}else if(button == Buttons.RIGHT){ //right = begin breaking
|
||||
selectX = cursor.x;
|
||||
selectY = cursor.y;
|
||||
mode = breaking;
|
||||
}else if(button == Buttons.MIDDLE){ //middle button = cancel placing
|
||||
}else if(Inputs.keyTap(section, "deselect") && (recipe != null || mode != none || player.isBuilding())){
|
||||
if(recipe == null){
|
||||
player.clearBuilding();
|
||||
}
|
||||
|
||||
recipe = null;
|
||||
mode = none;
|
||||
}else if(Inputs.keyTap(section, "break")){
|
||||
selectX = cursor.x;
|
||||
selectY = cursor.y;
|
||||
mode = breaking;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean touchUp(int screenX, int screenY, int pointer, int button){
|
||||
if(button == Buttons.LEFT){
|
||||
player.isShooting = false;
|
||||
}
|
||||
|
||||
if(player.isDead() || state.is(State.menu) || ui.hasDialog()) return false;
|
||||
|
||||
Tile cursor = tileAt(screenX, screenY);
|
||||
|
||||
if(cursor == null){
|
||||
mode = none;
|
||||
return false;
|
||||
}
|
||||
if(Inputs.keyRelease(section, "break") || Inputs.keyRelease(section, "select")){
|
||||
|
||||
if(mode == placing){ //touch up while placing, place everything in selection
|
||||
NormalizeResult result = PlaceUtils.normalizeArea(selectX, selectY, cursor.x, cursor.y, rotation, true, maxLength);
|
||||
@@ -295,11 +284,11 @@ public class DesktopInput extends InputHandler{
|
||||
}
|
||||
}
|
||||
|
||||
tryDropItems(cursor.target(), Graphics.world(screenX, screenY).x, Graphics.world(screenX, screenY).y);
|
||||
tryDropItems(cursor.target(), Graphics.mouseWorld().x, Graphics.mouseWorld().y);
|
||||
|
||||
mode = none;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user