mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
ROE and reaction to threat buttons are now updated to reflect the state of the selected units
This commit is contained in:
parent
e8a476e1c7
commit
79d8ca260a
@ -11,7 +11,7 @@ const DEMO_UNIT_DATA = {
|
||||
},
|
||||
flightData: {
|
||||
latitude: 37.20,
|
||||
longitude: -115.8,
|
||||
longitude: -115.80,
|
||||
altitude: 2000,
|
||||
heading: 0.5,
|
||||
speed: 300
|
||||
@ -52,8 +52,8 @@ const DEMO_UNIT_DATA = {
|
||||
targetAltitude: 3000
|
||||
},
|
||||
optionsData: {
|
||||
ROE: "None",
|
||||
reactionToThreat: "None",
|
||||
ROE: "Designated",
|
||||
reactionToThreat: "Abort",
|
||||
}
|
||||
},
|
||||
["2"]:{
|
||||
@ -95,8 +95,8 @@ const DEMO_UNIT_DATA = {
|
||||
targetAltitude: 3000
|
||||
},
|
||||
optionsData: {
|
||||
ROE: "None",
|
||||
reactionToThreat: "None",
|
||||
ROE: "Designated",
|
||||
reactionToThreat: "Abort",
|
||||
}
|
||||
},
|
||||
["3"]:{
|
||||
|
||||
@ -3,6 +3,7 @@ import { Slider } from "../controls/slider";
|
||||
import { aircraftDatabase } from "../units/aircraftdatabase";
|
||||
import { groundUnitsDatabase } from "../units/groundunitsdatabase";
|
||||
import { Aircraft, GroundUnit, Unit } from "../units/unit";
|
||||
import { UnitsManager } from "../units/unitsmanager";
|
||||
import { Panel } from "./panel";
|
||||
|
||||
const ROEs: string[] = ["Free", "Designated free", "Designated", "Return", "Hold"];
|
||||
@ -28,42 +29,31 @@ export class UnitControlPanel extends Panel {
|
||||
this.#optionButtons["ROE"] = ROEs.map((option: string, index:number) => {
|
||||
var button = document.createElement("button");
|
||||
button.title = option;
|
||||
if ( index === 0 ) {
|
||||
button.classList.add( "selected" );
|
||||
}
|
||||
button.addEventListener("click", () => {
|
||||
this.getElement().querySelector("#roe-buttons-container button.selected")?.classList.remove( "selected" );
|
||||
button.classList.add( "selected" );
|
||||
getUnitsManager().selectedUnitsSetROE(button.title);
|
||||
});
|
||||
button.value = option;
|
||||
button.addEventListener("click", () => {getUnitsManager().selectedUnitsSetROE(button.title);});
|
||||
return button;
|
||||
});
|
||||
|
||||
this.#optionButtons["reactionToThreat"] = reactionsToThreat.map((option: string, index:number) => {
|
||||
var button = document.createElement("button");
|
||||
button.title = option;
|
||||
if ( index === 0 ) {
|
||||
button.classList.add( "selected" );
|
||||
}
|
||||
button.addEventListener("click", () => {
|
||||
this.getElement().querySelector("#reaction-to-threat-buttons-container button.selected")?.classList.remove( "selected" );
|
||||
button.classList.add( "selected" );
|
||||
|
||||
getUnitsManager().selectedUnitsSetROE(button.title);
|
||||
});
|
||||
button.value = option;
|
||||
button.addEventListener("click", () => {getUnitsManager().selectedUnitsSetROE(button.title);});
|
||||
return button;
|
||||
});
|
||||
|
||||
this.getElement().querySelector("#roe-buttons-container")?.append(...this.#optionButtons["ROE"]);
|
||||
this.getElement().querySelector("#reaction-to-threat-buttons-container")?.append(...this.#optionButtons["reactionToThreat"]);
|
||||
|
||||
document.addEventListener("unitsSelection", (e: CustomEvent<Unit[]>) => {this.show(); this.update(e.detail)});
|
||||
document.addEventListener("unitUpdated", (e: CustomEvent<Unit>) => {if (e.detail.getSelected()) this.update()});
|
||||
document.addEventListener("unitsSelection", (e: CustomEvent<Unit[]>) => {this.show(); this.update()});
|
||||
document.addEventListener("clearSelection", () => {this.hide()});
|
||||
|
||||
this.hide();
|
||||
}
|
||||
|
||||
update(units: Unit[]) {
|
||||
update() {
|
||||
var units = getUnitsManager().getSelectedUnits();
|
||||
if (this.getElement() != null && units.length > 0)
|
||||
{
|
||||
this.#showFlightControlSliders(units);
|
||||
@ -87,11 +77,11 @@ export class UnitControlPanel extends Panel {
|
||||
}));
|
||||
|
||||
this.#optionButtons["ROE"].forEach((button: HTMLButtonElement) => {
|
||||
button.classList.toggle("active", units.every((unit: Unit) => unit.getOptionsData().ROE === button.value))
|
||||
button.classList.toggle("selected", units.every((unit: Unit) => unit.getOptionsData().ROE === button.value))
|
||||
});
|
||||
|
||||
this.#optionButtons["reactionToThreat"].forEach((button: HTMLButtonElement) => {
|
||||
button.classList.toggle("active", units.every((unit: Unit) => unit.getOptionsData().reactionToThreat === button.value))
|
||||
button.classList.toggle("selected", units.every((unit: Unit) => unit.getOptionsData().reactionToThreat === button.value))
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user