diff --git a/client/demo.js b/client/demo.js index ac74f3c9..44c2c08d 100644 --- a/client/demo.js +++ b/client/demo.js @@ -4,7 +4,7 @@ var enc = new TextEncoder(); const DEMO_UNIT_DATA = { ["1"]:{ category: "Aircraft", alive: true, human: false, controlled: true, coalition: 2, country: 0, name: "KC-135", unitName: "Cool guy 1-1 who also has a very long name", groupName: "Cool group 1", state: 1, task: "Being cool!", - hasTask: true, position: { lat: 37, lng: -116, alt: 1000 }, speed: 200, heading: 45, isTanker: true, isAWACS: false, onOff: true, followRoads: false, fuel: 50, + hasTask: true, position: { lat: 37, lng: -116, alt: 1000 }, speed: 200, heading: 45, isActiveTanker: true, isActiveAWACS: false, onOff: true, followRoads: false, fuel: 50, desiredSpeed: 300, desiredSpeedType: 1, desiredAltitude: 1000, desiredAltitudeType: 1, leaderID: 0, formationOffset: { x: 0, y: 0, z: 0 }, targetID: 0, @@ -20,7 +20,7 @@ const DEMO_UNIT_DATA = { activePath: [{lat: 38, lng: -115, alt: 0}, {lat: 38, lng: -114, alt: 0}] }, ["2"]:{ category: "Aircraft", alive: true, human: false, controlled: true, coalition: 1, country: 0, name: "E-3A", unitName: "Cool guy 1-2", groupName: "Cool group 2", state: 1, task: "Being cool", - hasTask: true, position: { lat: 36.9, lng: -116, alt: 1000 }, speed: 200, heading: 315 * Math.PI / 180, isTanker: false, isAWACS: true, onOff: true, followRoads: false, fuel: 50, + hasTask: true, position: { lat: 36.9, lng: -116, alt: 1000 }, speed: 200, heading: 315 * Math.PI / 180, isActiveTanker: false, isActiveAWACS: true, onOff: true, followRoads: false, fuel: 50, desiredSpeed: 300, desiredSpeedType: 1, desiredAltitude: 1000, desiredAltitudeType: 1, leaderID: 0, formationOffset: { x: 0, y: 0, z: 0 }, targetID: 0, @@ -35,7 +35,7 @@ const DEMO_UNIT_DATA = { contacts: [{ID: 4, detectionMethod: 1}], activePath: [ ] }, ["3"]:{ category: "Helicopter", alive: true, human: false, controlled: false, coalition: 1, country: 0, name: "AH-64D_BLK_II", unitName: "Cool guy 1-4", groupName: "Cool group 3", state: 1, task: "Being cool", - hasTask: false, position: { lat: 37.1, lng: -116.1, alt: 1000 }, speed: 200, heading: 315 * Math.PI / 180, isTanker: false, isAWACS: false, onOff: true, followRoads: false, fuel: 50, + hasTask: false, position: { lat: 37.1, lng: -116.1, alt: 1000 }, speed: 200, heading: 315 * Math.PI / 180, isActiveTanker: false, isActiveAWACS: false, onOff: true, followRoads: false, fuel: 50, desiredSpeed: 300, desiredSpeedType: 1, desiredAltitude: 1000, desiredAltitudeType: 1, leaderID: 0, formationOffset: { x: 0, y: 0, z: 0 }, targetID: 0, @@ -50,7 +50,7 @@ const DEMO_UNIT_DATA = { contacts: [{ID: 1, detectionMethod: 16}], activePath: [ ] }, ["4"]:{ category: "GroundUnit", alive: true, human: false, controlled: true, coalition: 2, country: 0, name: "Tor 9A331", unitName: "Cool guy 2-1", groupName: "Cool group 4", state: 1, task: "Being cool", - hasTask: false, position: { lat: 37.2, lng: -116.1, alt: 1000 }, speed: 200, heading: 315 * Math.PI / 180, isTanker: false, isAWACS: false, onOff: false, followRoads: false, fuel: 50, + hasTask: false, position: { lat: 37.2, lng: -116.1, alt: 1000 }, speed: 200, heading: 315 * Math.PI / 180, isActiveTanker: false, isActiveAWACS: false, onOff: false, followRoads: false, fuel: 50, desiredSpeed: 300, desiredSpeedType: 1, desiredAltitude: 1000, desiredAltitudeType: 1, leaderID: 0, formationOffset: { x: 0, y: 0, z: 0 }, targetID: 0, @@ -67,7 +67,7 @@ const DEMO_UNIT_DATA = { isLeader: true, operateAs: 2 }, ["5"]:{ category: "GroundUnit", alive: true, human: false, controlled: true, coalition: 2, country: 0, name: "Gepard", unitName: "Cool guy 2-2", groupName: "Cool group 4", state: 1, task: "Being cool", - hasTask: false, position: { lat: 37.21, lng: -116.1, alt: 1000 }, speed: 200, heading: 315 * Math.PI / 180, isTanker: false, isAWACS: false, onOff: false, followRoads: false, fuel: 50, + hasTask: false, position: { lat: 37.21, lng: -116.1, alt: 1000 }, speed: 200, heading: 315 * Math.PI / 180, isActiveTanker: false, isActiveAWACS: false, onOff: false, followRoads: false, fuel: 50, desiredSpeed: 300, desiredSpeedType: 1, desiredAltitude: 1000, desiredAltitudeType: 1, leaderID: 0, formationOffset: { x: 0, y: 0, z: 0 }, targetID: 0, @@ -85,7 +85,7 @@ const DEMO_UNIT_DATA = { operateAs: 2 }, ["6"]:{ category: "Aircraft", alive: true, human: false, controlled: false, coalition: 1, country: 0, name: "FA-18C_hornet", unitName: "Bad boi 1-2", groupName: "Bad group 1", state: 1, task: "Being bad", - hasTask: false, position: { lat: 36.8, lng: -116, alt: 1000 }, speed: 200, heading: 315 * Math.PI / 180, isTanker: false, isAWACS: false, onOff: true, followRoads: false, fuel: 50, + hasTask: false, position: { lat: 36.8, lng: -116, alt: 1000 }, speed: 200, heading: 315 * Math.PI / 180, isActiveTanker: false, isActiveAWACS: false, onOff: true, followRoads: false, fuel: 50, desiredSpeed: 300, desiredSpeedType: 1, desiredAltitude: 1000, desiredAltitudeType: 1, leaderID: 0, formationOffset: { x: 0, y: 0, z: 0 }, targetID: 0, @@ -100,7 +100,7 @@ const DEMO_UNIT_DATA = { contacts: [{ID: 1, detectionMethod: 16}], activePath: [ ] }, ["7"]:{ category: "GroundUnit", alive: true, human: false, controlled: true, coalition: 1, country: 0, name: "Tor 9A331", unitName: "Cool guy 2-1", groupName: "Cool group 10", state: 1, task: "Being cool", - hasTask: false, position: { lat: 37.2, lng: -116.2, alt: 1000 }, speed: 200, heading: 315 * Math.PI / 180, isTanker: false, isAWACS: false, onOff: true, followRoads: false, fuel: 50, + hasTask: false, position: { lat: 37.2, lng: -116.2, alt: 1000 }, speed: 200, heading: 315 * Math.PI / 180, isActiveTanker: false, isActiveAWACS: false, onOff: true, followRoads: false, fuel: 50, desiredSpeed: 300, desiredSpeedType: 1, desiredAltitude: 1000, desiredAltitudeType: 1, leaderID: 0, formationOffset: { x: 0, y: 0, z: 0 }, targetID: 0, @@ -144,7 +144,7 @@ class DemoDataGenerator { //for (let i = 8; i < 100; i++) { // var randomUnit = { category: "Aircraft", alive: true, human: false, controlled: true, coalition: 2, country: 0, name: "KC-135", unitName: "Cool guy 1-1 who also has a very long name", groupName: "Cool group 1", state: 1, task: "Being cool!", - // hasTask: true, position: { lat: 37 + Math.random(), lng: -116 + Math.random(), alt: 1000 }, speed: 200, heading: 45, isTanker: true, isAWACS: false, onOff: true, followRoads: false, fuel: 50, + // hasTask: true, position: { lat: 37 + Math.random(), lng: -116 + Math.random(), alt: 1000 }, speed: 200, heading: 45, isActiveTanker: true, isActiveAWACS: false, onOff: true, followRoads: false, fuel: 50, // desiredSpeed: 300, desiredSpeedType: 1, desiredAltitude: 1000, desiredAltitudeType: 1, leaderID: 0, // formationOffset: { x: 0, y: 0, z: 0 }, // targetID: 0, @@ -188,8 +188,8 @@ class DemoDataGenerator { array = this.appendCoordinates(array, unit.position, 13); array = this.appendDouble(array, unit.speed, 14); array = this.appendDouble(array, unit.heading, 15); - array = this.appendUint8(array, unit.isTanker, 16); - array = this.appendUint8(array, unit.isAWACS, 17); + array = this.appendUint8(array, unit.isActiveTanker, 16); + array = this.appendUint8(array, unit.isActiveAWACS, 17); array = this.appendUint8(array, unit.onOff, 18); array = this.appendUint8(array, unit.followRoads, 19); array = this.appendUint16(array, unit.fuel, 20); diff --git a/client/public/stylesheets/panels/unitcontrol.css b/client/public/stylesheets/panels/unitcontrol.css index 0d0496a2..c583dca4 100644 --- a/client/public/stylesheets/panels/unitcontrol.css +++ b/client/public/stylesheets/panels/unitcontrol.css @@ -247,8 +247,6 @@ body.feature-forceShowUnitControlPanel #unit-control-panel { #unit-control-panel:not([data-show-advanced-settings-button]) #advanced-settings-button, #advanced-settings-dialog:not([data-show-settings]) #general-settings, #advanced-settings-dialog:not([data-show-tasking]) #tasking, -/*#advanced-settings-dialog:not([data-show-tanker]) #tanker-checkbox, -#advanced-settings-dialog:not([data-show-AWACS]) #AWACS-checkbox,*/ #advanced-settings-dialog:not([data-show-TACAN]) #TACAN-options, #advanced-settings-dialog:not([data-show-radio]) #radio-options, #advanced-settings-dialog:not([data-show-air-unit-checkboxes]) .air-unit-checkbox { diff --git a/client/src/constants/constants.ts b/client/src/constants/constants.ts index bd5b5532..85c3c677 100644 --- a/client/src/constants/constants.ts +++ b/client/src/constants/constants.ts @@ -178,8 +178,8 @@ export enum DataIndexes { position, speed, heading, - isTanker, - isAWACS, + isActiveTanker, + isActiveAWACS, onOff, followRoads, fuel, diff --git a/client/src/interfaces.ts b/client/src/interfaces.ts index d520866f..c5d45f36 100644 --- a/client/src/interfaces.ts +++ b/client/src/interfaces.ts @@ -153,8 +153,8 @@ export interface UnitData { position: LatLng; speed: number; heading: number; - isTanker: boolean; - isAWACS: boolean; + isActiveTanker: boolean; + isActiveAWACS: boolean; onOff: boolean; followRoads: boolean; fuel: number; diff --git a/client/src/panels/unitcontrolpanel.ts b/client/src/panels/unitcontrolpanel.ts index 9c7bf15a..c590c652 100644 --- a/client/src/panels/unitcontrolpanel.ts +++ b/client/src/panels/unitcontrolpanel.ts @@ -65,7 +65,7 @@ export class UnitControlPanel extends Panel { // TODO: split setAdvancedOptions into setIsTanker, setIsAWACS, setAdvancedOptions var selectedUnits = getApp().getUnitsManager().getSelectedUnits(); selectedUnits.forEach((unit: Unit) => { - unit.setAdvancedOptions(value, unit.getIsAWACS(), unit.getTACAN(), unit.getRadio(), unit.getGeneralSettings()); + unit.setAdvancedOptions(value, unit.getIsActiveAWACS(), unit.getTACAN(), unit.getRadio(), unit.getGeneralSettings()); }); }); @@ -74,7 +74,7 @@ export class UnitControlPanel extends Panel { // TODO: split setAdvancedOptions into setIsTanker, setIsAWACS, setAdvancedOptions var selectedUnits = getApp().getUnitsManager().getSelectedUnits(); selectedUnits.forEach((unit: Unit) => { - unit.setAdvancedOptions(unit.getIsTanker(), value, unit.getTACAN(), unit.getRadio(), unit.getGeneralSettings()); + unit.setAdvancedOptions(unit.getIsActiveTanker(), value, unit.getTACAN(), unit.getRadio(), unit.getGeneralSettings()); }); }); @@ -184,28 +184,28 @@ export class UnitControlPanel extends Panel { const element = this.getElement(); if (element != null && this.#units.length > 0) { /* Toggle visibility of control elements */ - var tanker = getApp().getUnitsManager().getSelectedUnitsVariable((unit: Unit) => {return unit.canFulfillRole("Tanker")}); - var AWACS = getApp().getUnitsManager().getSelectedUnitsVariable((unit: Unit) => {return unit.canFulfillRole("AWACS")}); - var isTanker = getApp().getUnitsManager().getSelectedUnitsVariable((unit: Unit) => {return unit.getIsTanker()}); - var isAWACS = getApp().getUnitsManager().getSelectedUnitsVariable((unit: Unit) => {return unit.getIsAWACS()}); + var isTanker = getApp().getUnitsManager().getSelectedUnitsVariable((unit: Unit) => {return unit.isTanker();}); + var isAWACS = getApp().getUnitsManager().getSelectedUnitsVariable((unit: Unit) => {return unit.isAWACS();}); + var isActiveTanker = getApp().getUnitsManager().getSelectedUnitsVariable((unit: Unit) => {return unit.getIsActiveTanker()}); + var isActiveAWACAS = getApp().getUnitsManager().getSelectedUnitsVariable((unit: Unit) => {return unit.getIsActiveAWACS()}); element.toggleAttribute("data-show-categories-tooltip", this.#selectedUnitsTypes.length > 1); element.toggleAttribute("data-show-speed-slider", this.#selectedUnitsTypes.length == 1); element.toggleAttribute("data-show-altitude-slider", this.#selectedUnitsTypes.length == 1 && (this.#selectedUnitsTypes.includes("Aircraft") || this.#selectedUnitsTypes.includes("Helicopter"))); - element.toggleAttribute("data-show-roe", !tanker && !AWACS); + element.toggleAttribute("data-show-roe", !isTanker && !isAWACS); element.toggleAttribute("data-show-threat", (this.#selectedUnitsTypes.includes("Aircraft") || this.#selectedUnitsTypes.includes("Helicopter")) && !(this.#selectedUnitsTypes.includes("GroundUnit") || this.#selectedUnitsTypes.includes("NavyUnit"))); element.toggleAttribute("data-show-emissions-countermeasures", (this.#selectedUnitsTypes.includes("Aircraft") || this.#selectedUnitsTypes.includes("Helicopter")) && !(this.#selectedUnitsTypes.includes("GroundUnit") || this.#selectedUnitsTypes.includes("NavyUnit"))); - element.toggleAttribute("data-show-tanker-button", getApp().getUnitsManager().getSelectedUnitsVariable((unit: Unit) => {return unit.canFulfillRole("Tanker")}) === true); - element.toggleAttribute("data-show-AWACS-button", getApp().getUnitsManager().getSelectedUnitsVariable((unit: Unit) => {return unit.canFulfillRole("AWACS")}) === true); + element.toggleAttribute("data-show-tanker-button", getApp().getUnitsManager().getSelectedUnitsVariable((unit: Unit) => {return unit.isTanker();}) === true); + element.toggleAttribute("data-show-AWACS-button", getApp().getUnitsManager().getSelectedUnitsVariable((unit: Unit) => {return unit.isAWACS();}) === true); element.toggleAttribute("data-show-on-off", (this.#selectedUnitsTypes.includes("GroundUnit") || this.#selectedUnitsTypes.includes("NavyUnit")) && !(this.#selectedUnitsTypes.includes("Aircraft") || this.#selectedUnitsTypes.includes("Helicopter"))); element.toggleAttribute("data-show-follow-roads", (this.#selectedUnitsTypes.length == 1 && this.#selectedUnitsTypes.includes("GroundUnit"))); element.toggleAttribute("data-show-operate-as", getApp().getUnitsManager().getSelectedUnitsVariable((unit: Unit) => {return unit.getCoalition()}) === "neutral"); if (this.#units.length == 1) { - if (AWACS) - element.toggleAttribute("data-show-advanced-settings-button", isAWACS); - else if (tanker) - element.toggleAttribute("data-show-advanced-settings-button", isTanker); + if (isAWACS) + element.toggleAttribute("data-show-advanced-settings-button", isActiveAWACAS); + else if (isTanker) + element.toggleAttribute("data-show-advanced-settings-button", isActiveTanker); else element.toggleAttribute("data-show-advanced-settings-button", true); } @@ -216,8 +216,8 @@ export class UnitControlPanel extends Panel { var desiredAltitudeType = getApp().getUnitsManager().getSelectedUnitsVariable((unit: Unit) => {return unit.getDesiredAltitudeType()}); var desiredSpeed = getApp().getUnitsManager().getSelectedUnitsVariable((unit: Unit) => {return unit.getDesiredSpeed()}); var desiredSpeedType = getApp().getUnitsManager().getSelectedUnitsVariable((unit: Unit) => {return unit.getDesiredSpeedType()}); - var isTanker = getApp().getUnitsManager().getSelectedUnitsVariable((unit: Unit) => {return unit.getIsTanker()}); - var isAWACS = getApp().getUnitsManager().getSelectedUnitsVariable((unit: Unit) => {return unit.getIsAWACS()}); + var isActiveTanker = getApp().getUnitsManager().getSelectedUnitsVariable((unit: Unit) => {return unit.getIsActiveTanker()}); + var isActiveAWACAS = getApp().getUnitsManager().getSelectedUnitsVariable((unit: Unit) => {return unit.getIsActiveAWACS()}); var onOff = getApp().getUnitsManager().getSelectedUnitsVariable((unit: Unit) => {return unit.getOnOff()}); var followRoads = getApp().getUnitsManager().getSelectedUnitsVariable((unit: Unit) => {return unit.getFollowRoads()}); var operateAs = getApp().getUnitsManager().getSelectedUnitsVariable((unit: Unit) => {return unit.getOperateAs()}); @@ -256,8 +256,8 @@ export class UnitControlPanel extends Panel { button.classList.toggle("selected", this.#units.every((unit: Unit) => unit.getEmissionsCountermeasures() === button.value)) }); - this.#tankerSwitch.setValue(isTanker, false); - this.#AWACSSwitch.setValue(isAWACS, false); + this.#tankerSwitch.setValue(isActiveTanker, false); + this.#AWACSSwitch.setValue(isActiveAWACAS, false); this.#onOffSwitch.setValue(onOff, false); this.#followRoadsSwitch.setValue(followRoads, false); this.#operateAsSwitch.setValue(operateAs? operateAs === "blue": undefined, false); @@ -329,8 +329,6 @@ export class UnitControlPanel extends Panel { const prohibitAACheckbox = this.#advancedSettingsDialog.querySelector("#prohibit-AA-checkbox")?.querySelector("input") as HTMLInputElement; const prohibitAGCheckbox = this.#advancedSettingsDialog.querySelector("#prohibit-AG-checkbox")?.querySelector("input") as HTMLInputElement; const prohibitAirWpnCheckbox = this.#advancedSettingsDialog.querySelector("#prohibit-air-wpn-checkbox")?.querySelector("input") as HTMLInputElement; - //const tankerCheckbox = this.#advancedSettingsDialog.querySelector("#tanker-checkbox")?.querySelector("input") as HTMLInputElement; - //const AWACSCheckbox = this.#advancedSettingsDialog.querySelector("#AWACS-checkbox")?.querySelector("input") as HTMLInputElement; const TACANCheckbox = this.#advancedSettingsDialog.querySelector("#TACAN-checkbox")?.querySelector("input") as HTMLInputElement; const TACANChannelInput = this.#advancedSettingsDialog.querySelector("#TACAN-channel")?.querySelector("input") as HTMLInputElement; const TACANCallsignInput = this.#advancedSettingsDialog.querySelector("#tacan-callsign")?.querySelector("input") as HTMLInputElement; @@ -338,19 +336,19 @@ export class UnitControlPanel extends Panel { const radioCallsignNumberInput = this.#advancedSettingsDialog.querySelector("#radio-callsign-number")?.querySelector("input") as HTMLInputElement; const unit = units[0]; - const tanker = unit.canFulfillRole("Tanker"); - const AWACS = unit.canFulfillRole("AWACS"); + const isTanker = unit.isTanker(); + const isAWACS = unit.isAWACS(); const radioMHz = Math.floor(unit.getRadio().frequency / 1000000); const radioDecimals = (unit.getRadio().frequency / 1000000 - radioMHz) * 1000; /* Activate the correct options depending on unit type */ - this.#advancedSettingsDialog.toggleAttribute("data-show-settings", !tanker && !AWACS); + this.#advancedSettingsDialog.toggleAttribute("data-show-settings", !isTanker && !isAWACS); this.#advancedSettingsDialog.toggleAttribute("data-show-air-unit-checkboxes", ["Aircraft", "Helicopter"].includes(units[0].getCategory())); - this.#advancedSettingsDialog.toggleAttribute("data-show-tasking", tanker || AWACS); - this.#advancedSettingsDialog.toggleAttribute("data-show-tanker", tanker); - this.#advancedSettingsDialog.toggleAttribute("data-show-AWACS", AWACS); - this.#advancedSettingsDialog.toggleAttribute("data-show-TACAN", tanker || ["Aircraft Carrier", "Super Aircraft Carrier"].includes(units[0].getType())); - this.#advancedSettingsDialog.toggleAttribute("data-show-radio", tanker || AWACS || ["Aircraft Carrier", "Super Aircraft Carrier"].includes(units[0].getType())); + this.#advancedSettingsDialog.toggleAttribute("data-show-tasking", isTanker || isAWACS); + this.#advancedSettingsDialog.toggleAttribute("data-show-tanker", isTanker); + this.#advancedSettingsDialog.toggleAttribute("data-show-AWACS", isAWACS); + this.#advancedSettingsDialog.toggleAttribute("data-show-TACAN", isTanker || ["Aircraft Carrier", "Super Aircraft Carrier"].includes(units[0].getType())); + this.#advancedSettingsDialog.toggleAttribute("data-show-radio", isTanker || isAWACS || ["Aircraft Carrier", "Super Aircraft Carrier"].includes(units[0].getType())); /* Set common properties */ // Name @@ -363,10 +361,6 @@ export class UnitControlPanel extends Panel { prohibitAGCheckbox.checked = unit.getGeneralSettings().prohibitAG; prohibitAirWpnCheckbox.checked = unit.getGeneralSettings().prohibitAirWpn; - // Tasking - //tankerCheckbox.checked = unit.getIsTanker(); - //AWACSCheckbox.checked = unit.getIsAWACS(); - // TACAN TACANCheckbox.checked = unit.getTACAN().isOn; TACANChannelInput.value = String(unit.getTACAN().channel); @@ -378,9 +372,9 @@ export class UnitControlPanel extends Panel { radioCallsignNumberInput.value = String(unit.getRadio().callsignNumber); this.#radioDecimalsDropdown.setValue("." + radioDecimals); - if (tanker) /* Set tanker specific options */ + if (isTanker) /* Set tanker specific options */ this.#radioCallsignDropdown.setOptions(["Texaco", "Arco", "Shell"]); - else if (AWACS) /* Set AWACS specific options */ + else if (isAWACS) /* Set AWACS specific options */ this.#radioCallsignDropdown.setOptions(["Overlord", "Magic", "Wizard", "Focus", "Darkstar"]); else this.#radioCallsignDropdown.setOptions(["Enfield", "Springfield", "Uzi", "Colt", "Dodge", "Ford", "Chevy", "Pontiac"]); @@ -399,17 +393,12 @@ export class UnitControlPanel extends Panel { const prohibitAACheckbox = this.#advancedSettingsDialog.querySelector("#prohibit-AA-checkbox")?.querySelector("input") as HTMLInputElement; const prohibitAGCheckbox = this.#advancedSettingsDialog.querySelector("#prohibit-AG-checkbox")?.querySelector("input") as HTMLInputElement; const prohibitAirWpnCheckbox = this.#advancedSettingsDialog.querySelector("#prohibit-air-wpn-checkbox")?.querySelector("input") as HTMLInputElement; - //const tankerCheckbox = this.#advancedSettingsDialog.querySelector("#tanker-checkbox")?.querySelector("input") as HTMLInputElement; - //const AWACSCheckbox = this.#advancedSettingsDialog.querySelector("#AWACS-checkbox")?.querySelector("input") as HTMLInputElement; const TACANCheckbox = this.#advancedSettingsDialog.querySelector("#TACAN-checkbox")?.querySelector("input") as HTMLInputElement; const TACANChannelInput = this.#advancedSettingsDialog.querySelector("#TACAN-channel")?.querySelector("input") as HTMLInputElement; const TACANCallsignInput = this.#advancedSettingsDialog.querySelector("#tacan-callsign")?.querySelector("input") as HTMLInputElement; const radioMhzInput = this.#advancedSettingsDialog.querySelector("#radio-mhz")?.querySelector("input") as HTMLInputElement; const radioCallsignNumberInput = this.#advancedSettingsDialog.querySelector("#radio-callsign-number")?.querySelector("input") as HTMLInputElement; - /* Tasking */ - //const isTanker = tankerCheckbox.checked? true: false; - //const isAWACS = AWACSCheckbox.checked? true: false; /* TACAN */ const TACAN: TACAN = { @@ -441,7 +430,7 @@ export class UnitControlPanel extends Panel { var units = getApp().getUnitsManager().getSelectedUnits(); // TODO: split setAdvancedOptions into setIsTanker, setIsAWACS, setAdvancedOptions if (units.length > 0) - units[0].setAdvancedOptions(units[0].getIsTanker(), units[0].getIsAWACS(), TACAN, radio, generalSettings); + units[0].setAdvancedOptions(units[0].getIsActiveTanker(), units[0].getIsActiveAWACS(), TACAN, radio, generalSettings); this.#advancedSettingsDialog.classList.add("hide"); } diff --git a/client/src/server/servermanager.ts b/client/src/server/servermanager.ts index cf600561..cb6286f6 100644 --- a/client/src/server/servermanager.ts +++ b/client/src/server/servermanager.ts @@ -357,11 +357,11 @@ export class ServerManager { this.PUT(data, callback); } - setAdvacedOptions(ID: number, isTanker: boolean, isAWACS: boolean, TACAN: TACAN, radio: Radio, generalSettings: GeneralSettings, callback: CallableFunction = () => {}) { + setAdvacedOptions(ID: number, isActiveTanker: boolean, isActiveAWACS: boolean, TACAN: TACAN, radio: Radio, generalSettings: GeneralSettings, callback: CallableFunction = () => {}) { var command = { "ID": ID, - "isTanker": isTanker, - "isAWACS": isAWACS, + "isActiveTanker": isActiveTanker, + "isActiveAWACS": isActiveAWACS, "TACAN": TACAN, "radio": radio, "generalSettings": generalSettings diff --git a/client/src/unit/unit.ts b/client/src/unit/unit.ts index 02c14605..872dcc19 100644 --- a/client/src/unit/unit.ts +++ b/client/src/unit/unit.ts @@ -35,8 +35,8 @@ export class Unit extends CustomMarker { #position: LatLng = new LatLng(0, 0, 0); #speed: number = 0; #heading: number = 0; - #isTanker: boolean = false; - #isAWACS: boolean = false; + #isActiveTanker: boolean = false; + #isActiveAWACS: boolean = false; #onOff: boolean = true; #followRoads: boolean = false; #fuel: number = 0; @@ -110,8 +110,8 @@ export class Unit extends CustomMarker { getPosition() { return this.#position }; getSpeed() { return this.#speed }; getHeading() { return this.#heading }; - getIsTanker() { return this.#isTanker }; - getIsAWACS() { return this.#isAWACS }; + getIsActiveTanker() { return this.#isActiveTanker }; + getIsActiveAWACS() { return this.#isActiveAWACS }; getOnOff() { return this.#onOff }; getFollowRoads() { return this.#followRoads }; getFuel() { return this.#fuel }; @@ -221,8 +221,8 @@ export class Unit extends CustomMarker { case DataIndexes.position: this.#position = dataExtractor.extractLatLng(); updateMarker = true; break; case DataIndexes.speed: this.#speed = dataExtractor.extractFloat64(); updateMarker = true; break; case DataIndexes.heading: this.#heading = dataExtractor.extractFloat64(); updateMarker = true; break; - case DataIndexes.isTanker: this.#isTanker = dataExtractor.extractBool(); break; - case DataIndexes.isAWACS: this.#isAWACS = dataExtractor.extractBool(); break; + case DataIndexes.isActiveTanker: this.#isActiveTanker = dataExtractor.extractBool(); break; + case DataIndexes.isActiveAWACS: this.#isActiveAWACS = dataExtractor.extractBool(); break; case DataIndexes.onOff: this.#onOff = dataExtractor.extractBool(); break; case DataIndexes.followRoads: this.#followRoads = dataExtractor.extractBool(); break; case DataIndexes.fuel: this.#fuel = dataExtractor.extractUInt16(); break; @@ -285,8 +285,8 @@ export class Unit extends CustomMarker { position: this.#position, speed: this.#speed, heading: this.#heading, - isTanker: this.#isTanker, - isAWACS: this.#isAWACS, + isActiveTanker: this.#isActiveTanker, + isActiveAWACS: this.#isActiveAWACS, onOff: this.#onOff, followRoads: this.#followRoads, fuel: this.#fuel, @@ -638,6 +638,14 @@ export class Unit extends CustomMarker { return this.getDatabase()?.getByName(this.#name)?.canRearm === true; } + isTanker() { + return this.canFulfillRole("Tanker"); + } + + isAWACS() { + return this.canFulfillRole("AWACS"); + } + /********************** Unit commands *************************/ addDestination(latlng: L.LatLng) { if (!this.#human) { @@ -746,9 +754,9 @@ export class Unit extends CustomMarker { getApp().getServerManager().refuel(this.ID); } - setAdvancedOptions(isTanker: boolean, isAWACS: boolean, TACAN: TACAN, radio: Radio, generalSettings: GeneralSettings) { + setAdvancedOptions(isActiveTanker: boolean, isActiveAWACS: boolean, TACAN: TACAN, radio: Radio, generalSettings: GeneralSettings) { if (!this.#human) - getApp().getServerManager().setAdvacedOptions(this.ID, isTanker, isAWACS, TACAN, radio, generalSettings); + getApp().getServerManager().setAdvacedOptions(this.ID, isActiveTanker, isActiveAWACS, TACAN, radio, generalSettings); } bombPoint(latlng: LatLng) { @@ -1035,9 +1043,9 @@ export class Unit extends CustomMarker { } else { // Unit is under Olympus control if (this.#onOff) { - if (this.#isTanker) + if (this.#isActiveTanker) element.querySelector(".unit")?.setAttribute("data-state", "tanker"); - else if (this.#isAWACS) + else if (this.#isActiveAWACS) element.querySelector(".unit")?.setAttribute("data-state", "AWACS"); else element.querySelector(".unit")?.setAttribute("data-state", this.#state.toLowerCase()); @@ -1270,7 +1278,6 @@ export class Unit extends CustomMarker { if (getApp().getMap().hasLayer(this.#engagementCircle)) this.#engagementCircle.removeFrom(getApp().getMap()); } - } } diff --git a/src/core/include/datatypes.h b/src/core/include/datatypes.h index 81a767af..52314c42 100644 --- a/src/core/include/datatypes.h +++ b/src/core/include/datatypes.h @@ -20,8 +20,8 @@ namespace DataIndex { position, speed, heading, - isTanker, - isAWACS, + isActiveTanker, + isActiveAWACS, onOff, followRoads, fuel, diff --git a/src/core/include/unit.h b/src/core/include/unit.h index ebbcff94..60749f69 100644 --- a/src/core/include/unit.h +++ b/src/core/include/unit.h @@ -77,8 +77,8 @@ public: virtual void setPosition(Coords newValue) { updateValue(position, newValue, DataIndex::position); } virtual void setSpeed(double newValue) { updateValue(speed, newValue, DataIndex::speed); } virtual void setHeading(double newValue) { updateValue(heading, newValue, DataIndex::heading); } - virtual void setIsTanker(bool newValue); - virtual void setIsAWACS(bool newValue); + virtual void setIsActiveTanker(bool newValue); + virtual void setIsActiveAWACS(bool newValue); virtual void setOnOff(bool newValue, bool force = false) { updateValue(onOff, newValue, DataIndex::onOff); }; virtual void setFollowRoads(bool newValue, bool force = false) { updateValue(followRoads, newValue, DataIndex::followRoads); }; virtual void setFuel(unsigned short newValue) { updateValue(fuel, newValue, DataIndex::fuel); } @@ -118,8 +118,8 @@ public: virtual Coords getPosition() { return position; } virtual double getSpeed() { return speed; } virtual double getHeading() { return heading; } - virtual bool getIsTanker() { return isTanker; } - virtual bool getIsAWACS() { return isAWACS; } + virtual bool getIsActiveTanker() { return isActiveTanker; } + virtual bool getIsActiveAWACS() { return isActiveAWACS; } virtual bool getOnOff() { return onOff; }; virtual bool getFollowRoads() { return followRoads; }; virtual unsigned short getFuel() { return fuel; } @@ -161,8 +161,8 @@ protected: Coords position = Coords(NULL); double speed = NULL; double heading = NULL; - bool isTanker = false; - bool isAWACS = false; + bool isActiveTanker = false; + bool isActiveAWACS = false; bool onOff = true; bool followRoads = false; unsigned short fuel = 0; diff --git a/src/core/src/airunit.cpp b/src/core/src/airunit.cpp index 3f1950e8..5db499c6 100644 --- a/src/core/src/airunit.cpp +++ b/src/core/src/airunit.cpp @@ -149,9 +149,9 @@ void AirUnit::AIloop() /* State machine */ switch (state) { case State::IDLE: { - if (isTanker) + if (isActiveTanker) setTask("Tanker racetrack"); - else if (isAWACS) + else if (isActiveAWACS) setTask("AWACS racetrack"); else setTask("Idle"); @@ -159,12 +159,12 @@ void AirUnit::AIloop() if (!getHasTask()) { std::ostringstream taskSS; - if (isTanker) { + if (isActiveTanker) { taskSS << "{ [1] = { id = 'Tanker' }, [2] = { id = 'Orbit', pattern = 'Race-Track', altitude = " << desiredAltitude << ", speed = " << desiredSpeed << ", altitudeType = '" << (desiredAltitudeType ? "AGL" : "ASL") << "', speedType = '" << (desiredSpeedType ? "GS" : "CAS") << "' }}"; } - else if (isAWACS) { + else if (isActiveAWACS) { taskSS << "{ [1] = { id = 'AWACS' }, [2] = { id = 'Orbit', pattern = 'Circle', altitude = " << desiredAltitude << ", speed = " << desiredSpeed << ", altitudeType = '" << (desiredAltitudeType ? "AGL" : "ASL") << "', speedType = '" << (desiredSpeedType ? "GS" : "CAS") << "' }}"; @@ -184,12 +184,12 @@ void AirUnit::AIloop() string enrouteTask = ""; bool looping = false; - if (isTanker) + if (isActiveTanker) { enrouteTask = "{ id = 'Tanker' }"; setTask("Tanker"); } - else if (isAWACS) + else if (isActiveAWACS) { enrouteTask = "{ id = 'AWACS' }"; setTask("AWACS"); diff --git a/src/core/src/scheduler.cpp b/src/core/src/scheduler.cpp index 28ad9459..8fba5691 100644 --- a/src/core/src/scheduler.cpp +++ b/src/core/src/scheduler.cpp @@ -458,8 +458,8 @@ void Scheduler::handleRequest(string key, json::value value, string username, js if (unit != nullptr) { /* Advanced tasking */ - unit->setIsTanker(value[L"isTanker"].as_bool()); - unit->setIsAWACS(value[L"isAWACS"].as_bool()); + unit->setIsActiveTanker(value[L"isActiveTanker"].as_bool()); + unit->setIsActiveAWACS(value[L"isActiveAWACS"].as_bool()); /* TACAN Options */ DataTypes::TACAN TACAN; diff --git a/src/core/src/unit.cpp b/src/core/src/unit.cpp index a5414aab..2afc51c5 100644 --- a/src/core/src/unit.cpp +++ b/src/core/src/unit.cpp @@ -172,8 +172,8 @@ void Unit::refreshLeaderData(unsigned long long time) { case DataIndex::state: updateValue(state, leader->state, datumIndex); break; case DataIndex::task: updateValue(task, leader->task, datumIndex); break; case DataIndex::hasTask: updateValue(hasTask, leader->hasTask, datumIndex); break; - case DataIndex::isTanker: updateValue(isTanker, leader->isTanker, datumIndex); break; - case DataIndex::isAWACS: updateValue(isAWACS, leader->isAWACS, datumIndex); break; + case DataIndex::isActiveTanker: updateValue(isActiveTanker, leader->isActiveTanker, datumIndex); break; + case DataIndex::isActiveAWACS: updateValue(isActiveAWACS, leader->isActiveAWACS, datumIndex); break; case DataIndex::onOff: updateValue(onOff, leader->onOff, datumIndex); break; case DataIndex::followRoads: updateValue(followRoads, leader->followRoads, datumIndex); break; case DataIndex::desiredSpeed: updateValue(desiredSpeed, leader->desiredSpeed, datumIndex); break; @@ -248,8 +248,8 @@ void Unit::getData(stringstream& ss, unsigned long long time) case DataIndex::position: appendNumeric(ss, datumIndex, position); break; case DataIndex::speed: appendNumeric(ss, datumIndex, speed); break; case DataIndex::heading: appendNumeric(ss, datumIndex, heading); break; - case DataIndex::isTanker: appendNumeric(ss, datumIndex, isTanker); break; - case DataIndex::isAWACS: appendNumeric(ss, datumIndex, isAWACS); break; + case DataIndex::isActiveTanker: appendNumeric(ss, datumIndex, isActiveTanker); break; + case DataIndex::isActiveAWACS: appendNumeric(ss, datumIndex, isActiveAWACS); break; case DataIndex::onOff: appendNumeric(ss, datumIndex, onOff); break; case DataIndex::followRoads: appendNumeric(ss, datumIndex, followRoads); break; case DataIndex::fuel: appendNumeric(ss, datumIndex, fuel); break; @@ -495,23 +495,23 @@ void Unit::landAt(Coords loc) setState(State::LAND); } -void Unit::setIsTanker(bool newIsTanker) +void Unit::setIsActiveTanker(bool newIsActiveTanker) { - if (isTanker != newIsTanker) { - isTanker = newIsTanker; + if (isActiveTanker != newIsActiveTanker) { + isActiveTanker = newIsActiveTanker; resetTask(); - triggerUpdate(DataIndex::isTanker); + triggerUpdate(DataIndex::isActiveTanker); } } -void Unit::setIsAWACS(bool newIsAWACS) +void Unit::setIsActiveAWACS(bool newIsActiveAWACS) { - if (isAWACS != newIsAWACS) { - isAWACS = newIsAWACS; + if (isActiveAWACS != newIsActiveAWACS) { + isActiveAWACS = newIsActiveAWACS; resetTask(); - triggerUpdate(DataIndex::isAWACS); + triggerUpdate(DataIndex::isActiveAWACS); } }