Command hotkeys

This commit is contained in:
Anuken 2023-09-23 11:03:15 -04:00
parent f2bb712860
commit 2286b54011
3 changed files with 30 additions and 1 deletions

View File

@ -50,6 +50,16 @@ public enum Binding implements KeyBind{
unit_stance_4(KeyCode.unset),
unit_stance_5(KeyCode.unset),
unit_command_1(KeyCode.unset),
unit_command_2(KeyCode.unset),
unit_command_3(KeyCode.unset),
unit_command_4(KeyCode.unset),
unit_command_5(KeyCode.unset),
unit_command_6(KeyCode.unset),
unit_command_7(KeyCode.unset),
unit_command_8(KeyCode.unset),
unit_command_9(KeyCode.unset),
category_prev(KeyCode.comma, "blocks"),
category_next(KeyCode.period),

View File

@ -509,7 +509,7 @@ public class PlanetDialog extends BaseDialog implements PlanetInterfaceRenderer{
sec.isAttacked() ? Fonts.getLargeIcon("warning") :
!sec.hasBase() && sec.preset != null && sec.preset.unlocked() && preficon == null ?
Fonts.getLargeIcon("terrain") :
sec.preset != null && sec.preset.locked() && sec.preset.techNode != null && !sec.preset.techNode.parent.content.locked() ? Fonts.getLargeIcon("lock") :
sec.preset != null && sec.preset.locked() && sec.preset.techNode != null && (sec.preset.techNode.parent == null || !sec.preset.techNode.parent.content.locked()) ? Fonts.getLargeIcon("lock") :
preficon;
var color = sec.preset != null && !sec.hasBase() ? Team.derelict.color : Team.sharded.color;

View File

@ -77,6 +77,18 @@ public class PlacementFragment{
Binding.unit_stance_5,
};
Binding[] commandBindings = {
Binding.unit_command_1,
Binding.unit_command_2,
Binding.unit_command_3,
Binding.unit_command_4,
Binding.unit_command_5,
Binding.unit_command_6,
Binding.unit_command_7,
Binding.unit_command_8,
Binding.unit_command_9,
};
public PlacementFragment(){
Events.on(WorldLoadEvent.class, event -> {
Core.app.post(() -> {
@ -601,6 +613,13 @@ public class PlacementFragment{
Call.setUnitStance(player, control.input.selectedUnits.mapInt(un -> un.id).toArray(), stances.get(i));
}
}
for(int i = 0; i < Math.min(commandBindings.length, commands.size); i++){
//first stance must always be the stop stance
if(Core.input.keyTap(commandBindings[i])){
Call.setUnitCommand(player, control.input.selectedUnits.mapInt(un -> un.id).toArray(), commands.get(i));
}
}
}
});
rebuildCommand.run();