mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Moved code from broken branch.
This commit is contained in:
@@ -8,10 +8,37 @@ export interface AirbaseOptions
|
||||
position: L.LatLng
|
||||
}
|
||||
|
||||
|
||||
export interface AirbaseChartData {
|
||||
elevation: string,
|
||||
ICAO: string,
|
||||
TACAN: string,
|
||||
runways: AirbaseChartRunwayData[]
|
||||
}
|
||||
|
||||
export interface AirbaseChartRunwayData {
|
||||
"headings": AirbaseChartRunwayHeadingData[],
|
||||
"length": string
|
||||
}
|
||||
|
||||
export interface AirbaseChartRunwayHeadingData {
|
||||
[index: string]: {
|
||||
"magHeading": string,
|
||||
"ILS": string
|
||||
}
|
||||
}
|
||||
|
||||
export class Airbase extends CustomMarker
|
||||
{
|
||||
#name: string = "";
|
||||
#chartData: AirbaseChartData = {
|
||||
elevation: "",
|
||||
ICAO: "",
|
||||
TACAN: "",
|
||||
runways: []
|
||||
};
|
||||
#coalition: string = "";
|
||||
#hasChartDataBeenSet:boolean = false;
|
||||
#properties: string[] = [];
|
||||
#parkings: string[] = [];
|
||||
|
||||
@@ -22,6 +49,10 @@ export class Airbase extends CustomMarker
|
||||
this.#name = options.name;
|
||||
}
|
||||
|
||||
chartDataHasBeenSet() {
|
||||
return this.#hasChartDataBeenSet;
|
||||
}
|
||||
|
||||
createIcon() {
|
||||
var icon = new DivIcon({
|
||||
className: 'leaflet-airbase-marker',
|
||||
@@ -47,6 +78,11 @@ export class Airbase extends CustomMarker
|
||||
(<HTMLElement> this.getElement()?.querySelector(".airbase-icon")).dataset.coalition = this.#coalition;
|
||||
}
|
||||
|
||||
getChartData()
|
||||
{
|
||||
return this.#chartData;
|
||||
}
|
||||
|
||||
getCoalition()
|
||||
{
|
||||
return this.#coalition;
|
||||
@@ -62,6 +98,12 @@ export class Airbase extends CustomMarker
|
||||
return this.#name;
|
||||
}
|
||||
|
||||
setChartData( chartData:AirbaseChartData )
|
||||
{
|
||||
this.#hasChartDataBeenSet = true;
|
||||
this.#chartData = chartData;
|
||||
}
|
||||
|
||||
setProperties(properties: string[])
|
||||
{
|
||||
this.#properties = properties;
|
||||
@@ -81,4 +123,4 @@ export class Airbase extends CustomMarker
|
||||
{
|
||||
return this.#parkings;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { LatLng } from "leaflet";
|
||||
import { getInfoPopup, getMap } from "..";
|
||||
import { Airbase } from "./airbase";
|
||||
import { Airbase, AirbaseChartData } from "./airbase";
|
||||
import { Bullseye } from "./bullseye";
|
||||
import { BLUE_COMMANDER, GAME_MASTER, NONE, RED_COMMANDER } from "../constants/constants";
|
||||
import { refreshAll, setCommandModeOptions } from "../server/server";
|
||||
@@ -66,11 +66,14 @@ export class MissionHandler {
|
||||
|
||||
updateMission(data: MissionData) {
|
||||
if (data.mission) {
|
||||
|
||||
/* Set the mission theatre */
|
||||
if (data.mission.theatre != this.#theatre) {
|
||||
this.#theatre = data.mission.theatre;
|
||||
getMap().setTheatre(this.#theatre);
|
||||
getInfoPopup().setText("Map set to " + this.#theatre);
|
||||
|
||||
this.#loadAirbaseChartData();
|
||||
}
|
||||
|
||||
/* Set the date and time data */
|
||||
@@ -231,4 +234,38 @@ export class MissionHandler {
|
||||
#onAirbaseClick(e: any) {
|
||||
getMap().showAirbaseContextMenu(e.originalEvent.x, e.originalEvent.y, e.latlng, e.sourceTarget);
|
||||
}
|
||||
|
||||
|
||||
#loadAirbaseChartData() {
|
||||
|
||||
if ( !this.#theatre ) {
|
||||
return;
|
||||
}
|
||||
|
||||
fetch( '/api/airbases/' + this.#theatre , {
|
||||
method: 'GET',
|
||||
headers: {
|
||||
'Accept': '*/*',
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
.then( response => response.json() )
|
||||
.then( data => {
|
||||
|
||||
for ( const [ id, airbase ] of Object.entries( this.#airbases ) ) {
|
||||
|
||||
let airbaseName = airbase.getName();
|
||||
|
||||
if ( data.hasOwnProperty( airbaseName ) ) {
|
||||
airbase.setChartData( data[ airbaseName ] );
|
||||
} else {
|
||||
console.error( `Airbase "${airbaseName}" not found in chart data.` );
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user