Modified isTanker and isAWACS to isActiveTanker and isActiveAWACS

This commit is contained in:
Pax1601
2023-10-13 16:35:11 +02:00
parent 9ffab7d531
commit d3faf65900
12 changed files with 93 additions and 99 deletions

View File

@@ -178,8 +178,8 @@ export enum DataIndexes {
position,
speed,
heading,
isTanker,
isAWACS,
isActiveTanker,
isActiveAWACS,
onOff,
followRoads,
fuel,

View File

@@ -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;

View File

@@ -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");
}

View File

@@ -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

View File

@@ -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());
}
}
}