mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Ctrl-click-deselect
This commit is contained in:
@@ -708,9 +708,30 @@ export class Unit extends CustomMarker {
|
||||
#onClick(e: any) {
|
||||
if (!this.#preventClick) {
|
||||
if (getMap().getState() === IDLE || getMap().getState() === MOVE_UNIT || e.originalEvent.ctrlKey) {
|
||||
if (!e.originalEvent.ctrlKey)
|
||||
|
||||
if (!e.originalEvent.ctrlKey) {
|
||||
getUnitsManager().deselectAllUnits();
|
||||
this.setSelected(!this.getSelected());
|
||||
}
|
||||
|
||||
const unitIsSelected = !this.getSelected();
|
||||
|
||||
this.setSelected( unitIsSelected );
|
||||
|
||||
|
||||
// Tell everyone a unit (de-)selection has happened, usually a panel or something.
|
||||
|
||||
const detail = {
|
||||
"detail": {
|
||||
"unit": this
|
||||
}
|
||||
};
|
||||
|
||||
if ( unitIsSelected ) {
|
||||
document.dispatchEvent( new CustomEvent( "unitSelected", detail ) );
|
||||
} else {
|
||||
document.dispatchEvent( new CustomEvent( "unitDeselected", detail ) );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -196,6 +196,16 @@ export class UnitsManager {
|
||||
}
|
||||
}
|
||||
|
||||
deselectUnit( ID:number ) {
|
||||
|
||||
if ( this.#units.hasOwnProperty( ID ) ) {
|
||||
this.#units[ID].setSelected(false);
|
||||
} else {
|
||||
console.error( `deselectUnit(): no unit found with ID "${ID}".` );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
selectUnitsByHotgroup(hotgroup: number) {
|
||||
this.deselectAllUnits();
|
||||
this.getUnitsByHotgroup(hotgroup).forEach((unit: Unit) => unit.setSelected(true))
|
||||
|
||||
Reference in New Issue
Block a user