mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Multiple minor fixes
This commit is contained in:
@@ -9,7 +9,7 @@ import { AIC } from "./aic/aic";
|
||||
import { ATC } from "./atc/ATC";
|
||||
import { FeatureSwitches } from "./FeatureSwitches";
|
||||
import { LogPanel } from "./panels/logpanel";
|
||||
import { getAirbases, getBulllseye as getBulllseyes, getUnits, toggleDemoEnabled } from "./server/server";
|
||||
import { getAirbases, getBulllseye as getBulllseyes, getMission, getUnits, toggleDemoEnabled } from "./server/server";
|
||||
|
||||
var map: Map;
|
||||
|
||||
@@ -68,6 +68,7 @@ function setup() {
|
||||
/* On the first connection, force request of full data */
|
||||
getAirbases((data: AirbasesData) => getMissionData()?.update(data));
|
||||
getBulllseyes((data: BullseyesData) => getMissionData()?.update(data));
|
||||
getMission((data: any) => {getMissionData()?.update(data)});
|
||||
getUnits((data: UnitsData) => getUnitsManager()?.update(data), true /* Does a full refresh */);
|
||||
|
||||
/* Start periodically requesting updates */
|
||||
@@ -95,6 +96,7 @@ function requestRefresh() {
|
||||
getUnits((data: UnitsData) => {
|
||||
getAirbases((data: AirbasesData) => getMissionData()?.update(data));
|
||||
getBulllseyes((data: BullseyesData) => getMissionData()?.update(data));
|
||||
getMission((data: any) => {getMissionData()?.update(data)});
|
||||
checkSessionHash(data.sessionHash);
|
||||
}, true);
|
||||
setTimeout(() => requestRefresh(), 5000);
|
||||
|
||||
@@ -24,7 +24,8 @@ export class Airbase extends L.Marker
|
||||
<div class="airbase-marker"> </div>
|
||||
</div>`,
|
||||
className: 'leaflet-airbase-marker',
|
||||
iconSize: [63, 63]
|
||||
iconSize: [40, 40],
|
||||
iconAnchor: [20, 20]
|
||||
}); // Set the marker, className must be set to avoid white square
|
||||
this.setIcon(icon);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ export class MissionHandler
|
||||
#bullseyeMarkers: any;
|
||||
#airbases : any; //TODO declare interface
|
||||
#airbasesMarkers: {[name: string]: Airbase};
|
||||
#theatre : string = "";
|
||||
|
||||
constructor()
|
||||
{
|
||||
@@ -26,7 +27,7 @@ export class MissionHandler
|
||||
this.#airbasesMarkers = {};
|
||||
}
|
||||
|
||||
update(data: BullseyesData | AirbasesData)
|
||||
update(data: BullseyesData | AirbasesData | any)
|
||||
{
|
||||
if ("bullseyes" in data)
|
||||
{
|
||||
@@ -39,6 +40,17 @@ export class MissionHandler
|
||||
this.#airbases = data.airbases;
|
||||
this.#drawAirbases();
|
||||
}
|
||||
|
||||
if ("mission" in data)
|
||||
{
|
||||
var foo = 1;
|
||||
if (data.mission.theatre != this.#theatre)
|
||||
{
|
||||
this.#theatre = data.mission.theatre
|
||||
if (this.#theatre == "Syria")
|
||||
getMap().setView(new LatLng(34.5, 36.0), 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
getBullseyes()
|
||||
@@ -51,7 +63,7 @@ export class MissionHandler
|
||||
for (let idx in this.#bullseyes)
|
||||
{
|
||||
var bullseye = this.#bullseyes[idx];
|
||||
this.#bullseyeMarkers[idx].setLatLng(new LatLng(bullseye.lat, bullseye.lng));
|
||||
this.#bullseyeMarkers[idx].setLatLng(new LatLng(bullseye.latitude, bullseye.longitude));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,14 +75,14 @@ export class MissionHandler
|
||||
if (this.#airbasesMarkers[idx] === undefined)
|
||||
{
|
||||
this.#airbasesMarkers[idx] = new Airbase({
|
||||
position: new LatLng(airbase.lat, airbase.lng),
|
||||
position: new LatLng(airbase.latitude, airbase.longitude),
|
||||
name: airbase.callsign,
|
||||
src: "images/airbase.png"}).addTo(getMap());
|
||||
this.#airbasesMarkers[idx].on('contextmenu', (e) => this.#onAirbaseClick(e));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.#airbasesMarkers[idx].setLatLng(new LatLng(airbase.lat, airbase.lng));
|
||||
this.#airbasesMarkers[idx].setLatLng(new LatLng(airbase.latitude, airbase.longitude));
|
||||
this.#airbasesMarkers[idx].setCoalition(airbase.coalition);
|
||||
this.#airbasesMarkers[idx].setProperties(["test1", "test2"]);
|
||||
this.#airbasesMarkers[idx].setParkings(["2x big", "5x small"]);
|
||||
|
||||
@@ -36,8 +36,8 @@ export class MouseInfoPanel extends Panel {
|
||||
var el = <HTMLElement>this.getElement().querySelector(`#bullseye-${idx}`);
|
||||
|
||||
if ( el != null ) {
|
||||
var dist = distance(bullseyes[idx].lat, bullseyes[idx].lng, mousePosition.lat, mousePosition.lng);
|
||||
var bear = bearing(bullseyes[idx].lat, bullseyes[idx].lng, mousePosition.lat, mousePosition.lng);
|
||||
var dist = distance(bullseyes[idx].latitude, bullseyes[idx].longitude, mousePosition.lat, mousePosition.lng);
|
||||
var bear = bearing(bullseyes[idx].latitude, bullseyes[idx].longitude, mousePosition.lat, mousePosition.lng);
|
||||
|
||||
el.dataset.bearing = zeroAppend(Math.floor(bear), 3);
|
||||
el.dataset.distance = zeroAppend(Math.floor(dist*0.000539957), 3);
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import { getUnitsManager } from "..";
|
||||
import { Slider } from "../controls/slider";
|
||||
import { Unit } from "../units/unit";
|
||||
import { aircraftDatabase } from "../units/aircraftdatabase";
|
||||
import { groundUnitsDatabase } from "../units/groundunitsdatabase";
|
||||
import { Aircraft, GroundUnit, Unit } from "../units/unit";
|
||||
import { Panel } from "./panel";
|
||||
|
||||
const ROEs: string[] = ["Free", "Designated free", "Designated", "Return", "Hold"];
|
||||
@@ -69,7 +71,14 @@ export class UnitControlPanel extends Panel {
|
||||
{
|
||||
var button = document.createElement("button");
|
||||
button.innerText = unit.getBaseData().unitName;
|
||||
button.setAttribute( "data-short-label", unit.getBaseData().name );
|
||||
|
||||
if (unit instanceof Aircraft)
|
||||
button.setAttribute( "data-short-label", aircraftDatabase.getShortLabelByName(unit.getBaseData().name));
|
||||
else if (unit instanceof GroundUnit)
|
||||
button.setAttribute( "data-short-label", groundUnitsDatabase.getShortLabelByName(unit.getBaseData().name));
|
||||
else
|
||||
button.setAttribute( "data-short-label", "");
|
||||
|
||||
button.setAttribute( "data-coalition", unit.getMissionData().coalition );
|
||||
button.classList.add( "pill", "highlight-coalition" )
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ const UNITS_URI = "units";
|
||||
const LOGS_URI = "logs";
|
||||
const AIRBASES_URI = "airbases";
|
||||
const BULLSEYE_URI = "bullseyes";
|
||||
const MISSION_URI = "mission";
|
||||
|
||||
var lastUpdateTime = 0;
|
||||
var demoEnabled = false;
|
||||
@@ -56,6 +57,10 @@ export function getLogs(callback: CallableFunction) {
|
||||
GET(callback, LOGS_URI);
|
||||
}
|
||||
|
||||
export function getMission(callback: CallableFunction) {
|
||||
GET(callback, MISSION_URI);
|
||||
}
|
||||
|
||||
export function getUnits(callback: CallableFunction, refresh: boolean = false) {
|
||||
GET(callback, `${UNITS_URI}?time=${refresh? 0: lastUpdateTime}`);
|
||||
}
|
||||
|
||||
@@ -383,7 +383,7 @@ export class Unit extends Marker {
|
||||
unitAltitudeDiv.innerHTML = String(Math.floor(this.getFlightData().altitude / 0.3048 / 1000));
|
||||
}
|
||||
var pos = getMap().latLngToLayerPoint(this.getLatLng()).round();
|
||||
this.setZIndexOffset(Math.floor(this.getFlightData().altitude) - pos.y);
|
||||
this.setZIndexOffset(1000 + Math.floor(this.getFlightData().altitude) - pos.y);
|
||||
}
|
||||
|
||||
this.#forceUpdate = false;
|
||||
@@ -503,7 +503,10 @@ export class Helicopter extends AirUnit {
|
||||
|
||||
export class GroundUnit extends Unit {
|
||||
constructor(ID: number, data: UnitData) {
|
||||
// TODO this is very messy
|
||||
var role = groundUnitsDatabase.getByName(data.baseData.name)?.loadouts[0].roles[0];
|
||||
if (role == undefined)
|
||||
role = "U";
|
||||
var roleType = (role === "SAM") ? "sam" : "mi";
|
||||
|
||||
super(ID, data, `
|
||||
|
||||
@@ -101,6 +101,6 @@ export class UnitDatabase {
|
||||
|
||||
getShortLabelByName(name: string)
|
||||
{
|
||||
return this.units[name] === undefined? name: this.units[name].shortLabel;
|
||||
return this.units[name] === undefined? "U": this.units[name].shortLabel;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user