Merge pull request #230 from Pax1601/218-add-humandcs-controlledolympus-controller-icon

218 add humandcs controlledolympus controller icon
This commit is contained in:
Pax1601
2023-04-28 15:43:22 +02:00
committed by GitHub
25 changed files with 4566 additions and 84 deletions

View File

@@ -2064,8 +2064,8 @@ export class AircraftDatabase extends UnitDatabase {
],
"filename": "kc-135.png"
},
"KC-135MPRS": {
"name": "KC-135MPRS",
"KC135MPRS": {
"name": "KC135MPRS",
"label": "KC-135 MPRS Stratotanker",
"shortLabel": "135M",
"loadouts": [
@@ -2083,6 +2083,44 @@ export class AircraftDatabase extends UnitDatabase {
],
"filename": "kc-135.png"
},
"KC_10_Extender": {
"name": "KC_10_Extender",
"label": "KC-10 Extender",
"shortLabel": "KC10",
"loadouts": [
{
"fuel": 1,
"items": [
],
"roles": [
"Tanker"
],
"code": "",
"name": "Default Tanker"
}
],
"filename": "kc-10.png"
},
"KC_10_Extender_D": {
"name": "KC_10_Extender_D",
"label": "KC-10 Extender (Drogue)",
"shortLabel": "KC10",
"loadouts": [
{
"fuel": 1,
"items": [
],
"roles": [
"Tanker"
],
"code": "",
"name": "Default Tanker"
}
],
"filename": "kc-10.png"
},
"MiG-15bis": {
"name": "MiG-15bis",
"label": "MiG-15 Fagot",

View File

@@ -1,9 +1,10 @@
import { Marker, LatLng, Polyline, Icon, DivIcon } from 'leaflet';
import { Marker, LatLng, Polyline, Icon, DivIcon, CircleMarker } from 'leaflet';
import { getMap, getUnitsManager } from '..';
import { rad2deg } from '../other/utils';
import { addDestination, attackUnit, changeAltitude, changeSpeed, createFormation as setLeader, deleteUnit, getUnits, landAt, setAltitude, setReactionToThreat, setROE, setSpeed, refuel, setAdvacedOptions, followUnit } from '../server/server';
import { aircraftDatabase } from './aircraftdatabase';
import { groundUnitsDatabase } from './groundunitsdatabase';
import { field } from 'geomag'
var pathIcon = new Icon({
iconUrl: 'images/marker-icon.png',
@@ -77,6 +78,7 @@ export class Unit extends Marker {
#pathMarkers: Marker[] = [];
#pathPolyline: Polyline;
#targetsPolylines: Polyline[];
#miniMapMarker: CircleMarker | null = null;
#timer: number = 0;
#forceUpdate: boolean = false;
@@ -107,11 +109,11 @@ export class Unit extends Marker {
/* Deselect units if they are hidden */
document.addEventListener("toggleCoalitionVisibility", (ev: CustomEventInit) => {
setTimeout(() => {this.setSelected(this.getSelected() && !this.getHidden())}, 300);
window.setTimeout(() => {this.setSelected(this.getSelected() && !this.getHidden())}, 300);
});
document.addEventListener("toggleUnitVisibility", (ev: CustomEventInit) => {
setTimeout(() => {this.setSelected(this.getSelected() && !this.getHidden())}, 300);
window.setTimeout(() => {this.setSelected(this.getSelected() && !this.getHidden())}, 300);
});
/* Set the unit data */
@@ -124,7 +126,6 @@ export class Unit extends Marker {
iconAnchor: [0, 0]
});
this.setIcon(icon);
}
getMarkerHTML() {
@@ -392,7 +393,7 @@ export class Unit extends Marker {
}
#onClick(e: any) {
this.#timer = setTimeout(() => {
this.#timer = window.setTimeout(() => {
if (!this.#preventClick) {
if (getMap().getState() === 'IDLE' || getMap().getState() === 'MOVE_UNIT' || e.originalEvent.ctrlKey) {
if (!e.originalEvent.ctrlKey) {
@@ -517,8 +518,33 @@ export class Unit extends Marker {
#updateMarker() {
this.updateVisibility();
if (!this.getHidden()) {
if (this.getBaseData().alive )
{
if (this.#miniMapMarker == null)
{
this.#miniMapMarker = new CircleMarker(new LatLng(this.getFlightData().latitude, this.getFlightData().longitude), {radius: 0.5});
if (this.getMissionData().coalition == "neutral")
this.#miniMapMarker.setStyle({color: "#CFD9E8"});
else if (this.getMissionData().coalition == "red")
this.#miniMapMarker.setStyle({color: "#ff5858"});
else
this.#miniMapMarker.setStyle({color: "#247be2"});
this.#miniMapMarker.addTo(getMap().getMiniMapLayerGroup());
this.#miniMapMarker.bringToBack();
}
else {
this.#miniMapMarker.setLatLng(new LatLng(this.getFlightData().latitude, this.getFlightData().longitude));
this.#miniMapMarker.bringToBack();
}
}
else {
if (this.#miniMapMarker != null && getMap().getMiniMapLayerGroup().hasLayer(this.#miniMapMarker)) {
getMap().getMiniMapLayerGroup().removeLayer(this.#miniMapMarker);
this.#miniMapMarker = null;
}
}
if (!this.getHidden()) {
this.setLatLng(new LatLng(this.getFlightData().latitude, this.getFlightData().longitude));
var element = this.getElement();
if (element != null) {
@@ -530,17 +556,20 @@ export class Unit extends Marker {
element.querySelector(".unit")?.toggleAttribute("data-is-dead", !this.getBaseData().alive);
element.querySelector(".unit")?.setAttribute("data-state", this.getTaskData().currentState.toLowerCase());
var unitHeadingDiv = element.querySelector(".unit-heading");
if (unitHeadingDiv != null)
unitHeadingDiv.innerHTML = String(Math.floor(rad2deg(this.getFlightData().heading)));
if (this.getMissionData().flags.Human) // Unit is human
element.querySelector(".unit")?.setAttribute("data-state", "human");
else if (!this.getBaseData().AI) // Unit is under DCS control (no Olympus)
element.querySelector(".unit")?.setAttribute("data-state", "dcs");
else // Unit is under Olympus control
element.querySelector(".unit")?.setAttribute("data-state", this.getTaskData().currentState.toLowerCase());
var unitAltitudeDiv = element.querySelector(".unit-altitude");
if (unitAltitudeDiv != null) {
unitAltitudeDiv.innerHTML = String(Math.floor(this.getFlightData().altitude / 0.3048 / 1000));
}
if (unitAltitudeDiv != null)
unitAltitudeDiv.innerHTML = "FL" + String(Math.floor(this.getFlightData().altitude / 0.3048 / 1000));
var unitSpeedDiv = element.querySelector(".unit-speed");
if (unitSpeedDiv != null)
unitSpeedDiv.innerHTML = String(Math.floor(this.getFlightData().speed * 1.94384 ) );
element.querySelectorAll( "[data-rotate-to-heading]" ).forEach( el => {
const headingDeg = rad2deg( this.getFlightData().heading );
@@ -548,9 +577,7 @@ export class Unit extends Marker {
el.setAttribute( "style", currentStyle + `transform:rotate(${headingDeg}deg);` );
});
var unitSpeedDiv = element.querySelector(".unit-speed");
if (unitSpeedDiv != null)
unitSpeedDiv.innerHTML = String(Math.floor(this.getFlightData().speed * 1.94384 ) );
}
var pos = getMap().latLngToLayerPoint(this.getLatLng()).round();

View File

@@ -68,7 +68,7 @@ export class UnitsManager {
Object.keys(data.units)
.filter((ID: string) => !(ID in this.#units))
.reduce((timeout: number, ID: string) => {
setTimeout(() => {
window.setTimeout(() => {
if (!(ID in this.#units))
this.addUnit(parseInt(ID), data.units[ID]);
this.#units[parseInt(ID)]?.setData(data.units[ID]);
@@ -330,7 +330,7 @@ export class UnitsManager {
this.#showActionMessage(this.#copiedUnits, `pasted`);
}
this.#pasteDisabled = true;
setTimeout(() => this.#pasteDisabled = false, 250);
window.setTimeout(() => this.#pasteDisabled = false, 250);
}
}
@@ -348,7 +348,7 @@ export class UnitsManager {
/* Disable the firing of the selection event for a certain amount of time. This avoids firing many events if many units are selected */
if (!this.#selectionEventDisabled)
{
setTimeout(() => {
window.setTimeout(() => {
document.dispatchEvent(new CustomEvent("unitsSelection", {detail: this.getSelectedUnits()}));
this.#selectionEventDisabled = false;
}, 100);