diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 60b7462d81..cad740c8fd 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -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 diff --git a/core/src/io/anuke/mindustry/input/DefaultKeybinds.java b/core/src/io/anuke/mindustry/input/DefaultKeybinds.java index 0a5c5cc01f..9c8daba9ec 100644 --- a/core/src/io/anuke/mindustry/input/DefaultKeybinds.java +++ b/core/src/io/anuke/mindustry/input/DefaultKeybinds.java @@ -16,51 +16,51 @@ public class DefaultKeybinds{ for(String section : sections){ KeyBinds.defaultSection(section, DeviceType.keyboard, - 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, - "rotate", new Axis(Input.SCROLL), - "dash", Input.SHIFT_LEFT, - "ability", Input.SPACE, - "drop_unit", Input.SHIFT_LEFT, - new Category("view"), - "zoom_hold", Input.CONTROL_LEFT, - "zoom", new Axis(Input.SCROLL), - "zoom_minimap", new Axis(Input.MINUS, Input.PLUS), - "menu", Gdx.app.getType() == ApplicationType.Android ? Input.BACK : Input.ESCAPE, - "pause", Input.Q, - "toggle_menus", Input.C, - new Category("multiplayer"), - "player_list", Input.TAB, - "chat", Input.ENTER, - "chat_history_prev", Input.UP, - "chat_history_next", Input.DOWN, - "chat_scroll", new Axis(Input.SCROLL), - "console", Input.GRAVE + new Category("general"), + "move_x", new Axis(Input.A, Input.D), + "move_y", new Axis(Input.S, Input.W), + "select", Input.MOUSE_LEFT, + "deselect", Input.SPACE, + "break", Input.MOUSE_RIGHT, + "rotate", new Axis(Input.SCROLL), + "dash", Input.SHIFT_LEFT, + "ability", Input.Q, + "drop_unit", Input.SHIFT_LEFT, + new Category("view"), + "zoom_hold", Input.CONTROL_LEFT, + "zoom", new Axis(Input.SCROLL), + "zoom_minimap", new Axis(Input.MINUS, Input.PLUS), + "menu", Gdx.app.getType() == ApplicationType.Android ? Input.BACK : Input.ESCAPE, + "pause", Input.Q, + "toggle_menus", Input.C, + new Category("multiplayer"), + "player_list", Input.TAB, + "chat", Input.ENTER, + "chat_history_prev", Input.UP, + "chat_history_next", Input.DOWN, + "chat_scroll", new Axis(Input.SCROLL), + "console", Input.GRAVE ); KeyBinds.defaultSection(section, DeviceType.controller, - new Category("general"), - "move_x", new Axis(Input.CONTROLLER_L_STICK_HORIZONTAL_AXIS), - "move_y", new Axis(Input.CONTROLLER_L_STICK_VERTICAL_AXIS), - "cursor_x", new Axis(Input.CONTROLLER_R_STICK_HORIZONTAL_AXIS), - "cursor_y", new Axis(Input.CONTROLLER_R_STICK_VERTICAL_AXIS), - //"select", Input.CONTROLLER_R_BUMPER, - //"break", Input.CONTROLLER_L_BUMPER, - //"shoot", Input.CONTROLLER_R_TRIGGER, - "dash", Input.CONTROLLER_Y, - "rotate_alt", new Axis(Input.CONTROLLER_DPAD_RIGHT, Input.CONTROLLER_DPAD_LEFT), - "rotate", new Axis(Input.CONTROLLER_A, Input.CONTROLLER_B), - new Category("view"), - "zoom_hold", Input.ANY_KEY, - "zoom", new Axis(Input.CONTROLLER_DPAD_DOWN, Input.CONTROLLER_DPAD_UP), - "menu", Input.CONTROLLER_X, - "pause", Input.CONTROLLER_L_TRIGGER, - new Category("multiplayer"), - "player_list", Input.CONTROLLER_START + new Category("general"), + "move_x", new Axis(Input.CONTROLLER_L_STICK_HORIZONTAL_AXIS), + "move_y", new Axis(Input.CONTROLLER_L_STICK_VERTICAL_AXIS), + "cursor_x", new Axis(Input.CONTROLLER_R_STICK_HORIZONTAL_AXIS), + "cursor_y", new Axis(Input.CONTROLLER_R_STICK_VERTICAL_AXIS), + //"select", Input.CONTROLLER_R_BUMPER, + //"break", Input.CONTROLLER_L_BUMPER, + //"shoot", Input.CONTROLLER_R_TRIGGER, + "dash", Input.CONTROLLER_Y, + "rotate_alt", new Axis(Input.CONTROLLER_DPAD_RIGHT, Input.CONTROLLER_DPAD_LEFT), + "rotate", new Axis(Input.CONTROLLER_A, Input.CONTROLLER_B), + new Category("view"), + "zoom_hold", Input.ANY_KEY, + "zoom", new Axis(Input.CONTROLLER_DPAD_DOWN, Input.CONTROLLER_DPAD_UP), + "menu", Input.CONTROLLER_X, + "pause", Input.CONTROLLER_L_TRIGGER, + new Category("multiplayer"), + "player_list", Input.CONTROLLER_START ); } diff --git a/core/src/io/anuke/mindustry/input/DesktopInput.java b/core/src/io/anuke/mindustry/input/DesktopInput.java index 91a58e86bd..0a69a59489 100644 --- a/core/src/io/anuke/mindustry/input/DesktopInput.java +++ b/core/src/io/anuke/mindustry/input/DesktopInput.java @@ -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,91 +220,75 @@ 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; - - 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(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){ - 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 - if(recipe == null){ - player.clearBuilding(); - } - - recipe = null; - mode = none; - } - - 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); - + void pollInput(){ + Tile cursor = tileAt(control.gdxInput().getX(), control.gdxInput().getY()); if(cursor == null){ mode = none; - return false; + return; } - if(mode == placing){ //touch up while placing, place everything in selection - NormalizeResult result = PlaceUtils.normalizeArea(selectX, selectY, cursor.x, cursor.y, rotation, true, maxLength); + 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(Graphics.mouseWorld().x, Graphics.mouseWorld().y) && player.getPlaceQueue().size == 0 && !droppingItem && + !tryBeginMine(cursor) && player.getMineTile() == null) { + player.isShooting = true; + } + } + }else if(Inputs.keyTap(section, "deselect") && (recipe != null || mode != none || player.isBuilding())){ + if(recipe == null){ + player.clearBuilding(); + } - for(int i = 0; i <= result.getLength(); i += recipe.result.size){ - int x = selectX + i * Mathf.sign(cursor.x - selectX) * Mathf.bool(result.isX()); - int y = selectY + i * Mathf.sign(cursor.y - selectY) * Mathf.bool(!result.isX()); - - rotation = result.rotation; - - tryPlaceBlock(x, y); + recipe = null; + mode = none; + }else if(Inputs.keyTap(section, "break")){ + selectX = cursor.x; + selectY = cursor.y; + mode = breaking; } - }else if(mode == breaking){ //touch up while breaking, break everything in selection - NormalizeResult result = PlaceUtils.normalizeArea(selectX, selectY, cursor.x, cursor.y, rotation, false, maxLength); + } - if(debug && Inputs.keyDown(Input.CONTROL_LEFT)){ - printArea(result); - }else{ - for(int x = 0; x <= Math.abs(result.x2 - result.x); x++){ - for(int y = 0; y <= Math.abs(result.y2 - result.y); y++){ - int wx = selectX + x * Mathf.sign(cursor.x - selectX); - int wy = selectY + y * Mathf.sign(cursor.y - selectY); + if(Inputs.keyRelease(section, "break") || Inputs.keyRelease(section, "select")){ - tryBreakBlock(wx, wy); + if(mode == placing){ //touch up while placing, place everything in selection + NormalizeResult result = PlaceUtils.normalizeArea(selectX, selectY, cursor.x, cursor.y, rotation, true, maxLength); + + for(int i = 0; i <= result.getLength(); i += recipe.result.size){ + int x = selectX + i * Mathf.sign(cursor.x - selectX) * Mathf.bool(result.isX()); + int y = selectY + i * Mathf.sign(cursor.y - selectY) * Mathf.bool(!result.isX()); + + rotation = result.rotation; + + tryPlaceBlock(x, y); + } + }else if(mode == breaking){ //touch up while breaking, break everything in selection + NormalizeResult result = PlaceUtils.normalizeArea(selectX, selectY, cursor.x, cursor.y, rotation, false, maxLength); + + if(debug && Inputs.keyDown(Input.CONTROL_LEFT)){ + printArea(result); + }else{ + for(int x = 0; x <= Math.abs(result.x2 - result.x); x++){ + for(int y = 0; y <= Math.abs(result.y2 - result.y); y++){ + int wx = selectX + x * Mathf.sign(cursor.x - selectX); + int wy = selectY + y * Mathf.sign(cursor.y - selectY); + + tryBreakBlock(wx, wy); + } } } } + + tryDropItems(cursor.target(), Graphics.mouseWorld().x, Graphics.mouseWorld().y); + + mode = none; } - - tryDropItems(cursor.target(), Graphics.world(screenX, screenY).x, Graphics.world(screenX, screenY).y); - - mode = none; - - return false; + } @Override