Keybind tweaks

This commit is contained in:
Anuken
2023-09-21 10:40:44 -04:00
parent 36193c755f
commit 8598eedd6f
4 changed files with 39 additions and 21 deletions

View File

@ -1149,6 +1149,7 @@ keybind.title = Rebind Keys
keybinds.mobile = [scarlet]Most keybinds here are not functional on mobile. Only basic movement is supported.
category.general.name = General
category.view.name = View
category.command.name = Unit Command
category.multiplayer.name = Multiplayer
category.blocks.name = Block Select
placement.blockselectkeys = \n[lightgray]Key: [{0},
@ -1168,6 +1169,7 @@ keybind.boost.name = Boost
keybind.command_mode.name = Command Mode
keybind.command_queue.name = Queue Unit Command
keybind.create_control_group.name = Create Control Group
keybind.cancel_orders.name = Cancel Orders
keybind.rebuild_select.name = Rebuild Region
keybind.schematic_select.name = Select Region
keybind.schematic_menu.name = Schematic Menu

View File

@ -333,7 +333,7 @@ public class Teams{
}
for(var build : builds){
if(build.within(x, y, range)){
if(build.within(x, y, range) && !build.block.privileged){
scheduleDerelict(build);
}
}

View File

@ -12,18 +12,12 @@ public enum Binding implements KeyBind{
pan(KeyCode.mouseForward),
boost(KeyCode.shiftLeft),
command_mode(KeyCode.shiftLeft),
command_queue(KeyCode.mouseMiddle),
create_control_group(KeyCode.controlLeft),
control(KeyCode.controlLeft),
respawn(KeyCode.v),
control(KeyCode.controlLeft),
select(KeyCode.mouseLeft),
deselect(KeyCode.mouseRight),
break_block(KeyCode.mouseRight),
select_all_units(KeyCode.g),
select_all_unit_factories(KeyCode.h),
pickupCargo(KeyCode.leftBracket),
dropCargo(KeyCode.rightBracket),
@ -40,6 +34,22 @@ public enum Binding implements KeyBind{
schematic_flip_y(KeyCode.x),
schematic_menu(KeyCode.t),
command_mode(KeyCode.shiftLeft, "command"),
command_queue(KeyCode.mouseMiddle),
create_control_group(KeyCode.controlLeft),
select_all_units(KeyCode.g),
select_all_unit_factories(KeyCode.h),
cancel_orders(KeyCode.unset),
unit_stance_1(KeyCode.unset),
unit_stance_2(KeyCode.unset),
unit_stance_3(KeyCode.unset),
unit_stance_4(KeyCode.unset),
unit_stance_5(KeyCode.unset),
category_prev(KeyCode.comma, "blocks"),
category_next(KeyCode.period),

View File

@ -11,7 +11,6 @@ import arc.scene.ui.*;
import arc.scene.ui.layout.*;
import arc.struct.*;
import arc.util.*;
import mindustry.*;
import mindustry.ai.*;
import mindustry.content.*;
import mindustry.core.*;
@ -69,6 +68,15 @@ public class PlacementFragment{
Binding.block_select_down
};
Binding[] stanceBindings = {
Binding.cancel_orders,
Binding.unit_stance_1,
Binding.unit_stance_2,
Binding.unit_stance_3,
Binding.unit_stance_4,
Binding.unit_stance_5,
};
public PlacementFragment(){
Events.on(WorldLoadEvent.class, event -> {
Core.app.post(() -> {
@ -513,12 +521,7 @@ public class PlacementFragment{
int scol = 0;
for(var command : commands){
coms.button(Icon.icons.get(command.icon, Icon.cancel), Styles.clearNoneTogglei, () -> {
IntSeq ids = new IntSeq();
for(var unit : units){
ids.add(unit.id);
}
Call.setUnitCommand(Vars.player, ids.toArray(), command);
Call.setUnitCommand(player, units.mapInt(un -> un.id).toArray(), command);
}).checked(i -> currentCommand[0] == command).size(50f).tooltip(command.localized());
if(++scol % 6 == 0) coms.row();
@ -537,12 +540,7 @@ public class PlacementFragment{
for(var stance : stances){
coms.button(Icon.icons.get(stance.icon, Icon.cancel), Styles.clearNoneTogglei, () -> {
IntSeq ids = new IntSeq();
for(var unit : units){
ids.add(unit.id);
}
Call.setUnitStance(Vars.player, ids.toArray(), stance);
Call.setUnitStance(player, units.mapInt(un -> un.id).toArray(), stance);
}).checked(i -> currentStance[0] == stance).size(50f).tooltip(stance.localized());
if(++scol % 6 == 0) coms.row();
@ -595,6 +593,14 @@ public class PlacementFragment{
curCount[0] = size;
rebuildCommand.run();
}
//not a huge fan of running input logic here, but it's convenient as the stance arrays are all here...
for(int i = 0; i < Math.min(stanceBindings.length, stances.size); i++){
//first stance must always be the stop stance
if(Core.input.keyTap(stanceBindings[i]) && (i != 0 || stances.get(0) == UnitStance.stopStance)){
Call.setUnitStance(player, control.input.selectedUnits.mapInt(un -> un.id).toArray(), stances.get(i));
}
}
}
});
rebuildCommand.run();