Follow, tankers and AWACS completed

This commit is contained in:
Pax1601
2023-04-19 16:30:14 +02:00
parent f24c57cc18
commit c3c84b2115
5 changed files with 68 additions and 21 deletions

View File

@@ -24,9 +24,10 @@ export class Dropdown {
this.#clip();
});
this.#element.addEventListener("mouseleave", ev => {
this.#close();
});
// Commented out since it is a bit frustrating, particularly when the dropdown opens towards the top and not to the bottom
//this.#element.addEventListener("mouseleave", ev => {
// this.#close();
//});
}
setOptions(optionsList: string[])
@@ -61,7 +62,10 @@ export class Dropdown {
this.#index = idx;
this.#close();
this.#callback(option);
return true;
}
else
return false;
}
reset() {
@@ -73,6 +77,12 @@ export class Dropdown {
return this.#value.innerText;
}
setValue(value: string) {
var index = this.#optionsList.findIndex((option) => {return option === value});
if (index > -1)
this.selectValue(index);
}
getIndex() {
return this.#index;
}

View File

@@ -1,5 +1,5 @@
import { Marker, LatLng, Icon } from "leaflet";
import { getMap, getUnitsManager } from "..";
import { getInfoPopup, getMap, getUnitsManager } from "..";
import { Airbase } from "./airbase";
var bullseyeIcons = [
@@ -58,6 +58,8 @@ export class MissionHandler
getMap().setView(new LatLng(-50.6, -42.7), 7);
else if (this.#theatre == "Caucasus")
getMap().setView(new LatLng(42.1, 42.3), 8);
getInfoPopup().setText("Map set to " + this.#theatre);
}
}
}
@@ -93,8 +95,8 @@ export class MissionHandler
{
this.#airbasesMarkers[idx].setLatLng(new LatLng(airbase.latitude, airbase.longitude));
this.#airbasesMarkers[idx].setCoalition(airbase.coalition);
this.#airbasesMarkers[idx].setProperties(["Runway 1: 31L / 13R", "Runway 2: 31R / 13L", "TCN: 17X", "ILS: ---" ]);
this.#airbasesMarkers[idx].setParkings(["2x big", "5x small"]);
//this.#airbasesMarkers[idx].setProperties(["Runway 1: 31L / 13R", "Runway 2: 31R / 13L", "TCN: 17X", "ILS: ---" ]);
//this.#airbasesMarkers[idx].setParkings(["2x big", "5x small"]);
}
}
}

View File

@@ -210,13 +210,37 @@ export class UnitControlPanel extends Panel {
if (getUnitsManager().getSelectedUnits().length == 1)
{
var radioMHz = Math.floor(unit.getTaskData().radioFrequency / 1000000);
var radioDecimals = (unit.getTaskData().radioFrequency / 1000000 - radioMHz) * 1000;
// Default values for "normal" units
this.#radioCallsignDropdown.setOptions(["Enfield", "Springfield", "Uzi", "Colt", "Dodge", "Ford", "Chevy", "Pontiac"]);
this.#radioCallsignDropdown.selectValue(unit.getTaskData().radioCallsign);
var tankerCheckbox = this.#advancedSettingsDialog.querySelector("#tanker-checkbox")?.querySelector("input")
if (tankerCheckbox) tankerCheckbox.checked = unit.getTaskData().isTanker;
var AWACSCheckbox = this.#advancedSettingsDialog.querySelector("#AWACS-checkbox")?.querySelector("input")
if (AWACSCheckbox) AWACSCheckbox.checked = unit.getTaskData().isAWACS;
// Input values
var tankerCheckbox = this.#advancedSettingsDialog.querySelector("#tanker-checkbox")?.querySelector("input")
var AWACSCheckbox = this.#advancedSettingsDialog.querySelector("#AWACS-checkbox")?.querySelector("input")
var TACANChannelInput = this.#advancedSettingsDialog.querySelector("#TACAN-channel")?.querySelector("input");
var TACANCallsignInput = this.#advancedSettingsDialog.querySelector("#tacan-callsign")?.querySelector("input");
var radioMhzInput = this.#advancedSettingsDialog.querySelector("#radio-mhz")?.querySelector("input");
var radioCallsignNumberInput = this.#advancedSettingsDialog.querySelector("#radio-callsign-number")?.querySelector("input");
if (tankerCheckbox) tankerCheckbox.checked = unit.getTaskData().isTanker;
if (AWACSCheckbox) AWACSCheckbox.checked = unit.getTaskData().isAWACS;
if (TACANChannelInput) TACANChannelInput.value = String(unit.getTaskData().TACANChannel);
if (TACANCallsignInput) TACANCallsignInput.value = String(unit.getTaskData().TACANCallsign);
if (radioMhzInput) radioMhzInput.value = String(radioMHz);
if (radioCallsignNumberInput) radioCallsignNumberInput.value = String(unit.getTaskData().radioCallsignNumber);
this.#TACANXYDropdown.setValue(unit.getTaskData().TACANXY);
this.#radioDecimalsDropdown.setValue("." + radioDecimals);
// Make sure its in the valid range
if (!this.#radioCallsignDropdown.selectValue(unit.getTaskData().radioCallsign))
this.#radioCallsignDropdown.selectValue(0);
// Set options for tankers
var roles = aircraftDatabase.getByName(unit.getBaseData().name)?.loadouts.map((loadout) => {return loadout.roles})
if (roles != undefined && Array.prototype.concat.apply([], roles)?.includes("Tanker")){
this.#advancedSettingsDialog.querySelector("#tanker-checkbox")?.classList.remove("hide");
@@ -227,6 +251,7 @@ export class UnitControlPanel extends Panel {
this.#advancedSettingsDialog.querySelector("#tanker-checkbox")?.classList.add("hide");
}
// Set options for AWACS
if (roles != undefined && Array.prototype.concat.apply([], roles)?.includes("AWACS")){
this.#advancedSettingsDialog.querySelector("#AWACS-checkbox")?.classList.remove("hide");
this.#radioCallsignDropdown.setOptions(["Overlord", "Magic", "Wizard", "Focus", "Darkstar"]);