Added additive hotgroup select

This commit is contained in:
PeekabooSteam
2023-10-01 20:12:36 +01:00
parent 4d694f1f74
commit 5a28974027
2 changed files with 9 additions and 2 deletions

View File

@@ -278,11 +278,14 @@ export class OlympusApp {
digits.forEach(code => {
shortcutManager.addKeyboardShortcut(`hotgroup${code}`, {
"altKey": false,
"callback": (ev: KeyboardEvent) => {
if (ev.ctrlKey && ev.shiftKey)
this.getUnitsManager().selectedUnitsAddToHotgroup(parseInt(ev.code.substring(5)));
else if (ev.ctrlKey && !ev.shiftKey)
this.getUnitsManager().selectedUnitsSetHotgroup(parseInt(ev.code.substring(5)));
else if (!ev.ctrlKey && ev.shiftKey)
this.getUnitsManager().selectUnitsByHotgroup(parseInt(ev.code.substring(5)), false);
else
this.getUnitsManager().selectUnitsByHotgroup(parseInt(ev.code.substring(5)));
},

View File

@@ -201,8 +201,12 @@ export class UnitsManager {
*
* @param hotgroup The hotgroup number
*/
selectUnitsByHotgroup(hotgroup: number) {
this.deselectAllUnits();
selectUnitsByHotgroup(hotgroup: number, deselectAllUnits: boolean = true ) {
if ( deselectAllUnits ) {
this.deselectAllUnits();
}
this.getUnitsByHotgroup(hotgroup).forEach((unit: Unit) => unit.setSelected(true))
}