Keybind search bar + modding support
This commit is contained in:
@@ -4,6 +4,7 @@ import arc.*;
|
|||||||
import arc.assets.*;
|
import arc.assets.*;
|
||||||
import arc.files.*;
|
import arc.files.*;
|
||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
|
import arc.input.*;
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.struct.*;
|
import arc.struct.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
@@ -451,10 +452,16 @@ public class Vars implements Loadable{
|
|||||||
//needed to make sure binding values are correct
|
//needed to make sure binding values are correct
|
||||||
Vars.android = app.isAndroid();
|
Vars.android = app.isAndroid();
|
||||||
settings.defaults("locale", "default", "blocksync", true);
|
settings.defaults("locale", "default", "blocksync", true);
|
||||||
keybinds.setDefaults(Binding.values());
|
|
||||||
settings.setAutosave(false);
|
settings.setAutosave(false);
|
||||||
settings.load();
|
settings.load();
|
||||||
|
|
||||||
|
//this should not be necessary, but in case Binding is initialized before Settings#load(), do that here
|
||||||
|
for(KeyBind bind : KeyBind.all){
|
||||||
|
bind.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
Binding.init();
|
||||||
|
|
||||||
//https://github.com/Anuken/Mindustry/issues/8483
|
//https://github.com/Anuken/Mindustry/issues/8483
|
||||||
if(settings.getInt("uiscale") == 5){
|
if(settings.getInt("uiscale") == 5){
|
||||||
settings.put("uiscale", 100);
|
settings.put("uiscale", 100);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package mindustry.ai;
|
|||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
import arc.func.*;
|
import arc.func.*;
|
||||||
|
import arc.input.*;
|
||||||
import arc.scene.style.*;
|
import arc.scene.style.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.ai.types.*;
|
import mindustry.ai.types.*;
|
||||||
@@ -31,7 +32,7 @@ public class UnitCommand extends MappableContent{
|
|||||||
/** If true, this command refreshes the list of stances when selected TODO: do not use, this will likely be removed later!*/
|
/** If true, this command refreshes the list of stances when selected TODO: do not use, this will likely be removed later!*/
|
||||||
public boolean refreshOnSelect = false;
|
public boolean refreshOnSelect = false;
|
||||||
/** Key to press for this command. */
|
/** Key to press for this command. */
|
||||||
public @Nullable Binding keybind = null;
|
public @Nullable KeyBind keybind = null;
|
||||||
|
|
||||||
public UnitCommand(String name, String icon, Func<Unit, AIController> controller){
|
public UnitCommand(String name, String icon, Func<Unit, AIController> controller){
|
||||||
super(name);
|
super(name);
|
||||||
@@ -40,7 +41,7 @@ public class UnitCommand extends MappableContent{
|
|||||||
this.controller = controller == null ? u -> null : controller;
|
this.controller = controller == null ? u -> null : controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UnitCommand(String name, String icon, Binding keybind, Func<Unit, AIController> controller){
|
public UnitCommand(String name, String icon, KeyBind keybind, Func<Unit, AIController> controller){
|
||||||
this(name, icon, controller);
|
this(name, icon, controller);
|
||||||
this.keybind = keybind;
|
this.keybind = keybind;
|
||||||
}
|
}
|
||||||
@@ -69,48 +70,48 @@ public class UnitCommand extends MappableContent{
|
|||||||
|
|
||||||
public static void loadAll(){
|
public static void loadAll(){
|
||||||
|
|
||||||
moveCommand = new UnitCommand("move", "right", Binding.unit_command_move, null){{
|
moveCommand = new UnitCommand("move", "right", Binding.unitCommandMove, null){{
|
||||||
drawTarget = true;
|
drawTarget = true;
|
||||||
resetTarget = false;
|
resetTarget = false;
|
||||||
}};
|
}};
|
||||||
repairCommand = new UnitCommand("repair", "modeSurvival", Binding.unit_command_repair, u -> new RepairAI());
|
repairCommand = new UnitCommand("repair", "modeSurvival", Binding.unitCommandRepair, u -> new RepairAI());
|
||||||
rebuildCommand = new UnitCommand("rebuild", "hammer", Binding.unit_command_rebuild, u -> new BuilderAI());
|
rebuildCommand = new UnitCommand("rebuild", "hammer", Binding.unitCommandRebuild, u -> new BuilderAI());
|
||||||
assistCommand = new UnitCommand("assist", "players", Binding.unit_command_assist, u -> {
|
assistCommand = new UnitCommand("assist", "players", Binding.unitCommandAssist, u -> {
|
||||||
var ai = new BuilderAI();
|
var ai = new BuilderAI();
|
||||||
ai.onlyAssist = true;
|
ai.onlyAssist = true;
|
||||||
return ai;
|
return ai;
|
||||||
});
|
});
|
||||||
mineCommand = new UnitCommand("mine", "production", Binding.unit_command_mine, u -> new MinerAI()){{
|
mineCommand = new UnitCommand("mine", "production", Binding.unitCommandNine, u -> new MinerAI()){{
|
||||||
refreshOnSelect = true;
|
refreshOnSelect = true;
|
||||||
}};
|
}};
|
||||||
boostCommand = new UnitCommand("boost", "up", Binding.unit_command_boost, u -> new BoostAI()){{
|
boostCommand = new UnitCommand("boost", "up", Binding.unitCommandBoost, u -> new BoostAI()){{
|
||||||
switchToMove = false;
|
switchToMove = false;
|
||||||
drawTarget = true;
|
drawTarget = true;
|
||||||
resetTarget = false;
|
resetTarget = false;
|
||||||
}};
|
}};
|
||||||
enterPayloadCommand = new UnitCommand("enterPayload", "downOpen", Binding.unit_command_enter_payload, null){{
|
enterPayloadCommand = new UnitCommand("enterPayload", "downOpen", Binding.unitCommandEnterPayload, null){{
|
||||||
switchToMove = false;
|
switchToMove = false;
|
||||||
drawTarget = true;
|
drawTarget = true;
|
||||||
resetTarget = false;
|
resetTarget = false;
|
||||||
snapToBuilding = true;
|
snapToBuilding = true;
|
||||||
}};
|
}};
|
||||||
loadUnitsCommand = new UnitCommand("loadUnits", "upload", Binding.unit_command_load_units, null){{
|
loadUnitsCommand = new UnitCommand("loadUnits", "upload", Binding.unitCommandLoadUnits, null){{
|
||||||
switchToMove = false;
|
switchToMove = false;
|
||||||
drawTarget = true;
|
drawTarget = true;
|
||||||
resetTarget = false;
|
resetTarget = false;
|
||||||
}};
|
}};
|
||||||
loadBlocksCommand = new UnitCommand("loadBlocks", "up", Binding.unit_command_load_blocks, null){{
|
loadBlocksCommand = new UnitCommand("loadBlocks", "up", Binding.unitCommandLoadBlocks, null){{
|
||||||
switchToMove = false;
|
switchToMove = false;
|
||||||
drawTarget = true;
|
drawTarget = true;
|
||||||
resetTarget = false;
|
resetTarget = false;
|
||||||
exactArrival = true;
|
exactArrival = true;
|
||||||
}};
|
}};
|
||||||
unloadPayloadCommand = new UnitCommand("unloadPayload", "download", Binding.unit_command_unload_payload, null){{
|
unloadPayloadCommand = new UnitCommand("unloadPayload", "download", Binding.unitCommandUnloadPayload, null){{
|
||||||
switchToMove = false;
|
switchToMove = false;
|
||||||
drawTarget = true;
|
drawTarget = true;
|
||||||
resetTarget = false;
|
resetTarget = false;
|
||||||
}};
|
}};
|
||||||
loopPayloadCommand = new UnitCommand("loopPayload", "resize", Binding.unit_command_loop_payload, null){{
|
loopPayloadCommand = new UnitCommand("loopPayload", "resize", Binding.unitCommandLoopPayload, null){{
|
||||||
switchToMove = false;
|
switchToMove = false;
|
||||||
drawTarget = true;
|
drawTarget = true;
|
||||||
resetTarget = false;
|
resetTarget = false;
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package mindustry.ai;
|
package mindustry.ai;
|
||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
|
import arc.input.*;
|
||||||
import arc.scene.style.*;
|
import arc.scene.style.*;
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.*;
|
import mindustry.*;
|
||||||
@@ -15,9 +16,9 @@ public class UnitStance extends MappableContent{
|
|||||||
/** Name of UI icon (from Icon class). */
|
/** Name of UI icon (from Icon class). */
|
||||||
public String icon;
|
public String icon;
|
||||||
/** Key to press for this stance. */
|
/** Key to press for this stance. */
|
||||||
public @Nullable Binding keybind;
|
public @Nullable KeyBind keybind;
|
||||||
|
|
||||||
public UnitStance(String name, String icon, Binding keybind){
|
public UnitStance(String name, String icon, KeyBind keybind){
|
||||||
super(name);
|
super(name);
|
||||||
this.icon = icon;
|
this.icon = icon;
|
||||||
this.keybind = keybind;
|
this.keybind = keybind;
|
||||||
@@ -46,12 +47,12 @@ public class UnitStance extends MappableContent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void loadAll(){
|
public static void loadAll(){
|
||||||
stop = new UnitStance("stop", "cancel", Binding.cancel_orders);
|
stop = new UnitStance("stop", "cancel", Binding.cancelOrders);
|
||||||
shoot = new UnitStance("shoot", "commandAttack", Binding.unit_stance_shoot);
|
shoot = new UnitStance("shoot", "commandAttack", Binding.unitStanceShoot);
|
||||||
holdFire = new UnitStance("holdfire", "none", Binding.unit_stance_hold_fire);
|
holdFire = new UnitStance("holdfire", "none", Binding.unitStanceHoldFire);
|
||||||
pursueTarget = new UnitStance("pursuetarget", "right", Binding.unit_stance_pursue_target);
|
pursueTarget = new UnitStance("pursuetarget", "right", Binding.unitStancePursueTarget);
|
||||||
patrol = new UnitStance("patrol", "refresh", Binding.unit_stance_patrol);
|
patrol = new UnitStance("patrol", "refresh", Binding.unitStancePatrol);
|
||||||
ram = new UnitStance("ram", "rightOpen", Binding.unit_stance_ram);
|
ram = new UnitStance("ram", "rightOpen", Binding.unitStanceRam);
|
||||||
mineAuto = new UnitStance("mineauto", "settings", null);
|
mineAuto = new UnitStance("mineauto", "settings", null);
|
||||||
|
|
||||||
//Only vanilla items are supported for now
|
//Only vanilla items are supported for now
|
||||||
|
|||||||
@@ -178,8 +178,8 @@ public class MapView extends Element implements GestureListener{
|
|||||||
super.act(delta);
|
super.act(delta);
|
||||||
|
|
||||||
if(Core.scene.getKeyboardFocus() == null || !Core.scene.hasField() && !Core.input.keyDown(KeyCode.controlLeft)){
|
if(Core.scene.getKeyboardFocus() == null || !Core.scene.hasField() && !Core.input.keyDown(KeyCode.controlLeft)){
|
||||||
float ax = Core.input.axis(Binding.move_x);
|
float ax = Core.input.axis(Binding.moveX);
|
||||||
float ay = Core.input.axis(Binding.move_y);
|
float ay = Core.input.axis(Binding.moveY);
|
||||||
offsetx -= ax * 15 * Time.delta / zoom;
|
offsetx -= ax * 15 * Time.delta / zoom;
|
||||||
offsety -= ay * 15 * Time.delta / zoom;
|
offsety -= ay * 15 * Time.delta / zoom;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,7 +214,7 @@ public class OverlayRenderer{
|
|||||||
build.drawDisabled();
|
build.drawDisabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Core.input.keyDown(Binding.rotateplaced) && build.block.rotate && build.block.quickRotate && build.interactable(player.team())){
|
if(Core.input.keyDown(Binding.rotatePlaced) && build.block.rotate && build.block.quickRotate && build.interactable(player.team())){
|
||||||
control.input.drawArrow(build.block, build.tileX(), build.tileY(), build.rotation, true);
|
control.input.drawArrow(build.block, build.tileX(), build.tileY(), build.rotation, true);
|
||||||
Draw.color(Pal.accent, 0.3f + Mathf.absin(4f, 0.2f));
|
Draw.color(Pal.accent, 0.3f + Mathf.absin(4f, 0.2f));
|
||||||
Fill.square(build.x, build.y, build.block.size * tilesize/2f);
|
Fill.square(build.x, build.y, build.block.size * tilesize/2f);
|
||||||
|
|||||||
@@ -59,6 +59,7 @@ public class Pal{
|
|||||||
darkishGray = new Color(0.3f, 0.3f, 0.3f, 1f),
|
darkishGray = new Color(0.3f, 0.3f, 0.3f, 1f),
|
||||||
darkerGray = new Color(0.2f, 0.2f, 0.2f, 1f),
|
darkerGray = new Color(0.2f, 0.2f, 0.2f, 1f),
|
||||||
darkestGray = new Color(0.1f, 0.1f, 0.1f, 1f),
|
darkestGray = new Color(0.1f, 0.1f, 0.1f, 1f),
|
||||||
|
darkestestGray = new Color(0.05f, 0.05f, 0.05f, 1f),
|
||||||
shadow = new Color(0, 0, 0, 0.22f),
|
shadow = new Color(0, 0, 0, 0.22f),
|
||||||
ammo = Color.valueOf("ff8947"),
|
ammo = Color.valueOf("ff8947"),
|
||||||
rubble = Color.valueOf("1c1817"),
|
rubble = Color.valueOf("1c1817"),
|
||||||
|
|||||||
@@ -1,127 +1,109 @@
|
|||||||
package mindustry.input;
|
package mindustry.input;
|
||||||
|
|
||||||
import arc.KeyBinds.*;
|
|
||||||
import arc.input.InputDevice.*;
|
|
||||||
import arc.input.*;
|
import arc.input.*;
|
||||||
|
import arc.input.KeyBind.*;
|
||||||
import mindustry.*;
|
import mindustry.*;
|
||||||
|
|
||||||
public enum Binding implements KeyBind{
|
public class Binding{
|
||||||
move_x(new Axis(KeyCode.a, KeyCode.d), "general"),
|
public static final KeyBind
|
||||||
move_y(new Axis(KeyCode.s, KeyCode.w)),
|
|
||||||
mouse_move(KeyCode.mouseBack),
|
|
||||||
pan(KeyCode.mouseForward),
|
|
||||||
|
|
||||||
boost(KeyCode.shiftLeft),
|
moveX = KeyBind.add("move_x", new Axis(KeyCode.a, KeyCode.d), "general"),
|
||||||
respawn(KeyCode.v),
|
moveY = KeyBind.add("move_y", new Axis(KeyCode.s, KeyCode.w)),
|
||||||
control(KeyCode.controlLeft),
|
mouseMove = KeyBind.add("mouse_move", KeyCode.mouseBack),
|
||||||
select(KeyCode.mouseLeft),
|
pan = KeyBind.add("pan", KeyCode.mouseForward),
|
||||||
deselect(KeyCode.mouseRight),
|
|
||||||
break_block(KeyCode.mouseRight),
|
|
||||||
|
|
||||||
pickupCargo(KeyCode.leftBracket),
|
boost = KeyBind.add("boost", KeyCode.shiftLeft),
|
||||||
dropCargo(KeyCode.rightBracket),
|
respawn = KeyBind.add("respawn", KeyCode.v),
|
||||||
|
control = KeyBind.add("control", KeyCode.controlLeft),
|
||||||
|
select = KeyBind.add("select", KeyCode.mouseLeft),
|
||||||
|
deselect = KeyBind.add("deselect", KeyCode.mouseRight),
|
||||||
|
breakBlock = KeyBind.add("break_block", KeyCode.mouseRight),
|
||||||
|
|
||||||
clear_building(KeyCode.q),
|
pickupCargo = KeyBind.add("pickupCargo", KeyCode.leftBracket),
|
||||||
pause_building(KeyCode.e),
|
dropCargo = KeyBind.add("dropCargo", KeyCode.rightBracket),
|
||||||
rotate(new Axis(KeyCode.scroll)),
|
|
||||||
rotateplaced(KeyCode.r),
|
|
||||||
diagonal_placement(KeyCode.controlLeft),
|
|
||||||
pick(KeyCode.mouseMiddle),
|
|
||||||
|
|
||||||
rebuild_select(KeyCode.b),
|
clearBuilding = KeyBind.add("clear_building", KeyCode.q),
|
||||||
schematic_select(KeyCode.f),
|
pauseBuilding = KeyBind.add("pause_building", KeyCode.e),
|
||||||
schematic_flip_x(KeyCode.z),
|
rotate = KeyBind.add("rotate", new Axis(KeyCode.scroll)),
|
||||||
schematic_flip_y(KeyCode.x),
|
rotatePlaced = KeyBind.add("rotateplaced", KeyCode.r),
|
||||||
schematic_menu(KeyCode.t),
|
diagonalPlacement = KeyBind.add("diagonal_placement", KeyCode.controlLeft),
|
||||||
|
pick = KeyBind.add("pick", KeyCode.mouseMiddle),
|
||||||
|
|
||||||
|
rebuildSelect = KeyBind.add("rebuild_select", KeyCode.b),
|
||||||
|
schematicSelect = KeyBind.add("schematic_select", KeyCode.f),
|
||||||
|
schematicFlipX = KeyBind.add("schematic_flip_x", KeyCode.z),
|
||||||
|
schematicFlipY = KeyBind.add("schematic_flip_y", KeyCode.x),
|
||||||
|
schematicMenu = KeyBind.add("schematic_menu", KeyCode.t),
|
||||||
|
|
||||||
|
|
||||||
command_mode(KeyCode.shiftLeft, "command"),
|
commandMode = KeyBind.add("command_mode", KeyCode.shiftLeft, "command"),
|
||||||
command_queue(KeyCode.mouseMiddle),
|
commandQueue = KeyBind.add("command_queue", KeyCode.mouseMiddle),
|
||||||
create_control_group(KeyCode.controlLeft),
|
createControlGroup = KeyBind.add("create_control_group", KeyCode.controlLeft),
|
||||||
|
|
||||||
select_all_units(KeyCode.g),
|
selectAllUnits = KeyBind.add("select_all_units", KeyCode.g),
|
||||||
select_all_unit_factories(KeyCode.h),
|
selectAllUnitFactories = KeyBind.add("select_all_unit_factories", KeyCode.h),
|
||||||
|
|
||||||
cancel_orders(KeyCode.unset),
|
cancelOrders = KeyBind.add("cancel_orders", KeyCode.unset),
|
||||||
|
|
||||||
unit_stance_shoot(KeyCode.unset),
|
unitStanceShoot = KeyBind.add("unit_stance_shoot", KeyCode.unset),
|
||||||
unit_stance_hold_fire(KeyCode.unset),
|
unitStanceHoldFire = KeyBind.add("unit_stance_hold_fire", KeyCode.unset),
|
||||||
unit_stance_pursue_target(KeyCode.unset),
|
unitStancePursueTarget = KeyBind.add("unit_stance_pursue_target", KeyCode.unset),
|
||||||
unit_stance_patrol(KeyCode.unset),
|
unitStancePatrol = KeyBind.add("unit_stance_patrol", KeyCode.unset),
|
||||||
unit_stance_ram(KeyCode.unset),
|
unitStanceRam = KeyBind.add("unit_stance_ram", KeyCode.unset),
|
||||||
|
|
||||||
unit_command_move(KeyCode.unset),
|
unitCommandMove = KeyBind.add("unit_command_move", KeyCode.unset),
|
||||||
unit_command_repair(KeyCode.unset),
|
unitCommandRepair = KeyBind.add("unit_command_repair", KeyCode.unset),
|
||||||
unit_command_rebuild(KeyCode.unset),
|
unitCommandRebuild = KeyBind.add("unit_command_rebuild", KeyCode.unset),
|
||||||
unit_command_assist(KeyCode.unset),
|
unitCommandAssist = KeyBind.add("unit_command_assist", KeyCode.unset),
|
||||||
unit_command_mine(KeyCode.unset),
|
unitCommandNine = KeyBind.add("unit_command_mine", KeyCode.unset),
|
||||||
unit_command_boost(KeyCode.unset),
|
unitCommandBoost = KeyBind.add("unit_command_boost", KeyCode.unset),
|
||||||
unit_command_enter_payload(KeyCode.unset),
|
unitCommandEnterPayload = KeyBind.add("unit_command_enter_payload", KeyCode.unset),
|
||||||
unit_command_load_units(KeyCode.unset),
|
unitCommandLoadUnits = KeyBind.add("unit_command_load_units", KeyCode.unset),
|
||||||
unit_command_load_blocks(KeyCode.unset),
|
unitCommandLoadBlocks = KeyBind.add("unit_command_load_blocks", KeyCode.unset),
|
||||||
unit_command_unload_payload(KeyCode.unset),
|
unitCommandUnloadPayload = KeyBind.add("unit_command_unload_payload", KeyCode.unset),
|
||||||
unit_command_loop_payload(KeyCode.unset),
|
unitCommandLoopPayload = KeyBind.add("unit_command_loop_payload", KeyCode.unset),
|
||||||
|
|
||||||
category_prev(KeyCode.comma, "blocks"),
|
categoryPrev = KeyBind.add("category_prev", KeyCode.comma, "blocks"),
|
||||||
category_next(KeyCode.period),
|
categoryNext = KeyBind.add("category_next", KeyCode.period),
|
||||||
|
|
||||||
block_select_left(KeyCode.left),
|
blockSelectLeft = KeyBind.add("block_select_left", KeyCode.left),
|
||||||
block_select_right(KeyCode.right),
|
blockSelectRight = KeyBind.add("block_select_right", KeyCode.right),
|
||||||
block_select_up(KeyCode.up),
|
blockSelectUp = KeyBind.add("block_select_up", KeyCode.up),
|
||||||
block_select_down(KeyCode.down),
|
blockSelectDown = KeyBind.add("block_select_down", KeyCode.down),
|
||||||
block_select_01(KeyCode.num1),
|
blockSelect01 = KeyBind.add("block_select_01", KeyCode.num1),
|
||||||
block_select_02(KeyCode.num2),
|
blockSelect02 = KeyBind.add("block_select_02", KeyCode.num2),
|
||||||
block_select_03(KeyCode.num3),
|
blockSelect03 = KeyBind.add("block_select_03", KeyCode.num3),
|
||||||
block_select_04(KeyCode.num4),
|
blockSelect04 = KeyBind.add("block_select_04", KeyCode.num4),
|
||||||
block_select_05(KeyCode.num5),
|
blockSelect05 = KeyBind.add("block_select_05", KeyCode.num5),
|
||||||
block_select_06(KeyCode.num6),
|
blockSelect06 = KeyBind.add("block_select_06", KeyCode.num6),
|
||||||
block_select_07(KeyCode.num7),
|
blockSelect07 = KeyBind.add("block_select_07", KeyCode.num7),
|
||||||
block_select_08(KeyCode.num8),
|
blockSelect08 = KeyBind.add("block_select_08", KeyCode.num8),
|
||||||
block_select_09(KeyCode.num9),
|
blockSelect09 = KeyBind.add("block_select_09", KeyCode.num9),
|
||||||
block_select_10(KeyCode.num0),
|
blockSelect10 = KeyBind.add("block_select_10", KeyCode.num0),
|
||||||
|
|
||||||
zoom(new Axis(KeyCode.scroll), "view"),
|
zoom = KeyBind.add("zoom", new Axis(KeyCode.scroll), "view"),
|
||||||
detach_camera(KeyCode.unset),
|
detachCamera = KeyBind.add("detach_camera", KeyCode.unset),
|
||||||
menu(Vars.android ? KeyCode.back : KeyCode.escape),
|
menu = KeyBind.add("menu", Vars.android ? KeyCode.back : KeyCode.escape),
|
||||||
fullscreen(KeyCode.f11),
|
fullscreen = KeyBind.add("fullscreen", KeyCode.f11),
|
||||||
pause(KeyCode.space),
|
pause = KeyBind.add("pause", KeyCode.space),
|
||||||
skip_wave(KeyCode.unset),
|
skipWave = KeyBind.add("skip_wave", KeyCode.unset),
|
||||||
minimap(KeyCode.m),
|
minimap = KeyBind.add("minimap", KeyCode.m),
|
||||||
research(KeyCode.j),
|
research = KeyBind.add("research", KeyCode.j),
|
||||||
planet_map(KeyCode.n),
|
planetMap = KeyBind.add("planet_map", KeyCode.n),
|
||||||
block_info(KeyCode.f1),
|
blockInfo = KeyBind.add("block_info", KeyCode.f1),
|
||||||
toggle_menus(KeyCode.c),
|
toggleMenus = KeyBind.add("toggle_menus", KeyCode.c),
|
||||||
screenshot(KeyCode.p),
|
screenshot = KeyBind.add("screenshot", KeyCode.p),
|
||||||
toggle_power_lines(KeyCode.f5),
|
togglePowerLines = KeyBind.add("toggle_power_lines", KeyCode.f5),
|
||||||
toggle_block_status(KeyCode.f6),
|
toggleBlockStatus = KeyBind.add("toggle_block_status", KeyCode.f6),
|
||||||
player_list(KeyCode.tab, "multiplayer"),
|
playerList = KeyBind.add("player_list", KeyCode.tab, "multiplayer"),
|
||||||
chat(KeyCode.enter),
|
chat = KeyBind.add("chat", KeyCode.enter),
|
||||||
chat_history_prev(KeyCode.up),
|
chatHistoryPrev = KeyBind.add("chat_history_prev", KeyCode.up),
|
||||||
chat_history_next(KeyCode.down),
|
chatHistoryNext = KeyBind.add("chat_history_next", KeyCode.down),
|
||||||
chat_scroll(new Axis(KeyCode.scroll)),
|
chatScroll = KeyBind.add("chat_scroll", new Axis(KeyCode.scroll)),
|
||||||
chat_mode(KeyCode.tab),
|
chatMode = KeyBind.add("chat_mode", KeyCode.tab),
|
||||||
console(KeyCode.f8),
|
console = KeyBind.add("console", KeyCode.f8)
|
||||||
;
|
;
|
||||||
|
|
||||||
private final KeybindValue defaultValue;
|
//dummy static class initializer
|
||||||
private final String category;
|
public static void init(){}
|
||||||
|
|
||||||
Binding(KeybindValue defaultValue, String category){
|
|
||||||
this.defaultValue = defaultValue;
|
|
||||||
this.category = category;
|
|
||||||
}
|
|
||||||
|
|
||||||
Binding(KeybindValue defaultValue){
|
|
||||||
this(defaultValue, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public KeybindValue defaultValue(DeviceType type){
|
|
||||||
return defaultValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String category(){
|
|
||||||
return category;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,14 +77,14 @@ public class DesktopInput extends InputHandler{
|
|||||||
if(!showHint()) return str;
|
if(!showHint()) return str;
|
||||||
str.setLength(0);
|
str.setLength(0);
|
||||||
if(!isBuilding && !Core.settings.getBool("buildautopause") && !player.unit().isBuilding()){
|
if(!isBuilding && !Core.settings.getBool("buildautopause") && !player.unit().isBuilding()){
|
||||||
str.append(Core.bundle.format("enablebuilding", Core.keybinds.get(Binding.pause_building).key.toString()));
|
str.append(Core.bundle.format("enablebuilding", Binding.pauseBuilding.value.key.toString()));
|
||||||
}else if(player.unit().isBuilding()){
|
}else if(player.unit().isBuilding()){
|
||||||
str.append(Core.bundle.format(isBuilding ? "pausebuilding" : "resumebuilding", Core.keybinds.get(Binding.pause_building).key.toString()))
|
str.append(Core.bundle.format(isBuilding ? "pausebuilding" : "resumebuilding", Binding.pauseBuilding.value.key.toString()))
|
||||||
.append("\n").append(Core.bundle.format("cancelbuilding", Core.keybinds.get(Binding.clear_building).key.toString()))
|
.append("\n").append(Core.bundle.format("cancelbuilding", Binding.clearBuilding.value.key.toString()))
|
||||||
.append("\n").append(Core.bundle.format("selectschematic", Core.keybinds.get(Binding.schematic_select).key.toString()));
|
.append("\n").append(Core.bundle.format("selectschematic", Binding.schematicSelect.value.key.toString()));
|
||||||
}
|
}
|
||||||
if(!player.dead() && !player.unit().spawnedByCore()){
|
if(!player.dead() && !player.unit().spawnedByCore()){
|
||||||
str.append(str.length() != 0 ? "\n" : "").append(Core.bundle.format("respawn", Core.keybinds.get(Binding.respawn).key.toString()));
|
str.append(str.length() != 0 ? "\n" : "").append(Core.bundle.format("respawn", Binding.respawn.value.key.toString()));
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}).style(Styles.outlineLabel);
|
}).style(Styles.outlineLabel);
|
||||||
@@ -98,8 +98,8 @@ public class DesktopInput extends InputHandler{
|
|||||||
t.table(Styles.black6, b -> {
|
t.table(Styles.black6, b -> {
|
||||||
b.defaults().left();
|
b.defaults().left();
|
||||||
b.label(() -> Core.bundle.format("schematic.flip",
|
b.label(() -> Core.bundle.format("schematic.flip",
|
||||||
Core.keybinds.get(Binding.schematic_flip_x).key.toString(),
|
Binding.schematicFlipX.value.key.toString(),
|
||||||
Core.keybinds.get(Binding.schematic_flip_y).key.toString())).style(Styles.outlineLabel).visible(() -> Core.settings.getBool("hints"));
|
Binding.schematicFlipY.value.key.toString())).style(Styles.outlineLabel).visible(() -> Core.settings.getBool("hints"));
|
||||||
b.row();
|
b.row();
|
||||||
b.table(a -> {
|
b.table(a -> {
|
||||||
a.button("@schematic.add", Icon.save, this::showSchematicSave).colspan(2).size(250f, 50f).disabled(f -> lastSchematic == null || lastSchematic.file != null);
|
a.button("@schematic.add", Icon.save, this::showSchematicSave).colspan(2).size(250f, 50f).disabled(f -> lastSchematic == null || lastSchematic.file != null);
|
||||||
@@ -120,14 +120,14 @@ public class DesktopInput extends InputHandler{
|
|||||||
|
|
||||||
//draw break selection
|
//draw break selection
|
||||||
if(mode == breaking){
|
if(mode == breaking){
|
||||||
drawBreakSelection(selectX, selectY, cursorX, cursorY, !(Core.input.keyDown(Binding.schematic_select) && schemX != -1 && schemY != -1) ? maxLength : Vars.maxSchematicSize, false);
|
drawBreakSelection(selectX, selectY, cursorX, cursorY, !(Core.input.keyDown(Binding.schematicSelect) && schemX != -1 && schemY != -1) ? maxLength : Vars.maxSchematicSize, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Core.scene.hasKeyboard() && mode != breaking){
|
if(!Core.scene.hasKeyboard() && mode != breaking){
|
||||||
|
|
||||||
if(Core.input.keyDown(Binding.schematic_select) && schemX != -1 && schemY != -1){
|
if(Core.input.keyDown(Binding.schematicSelect) && schemX != -1 && schemY != -1){
|
||||||
drawSelection(schemX, schemY, cursorX, cursorY, Vars.maxSchematicSize);
|
drawSelection(schemX, schemY, cursorX, cursorY, Vars.maxSchematicSize);
|
||||||
}else if(Core.input.keyDown(Binding.rebuild_select)){
|
}else if(Core.input.keyDown(Binding.rebuildSelect)){
|
||||||
drawRebuildSelection(schemX, schemY, cursorX, cursorY);
|
drawRebuildSelection(schemX, schemY, cursorX, cursorY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -218,7 +218,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
public void update(){
|
public void update(){
|
||||||
super.update();
|
super.update();
|
||||||
|
|
||||||
if(net.active() && Core.input.keyTap(Binding.player_list) && (scene.getKeyboardFocus() == null || scene.getKeyboardFocus().isDescendantOf(ui.listfrag.content) || scene.getKeyboardFocus().isDescendantOf(ui.minimapfrag.elem))){
|
if(net.active() && Core.input.keyTap(Binding.playerList) && (scene.getKeyboardFocus() == null || scene.getKeyboardFocus().isDescendantOf(ui.listfrag.content) || scene.getKeyboardFocus().isDescendantOf(ui.minimapfrag.elem))){
|
||||||
ui.listfrag.toggle();
|
ui.listfrag.toggle();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -228,7 +228,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
boolean detached = settings.getBool("detach-camera", false);
|
boolean detached = settings.getBool("detach-camera", false);
|
||||||
|
|
||||||
if(!scene.hasField() && !scene.hasDialog()){
|
if(!scene.hasField() && !scene.hasDialog()){
|
||||||
if(input.keyTap(Binding.detach_camera)){
|
if(input.keyTap(Binding.detachCamera)){
|
||||||
settings.put("detach-camera", detached = !detached);
|
settings.put("detach-camera", detached = !detached);
|
||||||
if(!detached){
|
if(!detached){
|
||||||
panning = false;
|
panning = false;
|
||||||
@@ -242,7 +242,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
spectating = null;
|
spectating = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((Math.abs(Core.input.axis(Binding.move_x)) > 0 || Math.abs(Core.input.axis(Binding.move_y)) > 0 || input.keyDown(Binding.mouse_move))){
|
if((Math.abs(Core.input.axis(Binding.moveX)) > 0 || Math.abs(Core.input.axis(Binding.moveY)) > 0 || input.keyDown(Binding.mouseMove))){
|
||||||
panning = false;
|
panning = false;
|
||||||
spectating = null;
|
spectating = null;
|
||||||
}
|
}
|
||||||
@@ -253,11 +253,11 @@ public class DesktopInput extends InputHandler{
|
|||||||
|
|
||||||
if(!locked){
|
if(!locked){
|
||||||
if(((player.dead() || state.isPaused() || detached) && !ui.chatfrag.shown()) && !scene.hasField() && !scene.hasDialog()){
|
if(((player.dead() || state.isPaused() || detached) && !ui.chatfrag.shown()) && !scene.hasField() && !scene.hasDialog()){
|
||||||
if(input.keyDown(Binding.mouse_move)){
|
if(input.keyDown(Binding.mouseMove)){
|
||||||
panCam = true;
|
panCam = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Core.camera.position.add(Tmp.v1.setZero().add(Core.input.axis(Binding.move_x), Core.input.axis(Binding.move_y)).nor().scl(camSpeed));
|
Core.camera.position.add(Tmp.v1.setZero().add(Core.input.axis(Binding.moveX), Core.input.axis(Binding.moveY)).nor().scl(camSpeed));
|
||||||
}else if((!player.dead() || spectating != null) && !panning){
|
}else if((!player.dead() || spectating != null) && !panning){
|
||||||
//TODO do not pan
|
//TODO do not pan
|
||||||
Team corePanTeam = state.won ? state.rules.waveTeam : player.team();
|
Team corePanTeam = state.won ? state.rules.waveTeam : player.team();
|
||||||
@@ -277,10 +277,10 @@ public class DesktopInput extends InputHandler{
|
|||||||
|
|
||||||
if(!locked && block == null && !scene.hasField() && !scene.hasDialog() &&
|
if(!locked && block == null && !scene.hasField() && !scene.hasDialog() &&
|
||||||
//disable command mode when player unit can boost and command mode binding is the same
|
//disable command mode when player unit can boost and command mode binding is the same
|
||||||
!(!player.dead() && player.unit().type.canBoost && keybinds.get(Binding.command_mode).key == keybinds.get(Binding.boost).key)){
|
!(!player.dead() && player.unit().type.canBoost && Binding.commandMode.value.key == Binding.boost.value.key)){
|
||||||
if(settings.getBool("commandmodehold")){
|
if(settings.getBool("commandmodehold")){
|
||||||
commandMode = input.keyDown(Binding.command_mode);
|
commandMode = input.keyDown(Binding.commandMode);
|
||||||
}else if(input.keyTap(Binding.command_mode)){
|
}else if(input.keyTap(Binding.commandMode)){
|
||||||
commandMode = !commandMode;
|
commandMode = !commandMode;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
@@ -291,7 +291,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
selectedUnits.removeAll(u -> !u.allowCommand() || !u.isValid() || u.team != player.team());
|
selectedUnits.removeAll(u -> !u.allowCommand() || !u.isValid() || u.team != player.team());
|
||||||
|
|
||||||
if(commandMode && !scene.hasField() && !scene.hasDialog()){
|
if(commandMode && !scene.hasField() && !scene.hasDialog()){
|
||||||
if(input.keyTap(Binding.select_all_units)){
|
if(input.keyTap(Binding.selectAllUnits)){
|
||||||
selectedUnits.clear();
|
selectedUnits.clear();
|
||||||
commandBuildings.clear();
|
commandBuildings.clear();
|
||||||
for(var unit : player.team().data().units){
|
for(var unit : player.team().data().units){
|
||||||
@@ -301,7 +301,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(input.keyTap(Binding.select_all_unit_factories)){
|
if(input.keyTap(Binding.selectAllUnitFactories)){
|
||||||
selectedUnits.clear();
|
selectedUnits.clear();
|
||||||
commandBuildings.clear();
|
commandBuildings.clear();
|
||||||
for(var build : player.team().data().buildings){
|
for(var build : player.team().data().buildings){
|
||||||
@@ -318,7 +318,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
if(controlGroups[i] == null) controlGroups[i] = new IntSeq();
|
if(controlGroups[i] == null) controlGroups[i] = new IntSeq();
|
||||||
|
|
||||||
IntSeq group = controlGroups[i];
|
IntSeq group = controlGroups[i];
|
||||||
boolean creating = input.keyDown(Binding.create_control_group);
|
boolean creating = input.keyDown(Binding.createControlGroup);
|
||||||
|
|
||||||
//clear existing if making a new control group
|
//clear existing if making a new control group
|
||||||
//if any of the control group edit buttons are pressed take the current selection
|
//if any of the control group edit buttons are pressed take the current selection
|
||||||
@@ -405,16 +405,16 @@ public class DesktopInput extends InputHandler{
|
|||||||
|
|
||||||
if(state.isGame() && !scene.hasDialog() && !scene.hasField()){
|
if(state.isGame() && !scene.hasDialog() && !scene.hasField()){
|
||||||
if(Core.input.keyTap(Binding.minimap)) ui.minimapfrag.toggle();
|
if(Core.input.keyTap(Binding.minimap)) ui.minimapfrag.toggle();
|
||||||
if(Core.input.keyTap(Binding.planet_map) && state.isCampaign()) ui.planet.toggle();
|
if(Core.input.keyTap(Binding.planetMap) && state.isCampaign()) ui.planet.toggle();
|
||||||
if(Core.input.keyTap(Binding.research) && state.isCampaign()) ui.research.toggle();
|
if(Core.input.keyTap(Binding.research) && state.isCampaign()) ui.research.toggle();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(state.isMenu() || Core.scene.hasDialog()) return;
|
if(state.isMenu() || Core.scene.hasDialog()) return;
|
||||||
|
|
||||||
//zoom camera
|
//zoom camera
|
||||||
if((!Core.scene.hasScroll() || Core.input.keyDown(Binding.diagonal_placement)) && !ui.chatfrag.shown() && !ui.consolefrag.shown() && Math.abs(Core.input.axisTap(Binding.zoom)) > 0
|
if((!Core.scene.hasScroll() || Core.input.keyDown(Binding.diagonalPlacement)) && !ui.chatfrag.shown() && !ui.consolefrag.shown() && Math.abs(Core.input.axisTap(Binding.zoom)) > 0
|
||||||
&& !Core.input.keyDown(Binding.rotateplaced) && (Core.input.keyDown(Binding.diagonal_placement) ||
|
&& !Core.input.keyDown(Binding.rotatePlaced) && (Core.input.keyDown(Binding.diagonalPlacement) ||
|
||||||
!keybinds.get(Binding.zoom).equals(keybinds.get(Binding.rotate)) || ((!player.isBuilder() || !isPlacing() || !block.rotate) && selectPlans.isEmpty()))){
|
!Binding.zoom.value.equals(Binding.rotate.value) || ((!player.isBuilder() || !isPlacing() || !block.rotate) && selectPlans.isEmpty()))){
|
||||||
renderer.scaleCamera(Core.input.axisTap(Binding.zoom));
|
renderer.scaleCamera(Core.input.axisTap(Binding.zoom));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -451,7 +451,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
selectScale = 0f;
|
selectScale = 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Core.input.keyDown(Binding.diagonal_placement) && Math.abs((int)Core.input.axisTap(Binding.rotate)) > 0){
|
if(!Core.input.keyDown(Binding.diagonalPlacement) && Math.abs((int)Core.input.axisTap(Binding.rotate)) > 0){
|
||||||
rotation = Mathf.mod(rotation + (int)Core.input.axisTap(Binding.rotate), 4);
|
rotation = Mathf.mod(rotation + (int)Core.input.axisTap(Binding.rotate), 4);
|
||||||
|
|
||||||
if(splan != null){
|
if(splan != null){
|
||||||
@@ -500,7 +500,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
cursorType = ui.targetCursor;
|
cursorType = ui.targetCursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(input.keyTap(Binding.command_queue) && keybinds.get(Binding.command_queue).key.type != KeyType.mouse){
|
if(input.keyTap(Binding.commandQueue) && Binding.commandQueue.value.key.type != KeyType.mouse){
|
||||||
commandTap(input.mouseX(), input.mouseY(), true);
|
commandTap(input.mouseX(), input.mouseY(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -514,7 +514,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(cursor.build != null && cursor.interactable(player.team()) && !isPlacing() && Math.abs(Core.input.axisTap(Binding.rotate)) > 0 && Core.input.keyDown(Binding.rotateplaced) && cursor.block().rotate && cursor.block().quickRotate){
|
if(cursor.build != null && cursor.interactable(player.team()) && !isPlacing() && Math.abs(Core.input.axisTap(Binding.rotate)) > 0 && Core.input.keyDown(Binding.rotatePlaced) && cursor.block().rotate && cursor.block().quickRotate){
|
||||||
Call.rotateBlock(player, cursor.build, Core.input.axisTap(Binding.rotate) > 0);
|
Call.rotateBlock(player, cursor.build, Core.input.axisTap(Binding.rotate) > 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -593,16 +593,16 @@ public class DesktopInput extends InputHandler{
|
|||||||
player.unit().mineTile = null;
|
player.unit().mineTile = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Core.input.keyTap(Binding.clear_building) && !player.dead()){
|
if(Core.input.keyTap(Binding.clearBuilding) && !player.dead()){
|
||||||
player.unit().clearBuilding();
|
player.unit().clearBuilding();
|
||||||
}
|
}
|
||||||
|
|
||||||
if((Core.input.keyTap(Binding.schematic_select) || Core.input.keyTap(Binding.rebuild_select)) && !Core.scene.hasKeyboard() && mode != breaking){
|
if((Core.input.keyTap(Binding.schematicSelect) || Core.input.keyTap(Binding.rebuildSelect)) && !Core.scene.hasKeyboard() && mode != breaking){
|
||||||
schemX = rawCursorX;
|
schemX = rawCursorX;
|
||||||
schemY = rawCursorY;
|
schemY = rawCursorY;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Core.input.keyTap(Binding.schematic_menu) && !Core.scene.hasKeyboard()){
|
if(Core.input.keyTap(Binding.schematicMenu) && !Core.scene.hasKeyboard()){
|
||||||
if(ui.schematics.isShown()){
|
if(ui.schematics.isShown()){
|
||||||
ui.schematics.hide();
|
ui.schematics.hide();
|
||||||
}else{
|
}else{
|
||||||
@@ -610,13 +610,13 @@ public class DesktopInput extends InputHandler{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Core.input.keyTap(Binding.clear_building) || isPlacing()){
|
if(Core.input.keyTap(Binding.clearBuilding) || isPlacing()){
|
||||||
lastSchematic = null;
|
lastSchematic = null;
|
||||||
selectPlans.clear();
|
selectPlans.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Core.scene.hasKeyboard() && selectX == -1 && selectY == -1 && schemX != -1 && schemY != -1){
|
if(!Core.scene.hasKeyboard() && selectX == -1 && selectY == -1 && schemX != -1 && schemY != -1){
|
||||||
if(Core.input.keyRelease(Binding.schematic_select)){
|
if(Core.input.keyRelease(Binding.schematicSelect)){
|
||||||
lastSchematic = schematics.create(schemX, schemY, rawCursorX, rawCursorY);
|
lastSchematic = schematics.create(schemX, schemY, rawCursorX, rawCursorY);
|
||||||
useSchematic(lastSchematic);
|
useSchematic(lastSchematic);
|
||||||
if(selectPlans.isEmpty()){
|
if(selectPlans.isEmpty()){
|
||||||
@@ -624,7 +624,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
}
|
}
|
||||||
schemX = -1;
|
schemX = -1;
|
||||||
schemY = -1;
|
schemY = -1;
|
||||||
}else if(input.keyRelease(Binding.rebuild_select)){
|
}else if(input.keyRelease(Binding.rebuildSelect)){
|
||||||
|
|
||||||
rebuildArea(schemX, schemY, rawCursorX, rawCursorY);
|
rebuildArea(schemX, schemY, rawCursorX, rawCursorY);
|
||||||
schemX = -1;
|
schemX = -1;
|
||||||
@@ -633,11 +633,11 @@ public class DesktopInput extends InputHandler{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!selectPlans.isEmpty()){
|
if(!selectPlans.isEmpty()){
|
||||||
if(Core.input.keyTap(Binding.schematic_flip_x)){
|
if(Core.input.keyTap(Binding.schematicFlipX)){
|
||||||
flipPlans(selectPlans, true);
|
flipPlans(selectPlans, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Core.input.keyTap(Binding.schematic_flip_y)){
|
if(Core.input.keyTap(Binding.schematicFlipY)){
|
||||||
flipPlans(selectPlans, false);
|
flipPlans(selectPlans, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -656,7 +656,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
linePlans.clear();
|
linePlans.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Core.input.keyTap(Binding.pause_building)){
|
if(Core.input.keyTap(Binding.pauseBuilding)){
|
||||||
isBuilding = !isBuilding;
|
isBuilding = !isBuilding;
|
||||||
buildWasAutoPaused = false;
|
buildWasAutoPaused = false;
|
||||||
|
|
||||||
@@ -693,7 +693,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
tappedOne = false;
|
tappedOne = false;
|
||||||
BuildPlan plan = getPlan(cursorX, cursorY);
|
BuildPlan plan = getPlan(cursorX, cursorY);
|
||||||
|
|
||||||
if(Core.input.keyDown(Binding.break_block)){
|
if(Core.input.keyDown(Binding.breakBlock)){
|
||||||
mode = none;
|
mode = none;
|
||||||
}else if(!selectPlans.isEmpty()){
|
}else if(!selectPlans.isEmpty()){
|
||||||
flushPlans(selectPlans);
|
flushPlans(selectPlans);
|
||||||
@@ -732,7 +732,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
}else if(Core.input.keyTap(Binding.deselect) && !selectPlans.isEmpty()){
|
}else if(Core.input.keyTap(Binding.deselect) && !selectPlans.isEmpty()){
|
||||||
selectPlans.clear();
|
selectPlans.clear();
|
||||||
lastSchematic = null;
|
lastSchematic = null;
|
||||||
}else if(Core.input.keyTap(Binding.break_block) && !Core.scene.hasMouse() && player.isBuilder() && !commandMode){
|
}else if(Core.input.keyTap(Binding.breakBlock) && !Core.scene.hasMouse() && player.isBuilder() && !commandMode){
|
||||||
//is recalculated because setting the mode to breaking removes potential multiblock cursor offset
|
//is recalculated because setting the mode to breaking removes potential multiblock cursor offset
|
||||||
deleting = false;
|
deleting = false;
|
||||||
mode = breaking;
|
mode = breaking;
|
||||||
@@ -752,7 +752,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(mode == placing && block != null){
|
if(mode == placing && block != null){
|
||||||
if(!overrideLineRotation && !Core.input.keyDown(Binding.diagonal_placement) && (selectX != cursorX || selectY != cursorY) && ((int)Core.input.axisTap(Binding.rotate) != 0)){
|
if(!overrideLineRotation && !Core.input.keyDown(Binding.diagonalPlacement) && (selectX != cursorX || selectY != cursorY) && ((int)Core.input.axisTap(Binding.rotate) != 0)){
|
||||||
rotation = ((int)((Angles.angle(selectX, selectY, cursorX, cursorY) + 45) / 90f)) % 4;
|
rotation = ((int)((Angles.angle(selectX, selectY, cursorX, cursorY) + 45) / 90f)) % 4;
|
||||||
overrideLineRotation = true;
|
overrideLineRotation = true;
|
||||||
}
|
}
|
||||||
@@ -760,13 +760,13 @@ public class DesktopInput extends InputHandler{
|
|||||||
overrideLineRotation = false;
|
overrideLineRotation = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Core.input.keyRelease(Binding.break_block) && Core.input.keyDown(Binding.schematic_select) && mode == breaking){
|
if(Core.input.keyRelease(Binding.breakBlock) && Core.input.keyDown(Binding.schematicSelect) && mode == breaking){
|
||||||
lastSchematic = schematics.create(schemX, schemY, rawCursorX, rawCursorY);
|
lastSchematic = schematics.create(schemX, schemY, rawCursorX, rawCursorY);
|
||||||
schemX = -1;
|
schemX = -1;
|
||||||
schemY = -1;
|
schemY = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Core.input.keyRelease(Binding.break_block) || Core.input.keyRelease(Binding.select)){
|
if(Core.input.keyRelease(Binding.breakBlock) || Core.input.keyRelease(Binding.select)){
|
||||||
|
|
||||||
if(mode == placing && block != null){ //touch up while placing, place everything in selection
|
if(mode == placing && block != null){ //touch up while placing, place everything in selection
|
||||||
if(input.keyDown(Binding.boost)){
|
if(input.keyDown(Binding.boost)){
|
||||||
@@ -778,7 +778,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
linePlans.clear();
|
linePlans.clear();
|
||||||
Events.fire(new LineConfirmEvent());
|
Events.fire(new LineConfirmEvent());
|
||||||
}else if(mode == breaking){ //touch up while breaking, break everything in selection
|
}else if(mode == breaking){ //touch up while breaking, break everything in selection
|
||||||
removeSelection(selectX, selectY, cursorX, cursorY, !Core.input.keyDown(Binding.schematic_select) ? maxLength : Vars.maxSchematicSize);
|
removeSelection(selectX, selectY, cursorX, cursorY, !Core.input.keyDown(Binding.schematicSelect) ? maxLength : Vars.maxSchematicSize);
|
||||||
if(lastSchematic != null){
|
if(lastSchematic != null){
|
||||||
useSchematic(lastSchematic);
|
useSchematic(lastSchematic);
|
||||||
lastSchematic = null;
|
lastSchematic = null;
|
||||||
@@ -808,11 +808,11 @@ public class DesktopInput extends InputHandler{
|
|||||||
mode = none;
|
mode = none;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Core.input.keyTap(Binding.toggle_block_status)){
|
if(Core.input.keyTap(Binding.toggleBlockStatus)){
|
||||||
Core.settings.put("blockstatus", !Core.settings.getBool("blockstatus"));
|
Core.settings.put("blockstatus", !Core.settings.getBool("blockstatus"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Core.input.keyTap(Binding.toggle_power_lines)){
|
if(Core.input.keyTap(Binding.togglePowerLines)){
|
||||||
if(Core.settings.getInt("lasersopacity") == 0){
|
if(Core.settings.getInt("lasersopacity") == 0){
|
||||||
Core.settings.put("lasersopacity", Core.settings.getInt("preferredlaseropacity", 100));
|
Core.settings.put("lasersopacity", Core.settings.getInt("preferredlaseropacity", 100));
|
||||||
}else{
|
}else{
|
||||||
@@ -849,7 +849,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
commandTap(x, y);
|
commandTap(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(button == keybinds.get(Binding.command_queue).key){
|
if(button == Binding.commandQueue.value.key){
|
||||||
commandTap(x, y, true);
|
commandTap(x, y, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -897,8 +897,8 @@ public class DesktopInput extends InputHandler{
|
|||||||
boolean omni = unit.type.omniMovement;
|
boolean omni = unit.type.omniMovement;
|
||||||
|
|
||||||
float speed = unit.speed();
|
float speed = unit.speed();
|
||||||
float xa = Core.input.axis(Binding.move_x);
|
float xa = Core.input.axis(Binding.moveX);
|
||||||
float ya = Core.input.axis(Binding.move_y);
|
float ya = Core.input.axis(Binding.moveY);
|
||||||
boolean boosted = (unit instanceof Mechc && unit.isFlying());
|
boolean boosted = (unit instanceof Mechc && unit.isFlying());
|
||||||
|
|
||||||
if(settings.getBool("detach-camera")){
|
if(settings.getBool("detach-camera")){
|
||||||
@@ -912,7 +912,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
movement.set(xa, ya).nor().scl(speed);
|
movement.set(xa, ya).nor().scl(speed);
|
||||||
if(Core.input.keyDown(Binding.mouse_move)){
|
if(Core.input.keyDown(Binding.mouseMove)){
|
||||||
movement.add(input.mouseWorld().sub(player).scl(1f / 25f * speed)).limit(speed);
|
movement.add(input.mouseWorld().sub(player).scl(1f / 25f * speed)).limit(speed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,17 +62,17 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
final static int maxLength = 100;
|
final static int maxLength = 100;
|
||||||
final static Rect r1 = new Rect(), r2 = new Rect();
|
final static Rect r1 = new Rect(), r2 = new Rect();
|
||||||
final static Seq<Unit> tmpUnits = new Seq<>(false);
|
final static Seq<Unit> tmpUnits = new Seq<>(false);
|
||||||
final static Binding[] controlGroupBindings = {
|
final static KeyBind[] controlGroupBindings = {
|
||||||
Binding.block_select_01,
|
Binding.blockSelect01,
|
||||||
Binding.block_select_02,
|
Binding.blockSelect02,
|
||||||
Binding.block_select_03,
|
Binding.blockSelect03,
|
||||||
Binding.block_select_04,
|
Binding.blockSelect04,
|
||||||
Binding.block_select_05,
|
Binding.blockSelect05,
|
||||||
Binding.block_select_06,
|
Binding.blockSelect06,
|
||||||
Binding.block_select_07,
|
Binding.blockSelect07,
|
||||||
Binding.block_select_08,
|
Binding.blockSelect08,
|
||||||
Binding.block_select_09,
|
Binding.blockSelect09,
|
||||||
Binding.block_select_10
|
Binding.blockSelect10
|
||||||
};
|
};
|
||||||
|
|
||||||
/** If true, there is a cutscene currently occurring in logic. */
|
/** If true, there is a cutscene currently occurring in logic. */
|
||||||
@@ -1905,7 +1905,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRebuildSelecting(){
|
public boolean isRebuildSelecting(){
|
||||||
return input.keyDown(Binding.rebuild_select);
|
return input.keyDown(Binding.rebuildSelect);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float mouseAngle(float x, float y){
|
public float mouseAngle(float x, float y){
|
||||||
@@ -2161,7 +2161,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
|
|
||||||
void iterateLine(int startX, int startY, int endX, int endY, Cons<PlaceLine> cons){
|
void iterateLine(int startX, int startY, int endX, int endY, Cons<PlaceLine> cons){
|
||||||
Seq<Point2> points;
|
Seq<Point2> points;
|
||||||
boolean diagonal = Core.input.keyDown(Binding.diagonal_placement);
|
boolean diagonal = Core.input.keyDown(Binding.diagonalPlacement);
|
||||||
|
|
||||||
if(Core.settings.getBool("swapdiagonal") && mobile){
|
if(Core.settings.getBool("swapdiagonal") && mobile){
|
||||||
diagonal = !diagonal;
|
diagonal = !diagonal;
|
||||||
|
|||||||
@@ -778,14 +778,14 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//zoom camera
|
//zoom camera
|
||||||
if(!locked && !scene.hasKeyboard() && !scene.hasScroll() && Math.abs(Core.input.axisTap(Binding.zoom)) > 0 && !Core.input.keyDown(Binding.rotateplaced) && (Core.input.keyDown(Binding.diagonal_placement) || ((!player.isBuilder() || !isPlacing() || !block.rotate) && selectPlans.isEmpty()))){
|
if(!locked && !scene.hasKeyboard() && !scene.hasScroll() && Math.abs(Core.input.axisTap(Binding.zoom)) > 0 && !Core.input.keyDown(Binding.rotatePlaced) && (Core.input.keyDown(Binding.diagonalPlacement) || ((!player.isBuilder() || !isPlacing() || !block.rotate) && selectPlans.isEmpty()))){
|
||||||
renderer.scaleCamera(Core.input.axisTap(Binding.zoom));
|
renderer.scaleCamera(Core.input.axisTap(Binding.zoom));
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Core.settings.getBool("keyboard") && !locked && !scene.hasKeyboard()){
|
if(!Core.settings.getBool("keyboard") && !locked && !scene.hasKeyboard()){
|
||||||
//move camera around
|
//move camera around
|
||||||
float camSpeed = 6f;
|
float camSpeed = 6f;
|
||||||
Vec2 delta = Tmp.v1.setZero().add(Core.input.axis(Binding.move_x), Core.input.axis(Binding.move_y)).nor().scl(Time.delta * camSpeed);
|
Vec2 delta = Tmp.v1.setZero().add(Core.input.axis(Binding.moveX), Core.input.axis(Binding.moveY)).nor().scl(Time.delta * camSpeed);
|
||||||
Core.camera.position.add(delta);
|
Core.camera.position.add(delta);
|
||||||
if(!delta.isZero()){
|
if(!delta.isZero()){
|
||||||
spectating = null;
|
spectating = null;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import static mindustry.gen.Tex.*;
|
|||||||
@StyleDefaults
|
@StyleDefaults
|
||||||
public class Styles{
|
public class Styles{
|
||||||
//TODO all these names are inconsistent and not descriptive
|
//TODO all these names are inconsistent and not descriptive
|
||||||
public static Drawable black, black9, black8, black6, black3, black5, grayPanel, none, flatDown, flatOver, accentDrawable;
|
public static Drawable black, black9, black8, black6, black3, black5, grayPanel, grayPanelDark, none, flatDown, flatOver, accentDrawable;
|
||||||
|
|
||||||
public static ButtonStyle defaultb, underlineb;
|
public static ButtonStyle defaultb, underlineb;
|
||||||
|
|
||||||
@@ -109,6 +109,7 @@ public class Styles{
|
|||||||
black3 = whiteui.tint(0f, 0f, 0f, 0.3f);
|
black3 = whiteui.tint(0f, 0f, 0f, 0.3f);
|
||||||
none = whiteui.tint(0f, 0f, 0f, 0f);
|
none = whiteui.tint(0f, 0f, 0f, 0f);
|
||||||
grayPanel = whiteui.tint(Pal.darkestGray);
|
grayPanel = whiteui.tint(Pal.darkestGray);
|
||||||
|
grayPanelDark = whiteui.tint(Pal.darkestestGray);
|
||||||
flatDown = createFlatDown();
|
flatDown = createFlatDown();
|
||||||
flatOver = whiteui.tint(Color.valueOf("454545"));
|
flatOver = whiteui.tint(Color.valueOf("454545"));
|
||||||
accentDrawable = whiteui.tint(Pal.accent);
|
accentDrawable = whiteui.tint(Pal.accent);
|
||||||
@@ -155,7 +156,8 @@ public class Styles{
|
|||||||
over = flatOver;
|
over = flatOver;
|
||||||
font = Fonts.def;
|
font = Fonts.def;
|
||||||
fontColor = Color.white;
|
fontColor = Color.white;
|
||||||
disabledFontColor = Color.lightGray;
|
disabledFontColor = Color.gray;
|
||||||
|
disabled = grayPanelDark;
|
||||||
down = flatOver;
|
down = flatOver;
|
||||||
up = grayPanel;
|
up = grayPanel;
|
||||||
}};
|
}};
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class ContentInfoDialog extends BaseDialog{
|
|||||||
addCloseButton();
|
addCloseButton();
|
||||||
|
|
||||||
keyDown(key -> {
|
keyDown(key -> {
|
||||||
if(key == keybinds.get(Binding.block_info).key){
|
if(key == Binding.blockInfo.value.key){
|
||||||
Core.app.post(this::hide);
|
Core.app.post(this::hide);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,39 +1,62 @@
|
|||||||
package mindustry.ui.dialogs;
|
package mindustry.ui.dialogs;
|
||||||
|
|
||||||
import arc.*;
|
import arc.*;
|
||||||
import arc.KeyBinds.*;
|
|
||||||
import arc.graphics.*;
|
import arc.graphics.*;
|
||||||
import arc.input.*;
|
import arc.input.*;
|
||||||
import arc.input.InputDevice.*;
|
import arc.input.KeyBind.*;
|
||||||
import arc.scene.event.*;
|
import arc.scene.event.*;
|
||||||
import arc.scene.ui.*;
|
import arc.scene.ui.*;
|
||||||
import arc.scene.ui.layout.*;
|
import arc.scene.ui.layout.*;
|
||||||
import arc.struct.*;
|
|
||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
import mindustry.ui.*;
|
import mindustry.ui.*;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
import static arc.Core.*;
|
import static arc.Core.*;
|
||||||
|
|
||||||
public class KeybindDialog extends Dialog{
|
public class KeybindDialog extends Dialog{
|
||||||
protected Section section;
|
|
||||||
protected KeyBind rebindKey = null;
|
protected KeyBind rebindKey = null;
|
||||||
protected boolean rebindAxis = false;
|
protected boolean rebindAxis = false;
|
||||||
protected boolean rebindMin = true;
|
protected boolean rebindMin = true;
|
||||||
protected KeyCode minKey = null;
|
protected KeyCode minKey = null;
|
||||||
protected Dialog rebindDialog;
|
protected Dialog rebindDialog;
|
||||||
protected float scroll;
|
protected Table bindsTable;
|
||||||
protected ObjectIntMap<Section> sectionControls = new ObjectIntMap<>();
|
private String searchText = "";
|
||||||
|
|
||||||
public KeybindDialog(){
|
public KeybindDialog(){
|
||||||
super(bundle.get("keybind.title"));
|
super(bundle.get("keybind.title"));
|
||||||
setup();
|
|
||||||
addCloseButton();
|
addCloseButton();
|
||||||
setFillParent(true);
|
setFillParent(true);
|
||||||
title.setAlignment(Align.center);
|
title.setAlignment(Align.center);
|
||||||
titleTable.row();
|
titleTable.row();
|
||||||
titleTable.add(new Image()).growX().height(3f).pad(4f).get().setColor(Pal.accent);
|
titleTable.add(new Image()).growX().height(3f).pad(4f).get().setColor(Pal.accent);
|
||||||
|
bindsTable = new Table();
|
||||||
|
ScrollPane pane = new ScrollPane(bindsTable);
|
||||||
|
pane.setFadeScrollBars(false);
|
||||||
|
|
||||||
|
top();
|
||||||
|
|
||||||
|
cont.table(table -> {
|
||||||
|
table.left();
|
||||||
|
table.image(Icon.zoom);
|
||||||
|
var field = table.field(searchText, res -> {
|
||||||
|
searchText = res;
|
||||||
|
rebuildBinds();
|
||||||
|
}).growX().get();
|
||||||
|
|
||||||
|
shown(() -> {
|
||||||
|
field.setText(searchText = "");
|
||||||
|
rebuildBinds();
|
||||||
|
app.post(field::requestKeyboard);
|
||||||
|
});
|
||||||
|
}).fillX().padBottom(4).top();
|
||||||
|
|
||||||
|
cont.row();
|
||||||
|
cont.add(pane).grow();
|
||||||
|
|
||||||
|
rebuildBinds();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -45,187 +68,114 @@ public class KeybindDialog extends Dialog{
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setup(){
|
private void rebuildBinds(){
|
||||||
cont.clear();
|
|
||||||
|
|
||||||
Section[] sections = Core.keybinds.getSections();
|
Table table = bindsTable;
|
||||||
|
bindsTable.clear();
|
||||||
|
|
||||||
Stack stack = new Stack();
|
table.add().height(10);
|
||||||
ButtonGroup<TextButton> group = new ButtonGroup<>();
|
table.row();
|
||||||
ScrollPane pane = new ScrollPane(stack);
|
|
||||||
pane.setFadeScrollBars(false);
|
|
||||||
pane.update(() -> scroll = pane.getScrollY());
|
|
||||||
this.section = sections[0];
|
|
||||||
|
|
||||||
for(Section section : sections){
|
String lastCategory = null;
|
||||||
if(!sectionControls.containsKey(section))
|
var tstyle = Styles.grayt;
|
||||||
sectionControls.put(section, input.getDevices().indexOf(section.device, true));
|
|
||||||
|
|
||||||
if(sectionControls.get(section, 0) >= input.getDevices().size){
|
float bw = 140f, bh = 40f;
|
||||||
sectionControls.put(section, 0);
|
|
||||||
section.device = input.getDevices().get(0);
|
for(KeyBind keybind : KeyBind.all){
|
||||||
|
if(!searchText.isEmpty() && !bundle.get("keybind." + keybind.name + ".name", keybind.name).toLowerCase(Locale.ROOT).contains(searchText.toLowerCase(Locale.ROOT))){
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(sections.length != 1){
|
if(lastCategory != keybind.category && keybind.category != null){
|
||||||
TextButton button = new TextButton(bundle.get("section." + section.name + ".name", Strings.capitalize(section.name)));
|
table.add(bundle.get("category." + keybind.category + ".name", Strings.capitalize(keybind.category))).color(Color.gray).colspan(4).pad(10).padBottom(4).row();
|
||||||
if(section.equals(this.section))
|
table.image().color(Color.gray).fillX().height(3).pad(6).colspan(4).padTop(0).padBottom(10).row();
|
||||||
button.toggle();
|
lastCategory = keybind.category;
|
||||||
|
|
||||||
button.clicked(() -> this.section = section);
|
|
||||||
|
|
||||||
group.add(button);
|
|
||||||
cont.add(button).fill();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Table table = new Table();
|
if(keybind.defaultValue instanceof Axis){
|
||||||
|
table.add(bundle.get("keybind." + keybind.name + ".name", Strings.capitalize(keybind.name)), Color.white).left().padRight(40).padLeft(8);
|
||||||
|
|
||||||
Label device = new Label("Keyboard");
|
table.labelWrap(() -> {
|
||||||
//device.setColor(style.controllerColor);
|
Axis axis = keybind.value;
|
||||||
device.setAlignment(Align.center);
|
return axis.key != null ? axis.key.toString() : axis.min + " [red]/[] " + axis.max;
|
||||||
|
}).color(Pal.accent).left().minWidth(90).fillX().padRight(20);
|
||||||
|
|
||||||
Seq<InputDevice> devices = input.getDevices();
|
table.button("@settings.rebind", tstyle, () -> {
|
||||||
|
rebindAxis = true;
|
||||||
|
rebindMin = true;
|
||||||
|
openDialog(keybind);
|
||||||
|
}).size(bw, bh);
|
||||||
|
}else{
|
||||||
|
table.add(bundle.get("keybind." + keybind.name + ".name", Strings.capitalize(keybind.name)), Color.white).left().padRight(40).padLeft(8);
|
||||||
|
table.label(() -> keybind.value.key.toString()).color(Pal.accent).left().minWidth(90).padRight(20);
|
||||||
|
|
||||||
Table stable = new Table();
|
table.button("@settings.rebind", tstyle, () -> {
|
||||||
|
rebindAxis = false;
|
||||||
stable.button("<", () -> {
|
rebindMin = false;
|
||||||
int i = sectionControls.get(section, 0);
|
openDialog(keybind);
|
||||||
if(i - 1 >= 0){
|
}).size(bw, bh);
|
||||||
sectionControls.put(section, i - 1);
|
}
|
||||||
section.device = devices.get(i - 1);
|
table.button("@settings.resetKey", tstyle, keybind::resetToDefault).disabled(t -> keybind.isDefault()).size(bw, bh).pad(2f).padLeft(4f);
|
||||||
setup();
|
|
||||||
}
|
|
||||||
}).disabled(sectionControls.get(section, 0) - 1 < 0).size(40);
|
|
||||||
|
|
||||||
stable.add(device).minWidth(device.getMinWidth() + 60);
|
|
||||||
|
|
||||||
device.setText(input.getDevices().get(sectionControls.get(section, 0)).name());
|
|
||||||
|
|
||||||
stable.button(">", () -> {
|
|
||||||
int i = sectionControls.get(section, 0);
|
|
||||||
|
|
||||||
if(i + 1 < devices.size){
|
|
||||||
sectionControls.put(section, i + 1);
|
|
||||||
section.device = devices.get(i + 1);
|
|
||||||
setup();
|
|
||||||
}
|
|
||||||
}).disabled(sectionControls.get(section, 0) + 1 >= devices.size).size(40);
|
|
||||||
|
|
||||||
//no alternate devices until further notice
|
|
||||||
//table.add(stable).colspan(4).row();
|
|
||||||
|
|
||||||
table.add().height(10);
|
|
||||||
table.row();
|
table.row();
|
||||||
if(section.device.type() == DeviceType.controller){
|
|
||||||
table.table(info -> info.add("Controller Type: [lightGray]" +
|
|
||||||
Strings.capitalize(section.device.name())).left());
|
|
||||||
}
|
|
||||||
table.row();
|
|
||||||
|
|
||||||
String lastCategory = null;
|
|
||||||
var tstyle = Styles.defaultt;
|
|
||||||
|
|
||||||
for(KeyBind keybind : keybinds.getKeybinds()){
|
|
||||||
if(lastCategory != keybind.category() && keybind.category() != null){
|
|
||||||
table.add(bundle.get("category." + keybind.category() + ".name", Strings.capitalize(keybind.category()))).color(Color.gray).colspan(4).pad(10).padBottom(4).row();
|
|
||||||
table.image().color(Color.gray).fillX().height(3).pad(6).colspan(4).padTop(0).padBottom(10).row();
|
|
||||||
lastCategory = keybind.category();
|
|
||||||
}
|
|
||||||
|
|
||||||
if(keybind.defaultValue(section.device.type()) instanceof Axis){
|
|
||||||
table.add(bundle.get("keybind." + keybind.name() + ".name", Strings.capitalize(keybind.name())), Color.white).left().padRight(40).padLeft(8);
|
|
||||||
|
|
||||||
table.labelWrap(() -> {
|
|
||||||
Axis axis = keybinds.get(section, keybind);
|
|
||||||
return axis.key != null ? axis.key.toString() : axis.min + " [red]/[] " + axis.max;
|
|
||||||
}).color(Pal.accent).left().minWidth(90).fillX().padRight(20);
|
|
||||||
|
|
||||||
table.button("@settings.rebind", tstyle, () -> {
|
|
||||||
rebindAxis = true;
|
|
||||||
rebindMin = true;
|
|
||||||
openDialog(section, keybind);
|
|
||||||
}).width(130f);
|
|
||||||
}else{
|
|
||||||
table.add(bundle.get("keybind." + keybind.name() + ".name", Strings.capitalize(keybind.name())), Color.white).left().padRight(40).padLeft(8);
|
|
||||||
table.label(() -> keybinds.get(section, keybind).key.toString()).color(Pal.accent).left().minWidth(90).padRight(20);
|
|
||||||
|
|
||||||
table.button("@settings.rebind", tstyle, () -> {
|
|
||||||
rebindAxis = false;
|
|
||||||
rebindMin = false;
|
|
||||||
openDialog(section, keybind);
|
|
||||||
}).width(130f);
|
|
||||||
}
|
|
||||||
table.button("@settings.resetKey", tstyle, () -> keybinds.resetToDefault(section, keybind)).width(130f).pad(2f).padLeft(4f);
|
|
||||||
table.row();
|
|
||||||
}
|
|
||||||
|
|
||||||
table.visible(() -> this.section.equals(section));
|
|
||||||
|
|
||||||
table.button("@settings.reset", () -> keybinds.resetToDefaults()).colspan(4).padTop(4).fill();
|
|
||||||
|
|
||||||
stack.add(table);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cont.row();
|
table.button("@settings.reset", Icon.refresh, tstyle, KeyBind::resetAll).minWidth(200f).colspan(4).padTop(4).margin(10f).height(50f).fill();
|
||||||
cont.add(pane).growX().colspan(sections.length);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void rebind(Section section, KeyBind bind, KeyCode newKey){
|
void rebind(KeyBind bind, KeyCode newKey){
|
||||||
if(rebindKey == null) return;
|
if(rebindKey == null) return;
|
||||||
rebindDialog.hide();
|
rebindDialog.hide();
|
||||||
boolean isAxis = bind.defaultValue(section.device.type()) instanceof Axis;
|
boolean isAxis = bind.defaultValue instanceof Axis;
|
||||||
|
|
||||||
if(isAxis){
|
if(isAxis){
|
||||||
if(newKey.axis || !rebindMin){
|
if(newKey.axis || !rebindMin){
|
||||||
section.binds.get(section.device.type(), OrderedMap::new).put(rebindKey, newKey.axis ? new Axis(newKey) : new Axis(minKey, newKey));
|
bind.value = newKey.axis ? new Axis(newKey) : new Axis(minKey, newKey);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
section.binds.get(section.device.type(), OrderedMap::new).put(rebindKey, new Axis(newKey));
|
bind.value = new Axis(newKey);
|
||||||
}
|
}
|
||||||
|
bind.save();
|
||||||
|
|
||||||
if(rebindAxis && isAxis && rebindMin && !newKey.axis){
|
if(rebindAxis && isAxis && rebindMin && !newKey.axis){
|
||||||
rebindMin = false;
|
rebindMin = false;
|
||||||
minKey = newKey;
|
minKey = newKey;
|
||||||
openDialog(section, rebindKey);
|
openDialog(rebindKey);
|
||||||
}else{
|
}else{
|
||||||
rebindKey = null;
|
rebindKey = null;
|
||||||
rebindAxis = false;
|
rebindAxis = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void openDialog(Section section, KeyBind name){
|
private void openDialog( KeyBind name){
|
||||||
rebindDialog = new Dialog(rebindAxis ? bundle.get("keybind.press.axis") : bundle.get("keybind.press"));
|
rebindDialog = new Dialog(rebindAxis ? bundle.get("keybind.press.axis") : bundle.get("keybind.press"));
|
||||||
|
|
||||||
rebindKey = name;
|
rebindKey = name;
|
||||||
|
|
||||||
rebindDialog.titleTable.getCells().first().pad(4);
|
rebindDialog.titleTable.getCells().first().pad(4);
|
||||||
|
|
||||||
if(section.device.type() == DeviceType.keyboard){
|
rebindDialog.addListener(new InputListener(){
|
||||||
|
@Override
|
||||||
|
public boolean touchDown(InputEvent event, float x, float y, int pointer, KeyCode button){
|
||||||
|
if(Core.app.isAndroid()) return false;
|
||||||
|
rebind(name, button);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
rebindDialog.addListener(new InputListener(){
|
@Override
|
||||||
@Override
|
public boolean keyDown(InputEvent event, KeyCode keycode){
|
||||||
public boolean touchDown(InputEvent event, float x, float y, int pointer, KeyCode button){
|
rebindDialog.hide();
|
||||||
if(Core.app.isAndroid()) return false;
|
rebind(name, keycode);
|
||||||
rebind(section, name, button);
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean keyDown(InputEvent event, KeyCode keycode){
|
public boolean scrolled(InputEvent event, float x, float y, float amountX, float amountY){
|
||||||
rebindDialog.hide();
|
if(!rebindAxis) return false;
|
||||||
rebind(section, name, keycode);
|
rebindDialog.hide();
|
||||||
return false;
|
rebind(name, KeyCode.scroll);
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
@Override
|
});
|
||||||
public boolean scrolled(InputEvent event, float x, float y, float amountX, float amountY){
|
|
||||||
if(!rebindAxis) return false;
|
|
||||||
rebindDialog.hide();
|
|
||||||
rebind(section, name, KeyCode.scroll);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
rebindDialog.show();
|
rebindDialog.show();
|
||||||
Time.runTask(1f, () -> getScene().setScrollFocus(rebindDialog));
|
Time.runTask(1f, () -> getScene().setScrollFocus(rebindDialog));
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
|
|||||||
addListener(new InputListener(){
|
addListener(new InputListener(){
|
||||||
@Override
|
@Override
|
||||||
public boolean keyDown(InputEvent event, KeyCode key){
|
public boolean keyDown(InputEvent event, KeyCode key){
|
||||||
if(event.targetActor == PlanetDialog.this && (key == KeyCode.escape || key == KeyCode.back || key == Core.keybinds.get(Binding.planet_map).key)){
|
if(event.targetActor == PlanetDialog.this && (key == KeyCode.escape || key == KeyCode.back || key == Binding.planetMap.value.key)){
|
||||||
if(showing() && newPresets.size > 1){
|
if(showing() && newPresets.size > 1){
|
||||||
//clear all except first, which is the last sector.
|
//clear all except first, which is the last sector.
|
||||||
newPresets.truncate(1);
|
newPresets.truncate(1);
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ public class ResearchDialog extends BaseDialog{
|
|||||||
addCloseButton();
|
addCloseButton();
|
||||||
|
|
||||||
keyDown(key -> {
|
keyDown(key -> {
|
||||||
if(key == Core.keybinds.get(Binding.research).key){
|
if(key == Binding.research.value.key){
|
||||||
Core.app.post(this::hide);
|
Core.app.post(this::hide);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -65,19 +65,19 @@ public class ChatFragment extends Table{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(shown){
|
if(shown){
|
||||||
if(input.keyTap(Binding.chat_history_prev) && historyPos < history.size - 1){
|
if(input.keyTap(Binding.chatHistoryPrev) && historyPos < history.size - 1){
|
||||||
if(historyPos == 0) history.set(0, chatfield.getText());
|
if(historyPos == 0) history.set(0, chatfield.getText());
|
||||||
historyPos++;
|
historyPos++;
|
||||||
updateChat();
|
updateChat();
|
||||||
}
|
}
|
||||||
if(input.keyTap(Binding.chat_history_next) && historyPos > 0){
|
if(input.keyTap(Binding.chatHistoryNext) && historyPos > 0){
|
||||||
historyPos--;
|
historyPos--;
|
||||||
updateChat();
|
updateChat();
|
||||||
}
|
}
|
||||||
if(input.keyTap(Binding.chat_mode)){
|
if(input.keyTap(Binding.chatMode)){
|
||||||
nextMode();
|
nextMode();
|
||||||
}
|
}
|
||||||
scrollPos = (int)Mathf.clamp(scrollPos + input.axis(Binding.chat_scroll), 0, Math.max(0, messages.size - messagesShown));
|
scrollPos = (int)Mathf.clamp(scrollPos + input.axis(Binding.chatScroll), 0, Math.max(0, messages.size - messagesShown));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -62,18 +62,18 @@ public class ConsoleFragment extends Table{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(open){
|
if(open){
|
||||||
if(input.keyTap(Binding.chat_history_prev) && historyPos < history.size - 1){
|
if(input.keyTap(Binding.chatHistoryPrev) && historyPos < history.size - 1){
|
||||||
if(historyPos == 0) history.set(0, chatfield.getText());
|
if(historyPos == 0) history.set(0, chatfield.getText());
|
||||||
historyPos++;
|
historyPos++;
|
||||||
updateChat();
|
updateChat();
|
||||||
}
|
}
|
||||||
if(input.keyTap(Binding.chat_history_next) && historyPos > 0){
|
if(input.keyTap(Binding.chatHistoryNext) && historyPos > 0){
|
||||||
historyPos--;
|
historyPos--;
|
||||||
updateChat();
|
updateChat();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
scrollPos = (int)Mathf.clamp(scrollPos + input.axis(Binding.chat_scroll), 0, Math.max(0, messages.size));
|
scrollPos = (int)Mathf.clamp(scrollPos + input.axis(Binding.chatScroll), 0, Math.max(0, messages.size));
|
||||||
});
|
});
|
||||||
|
|
||||||
history.insert(0, "");
|
history.insert(0, "");
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ public class HintsFragment{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public enum DefaultHint implements Hint{
|
public enum DefaultHint implements Hint{
|
||||||
desktopMove(visibleDesktop, () -> Core.input.axis(Binding.move_x) != 0 || Core.input.axis(Binding.move_y) != 0),
|
desktopMove(visibleDesktop, () -> Core.input.axis(Binding.moveX) != 0 || Core.input.axis(Binding.moveY) != 0),
|
||||||
zoom(visibleDesktop, () -> Core.input.axis(KeyCode.scroll) != 0),
|
zoom(visibleDesktop, () -> Core.input.axis(KeyCode.scroll) != 0),
|
||||||
breaking(() -> isTutorial.get() && state.rules.defaultTeam.data().getCount(Blocks.conveyor) > 5, () -> ui.hints.events.contains("break")),
|
breaking(() -> isTutorial.get() && state.rules.defaultTeam.data().getCount(Blocks.conveyor) > 5, () -> ui.hints.events.contains("break")),
|
||||||
desktopShoot(visibleDesktop, () -> isSerpulo() && Vars.state.enemies > 0, () -> player.shooting),
|
desktopShoot(visibleDesktop, () -> isSerpulo() && Vars.state.enemies > 0, () -> player.shooting),
|
||||||
@@ -175,8 +175,8 @@ public class HintsFragment{
|
|||||||
() -> control.input.commandMode && control.input.selectedUnits.size > 0 && control.input.selectedUnits.first().controller() instanceof CommandAI ai && ai.targetPos != null),
|
() -> control.input.commandMode && control.input.selectedUnits.size > 0 && control.input.selectedUnits.first().controller() instanceof CommandAI ai && ai.targetPos != null),
|
||||||
respawn(visibleMobile, () -> !player.dead() && !player.unit().spawnedByCore, () -> !player.dead() && player.unit().spawnedByCore),
|
respawn(visibleMobile, () -> !player.dead() && !player.unit().spawnedByCore, () -> !player.dead() && player.unit().spawnedByCore),
|
||||||
launch(() -> (isTutorial.get() || Vars.state.rules.sector == SectorPresets.onset.sector) && state.rules.sector.isCaptured(), () -> ui.planet.isShown()),
|
launch(() -> (isTutorial.get() || Vars.state.rules.sector == SectorPresets.onset.sector) && state.rules.sector.isCaptured(), () -> ui.planet.isShown()),
|
||||||
schematicSelect(visibleDesktop, () -> ui.hints.placedBlocks.contains(Blocks.router) || ui.hints.placedBlocks.contains(Blocks.ductRouter), () -> Core.input.keyRelease(Binding.schematic_select) || Core.input.keyTap(Binding.pick)),
|
schematicSelect(visibleDesktop, () -> ui.hints.placedBlocks.contains(Blocks.router) || ui.hints.placedBlocks.contains(Blocks.ductRouter), () -> Core.input.keyRelease(Binding.schematicSelect) || Core.input.keyTap(Binding.pick)),
|
||||||
conveyorPathfind(() -> control.input.block == Blocks.titaniumConveyor, () -> Core.input.keyRelease(Binding.diagonal_placement) || (mobile && Core.settings.getBool("swapdiagonal"))),
|
conveyorPathfind(() -> control.input.block == Blocks.titaniumConveyor, () -> Core.input.keyRelease(Binding.diagonalPlacement) || (mobile && Core.settings.getBool("swapdiagonal"))),
|
||||||
boost(visibleDesktop, () -> !player.dead() && player.unit().type.canBoost, () -> Core.input.keyDown(Binding.boost)),
|
boost(visibleDesktop, () -> !player.dead() && player.unit().type.canBoost, () -> Core.input.keyDown(Binding.boost)),
|
||||||
blockInfo(() -> control.input.block == Blocks.graphitePress, () -> ui.content.isShown()),
|
blockInfo(() -> control.input.block == Blocks.graphitePress, () -> ui.content.isShown()),
|
||||||
derelict(() -> ui.hints.events.contains("derelictmouse") && !isTutorial.get(), () -> ui.hints.events.contains("derelictbreak")),
|
derelict(() -> ui.hints.events.contains("derelictmouse") && !isTutorial.get(), () -> ui.hints.events.contains("derelictbreak")),
|
||||||
|
|||||||
@@ -278,14 +278,14 @@ public class HudFragment{
|
|||||||
}
|
}
|
||||||
|
|
||||||
cont.update(() -> {
|
cont.update(() -> {
|
||||||
if(Core.input.keyTap(Binding.toggle_menus) && !ui.chatfrag.shown() && !Core.scene.hasDialog() && !Core.scene.hasField()){
|
if(Core.input.keyTap(Binding.toggleMenus) && !ui.chatfrag.shown() && !Core.scene.hasDialog() && !Core.scene.hasField()){
|
||||||
Core.settings.getBoolOnce("ui-hidden", () -> {
|
Core.settings.getBoolOnce("ui-hidden", () -> {
|
||||||
ui.announce(Core.bundle.format("showui", Core.keybinds.get(Binding.toggle_menus).key.toString(), 11));
|
ui.announce(Core.bundle.format("showui", Binding.toggleMenus.value.key.toString(), 11));
|
||||||
});
|
});
|
||||||
toggleMenus();
|
toggleMenus();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Core.input.keyTap(Binding.skip_wave) && canSkipWave()){
|
if(Core.input.keyTap(Binding.skipWave) && canSkipWave()){
|
||||||
if(net.client() && player.admin){
|
if(net.client() && player.admin){
|
||||||
Call.adminRequest(player, AdminAction.wave, null);
|
Call.adminRequest(player, AdminAction.wave, null);
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@@ -54,21 +54,21 @@ public class PlacementFragment{
|
|||||||
boolean blockSelectEnd, wasCommandMode;
|
boolean blockSelectEnd, wasCommandMode;
|
||||||
int blockSelectSeq;
|
int blockSelectSeq;
|
||||||
long blockSelectSeqMillis;
|
long blockSelectSeqMillis;
|
||||||
Binding[] blockSelect = {
|
KeyBind[] blockSelect = {
|
||||||
Binding.block_select_01,
|
Binding.blockSelect01,
|
||||||
Binding.block_select_02,
|
Binding.blockSelect02,
|
||||||
Binding.block_select_03,
|
Binding.blockSelect03,
|
||||||
Binding.block_select_04,
|
Binding.blockSelect04,
|
||||||
Binding.block_select_05,
|
Binding.blockSelect05,
|
||||||
Binding.block_select_06,
|
Binding.blockSelect06,
|
||||||
Binding.block_select_07,
|
Binding.blockSelect07,
|
||||||
Binding.block_select_08,
|
Binding.blockSelect08,
|
||||||
Binding.block_select_09,
|
Binding.blockSelect09,
|
||||||
Binding.block_select_10,
|
Binding.blockSelect10,
|
||||||
Binding.block_select_left,
|
Binding.blockSelectLeft,
|
||||||
Binding.block_select_right,
|
Binding.blockSelectRight,
|
||||||
Binding.block_select_up,
|
Binding.blockSelectUp,
|
||||||
Binding.block_select_down
|
Binding.blockSelectDown
|
||||||
};
|
};
|
||||||
|
|
||||||
public PlacementFragment(){
|
public PlacementFragment(){
|
||||||
@@ -230,7 +230,7 @@ public class PlacementFragment{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Core.input.keyTap(Binding.category_prev)){
|
if(Core.input.keyTap(Binding.categoryPrev)){
|
||||||
int i = 0;
|
int i = 0;
|
||||||
do{
|
do{
|
||||||
currentCategory = currentCategory.prev();
|
currentCategory = currentCategory.prev();
|
||||||
@@ -240,7 +240,7 @@ public class PlacementFragment{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Core.input.keyTap(Binding.category_next)){
|
if(Core.input.keyTap(Binding.categoryNext)){
|
||||||
int i = 0;
|
int i = 0;
|
||||||
do{
|
do{
|
||||||
currentCategory = currentCategory.next();
|
currentCategory = currentCategory.next();
|
||||||
@@ -250,7 +250,7 @@ public class PlacementFragment{
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Core.input.keyTap(Binding.block_info)){
|
if(Core.input.keyTap(Binding.blockInfo)){
|
||||||
var build = world.buildWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
|
var build = world.buildWorld(Core.input.mouseWorld().x, Core.input.mouseWorld().y);
|
||||||
Block hovering = build == null ? null : build instanceof ConstructBuild c ? c.current : build.block;
|
Block hovering = build == null ? null : build instanceof ConstructBuild c ? c.current : build.block;
|
||||||
Block displayBlock = menuHoverBlock != null ? menuHoverBlock : input.block != null ? input.block : hovering;
|
Block displayBlock = menuHoverBlock != null ? menuHoverBlock : input.block != null ? input.block : hovering;
|
||||||
@@ -363,9 +363,9 @@ public class PlacementFragment{
|
|||||||
Seq<Block> blocks = getByCategory(currentCategory);
|
Seq<Block> blocks = getByCategory(currentCategory);
|
||||||
for(int i = 0; i < blocks.size; i++){
|
for(int i = 0; i < blocks.size; i++){
|
||||||
if(blocks.get(i) == displayBlock && (i + 1) / 10 - 1 < blockSelect.length){
|
if(blocks.get(i) == displayBlock && (i + 1) / 10 - 1 < blockSelect.length){
|
||||||
keyCombo = Core.bundle.format("placement.blockselectkeys", Core.keybinds.get(blockSelect[currentCategory.ordinal()]).key.toString())
|
keyCombo = Core.bundle.format("placement.blockselectkeys", blockSelect[currentCategory.ordinal()].value.key.toString())
|
||||||
+ (i < 10 ? "" : Core.keybinds.get(blockSelect[(i + 1) / 10 - 1]).key.toString() + ",")
|
+ (i < 10 ? "" : blockSelect[(i + 1) / 10 - 1].value.key.toString() + ",")
|
||||||
+ Core.keybinds.get(blockSelect[i % 10]).key.toString() + "]";
|
+ blockSelect[i % 10].value.key.toString() + "]";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,4 +26,4 @@ org.gradle.caching=true
|
|||||||
org.gradle.internal.http.socketTimeout=100000
|
org.gradle.internal.http.socketTimeout=100000
|
||||||
org.gradle.internal.http.connectionTimeout=100000
|
org.gradle.internal.http.connectionTimeout=100000
|
||||||
android.enableR8.fullMode=false
|
android.enableR8.fullMode=false
|
||||||
archash=597a814beb
|
archash=fed4cd0caf
|
||||||
|
|||||||
@@ -1,39 +0,0 @@
|
|||||||
import mindustry.*;
|
|
||||||
import mindustry.world.*;
|
|
||||||
import mindustry.world.meta.*;
|
|
||||||
import org.junit.jupiter.api.*;
|
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
|
|
||||||
//grabs a betamindy release and makes sure it initializes correctly
|
|
||||||
//this mod was chosen because:
|
|
||||||
//- it is one of the top java mods on the browser
|
|
||||||
//- it uses a variety of mindustry classes
|
|
||||||
//- it is popular enough to cause significant amounts of crashes when something breaks
|
|
||||||
//- I have some familiarity with its codebase
|
|
||||||
public class ModTestBM extends GenericModTest{
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void begin(){
|
|
||||||
grabMod("https://github.com/sk7725/BetaMindy/releases/download/v1.11/BetaMindy.jar");
|
|
||||||
|
|
||||||
checkExistence("betamindy");
|
|
||||||
|
|
||||||
Block type = Vars.content.blocks().find(u -> u.name.equals("betamindy-piston"));
|
|
||||||
assertNotNull(type, "A mod block must be loaded.");
|
|
||||||
assertSame(type.buildVisibility, BuildVisibility.shown, "A mod block must be buildable.");
|
|
||||||
|
|
||||||
world.loadMap(maps.loadInternalMap("groundZero"));
|
|
||||||
Tile t = world.tile(3, 3);
|
|
||||||
|
|
||||||
t.setBlock(type);
|
|
||||||
|
|
||||||
//check for crash
|
|
||||||
t.build.update();
|
|
||||||
|
|
||||||
assertTrue(t.build.health > 0, "Block must be spawned and alive.");
|
|
||||||
assertSame(t.build.block, type, "Block must be spawned and alive.");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user