mirror of
https://github.com/Pax1601/DCSOlympus.git
synced 2025-10-29 16:56:34 +00:00
Some database changes, started to add threat rings
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -68,6 +68,7 @@ export function addLoadoutItemsEditor(div: HTMLElement, loadout: LoadoutBlueprin
|
||||
itemsEl.classList.add("dm-scroll-container", "dm-items-container");
|
||||
|
||||
/* Create a row for each loadout item to allow and change the name and quantity of the item itself */
|
||||
loadout.items.sort((a: LoadoutItemBlueprint, b: LoadoutItemBlueprint) => a.name.localeCompare(b.name, undefined, {sensitivity: 'base'}));
|
||||
loadout.items.forEach((item: LoadoutItemBlueprint, index: number) => {
|
||||
var rowDiv = document.createElement("div");
|
||||
|
||||
@@ -154,7 +155,7 @@ export function addBlueprintsScroll(div: HTMLElement, database: {blueprints: {[k
|
||||
if (database !== null) {
|
||||
var blueprints: {[key: string]: UnitBlueprint} = database.blueprints;
|
||||
|
||||
for (let key in blueprints) {
|
||||
for (let key of Object.keys(blueprints).sort((a, b) => a.localeCompare(b, undefined, {sensitivity: 'base'}))) {
|
||||
var rowDiv = document.createElement("div");
|
||||
scrollDiv.appendChild(rowDiv);
|
||||
|
||||
@@ -186,6 +187,7 @@ export function addLoadoutsScroll(div: HTMLElement, loadouts: LoadoutBlueprint[]
|
||||
var loadoutsEl = document.createElement("div");
|
||||
loadoutsEl.classList.add("dm-scroll-container", "dm-loadout-container")
|
||||
|
||||
loadouts.sort((a: LoadoutBlueprint, b: LoadoutBlueprint) => a.name.localeCompare(b.name, undefined, {sensitivity: 'base'}));
|
||||
loadouts.forEach((loadout: LoadoutBlueprint, index: number) => {
|
||||
var rowDiv = document.createElement("div");
|
||||
loadoutsEl.appendChild(rowDiv);
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
}
|
||||
|
||||
.dm-content-container:nth-of-type(1) {
|
||||
width: 200px;
|
||||
width: 300px;
|
||||
}
|
||||
|
||||
.dm-content-container:nth-of-type(2) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"name": "A-10C_2",
|
||||
"coalition": "blue",
|
||||
"era": "Late Cold War",
|
||||
"label": "A-10C Warthog test",
|
||||
"label": "A-10C Warthog",
|
||||
"shortLabel": "10",
|
||||
"loadouts": [
|
||||
{
|
||||
|
||||
@@ -6230,7 +6230,7 @@
|
||||
"era": "",
|
||||
"label": "SPAAA LC with ZU-23",
|
||||
"shortLabel": "SPAAA LC with ZU-23",
|
||||
"type": "AirDefence",
|
||||
"type": "AAA",
|
||||
"enabled": true,
|
||||
"liveries": {}
|
||||
},
|
||||
@@ -6510,7 +6510,7 @@
|
||||
"era": "",
|
||||
"label": "AAA Bofors 40mm",
|
||||
"shortLabel": "AAA Bofors 40mm",
|
||||
"type": "AirDefence",
|
||||
"type": "AAA",
|
||||
"enabled": true,
|
||||
"liveries": {}
|
||||
},
|
||||
@@ -6620,9 +6620,11 @@
|
||||
"era": "",
|
||||
"label": "AAA 8,8cm Flak 18",
|
||||
"shortLabel": "AAA 8,8cm Flak 18",
|
||||
"type": "AirDefence",
|
||||
"type": "AAA",
|
||||
"enabled": true,
|
||||
"liveries": {}
|
||||
"liveries": {},
|
||||
"aimTime": 20,
|
||||
"shotsToFire": 1
|
||||
},
|
||||
"Pz_IV_H": {
|
||||
"name": "Pz_IV_H",
|
||||
@@ -6904,46 +6906,6 @@
|
||||
"enabled": true,
|
||||
"liveries": {}
|
||||
},
|
||||
"flak30": {
|
||||
"name": "flak30",
|
||||
"coalition": "",
|
||||
"era": "",
|
||||
"label": "AAA Flak 38 20mm",
|
||||
"shortLabel": "AAA Flak 38 20mm",
|
||||
"type": "AirDefence",
|
||||
"enabled": true,
|
||||
"liveries": {}
|
||||
},
|
||||
"flak36": {
|
||||
"name": "flak36",
|
||||
"coalition": "",
|
||||
"era": "",
|
||||
"label": "AAA 8,8cm Flak 36",
|
||||
"shortLabel": "AAA 8,8cm Flak 36",
|
||||
"type": "AirDefence",
|
||||
"enabled": true,
|
||||
"liveries": {}
|
||||
},
|
||||
"flak37": {
|
||||
"name": "flak37",
|
||||
"coalition": "",
|
||||
"era": "",
|
||||
"label": "AAA 8,8cm Flak 37",
|
||||
"shortLabel": "AAA 8,8cm Flak 37",
|
||||
"type": "AirDefence",
|
||||
"enabled": true,
|
||||
"liveries": {}
|
||||
},
|
||||
"flak38": {
|
||||
"name": "flak38",
|
||||
"coalition": "",
|
||||
"era": "",
|
||||
"label": "AAA Flak-Vierling 38 Quad 20mm",
|
||||
"shortLabel": "AAA Flak-Vierling 38 Quad 20mm",
|
||||
"type": "AirDefence",
|
||||
"enabled": true,
|
||||
"liveries": {}
|
||||
},
|
||||
"KDO_Mod40": {
|
||||
"name": "KDO_Mod40",
|
||||
"coalition": "",
|
||||
@@ -6960,7 +6922,7 @@
|
||||
"era": "",
|
||||
"label": "SL Flakscheinwerfer 37",
|
||||
"shortLabel": "SL Flakscheinwerfer 37",
|
||||
"type": "AirDefence",
|
||||
"type": "AAA",
|
||||
"enabled": true,
|
||||
"liveries": {}
|
||||
},
|
||||
@@ -6970,7 +6932,7 @@
|
||||
"era": "",
|
||||
"label": "Maschinensatz 33 Gen",
|
||||
"shortLabel": "Maschinensatz 33 Gen",
|
||||
"type": "AirDefence",
|
||||
"type": "AAA",
|
||||
"enabled": true,
|
||||
"liveries": {}
|
||||
},
|
||||
@@ -7024,16 +6986,6 @@
|
||||
"enabled": true,
|
||||
"liveries": {}
|
||||
},
|
||||
"flak41": {
|
||||
"name": "flak41",
|
||||
"coalition": "",
|
||||
"era": "",
|
||||
"label": "AAA 8,8cm Flak 41",
|
||||
"shortLabel": "AAA 8,8cm Flak 41",
|
||||
"type": "AirDefence",
|
||||
"enabled": true,
|
||||
"liveries": {}
|
||||
},
|
||||
"v1_launcher": {
|
||||
"name": "v1_launcher",
|
||||
"coalition": "",
|
||||
@@ -7160,7 +7112,7 @@
|
||||
"era": "",
|
||||
"label": "AAA QF 3.7\"",
|
||||
"shortLabel": "AAA QF 3.7\"",
|
||||
"type": "AirDefence",
|
||||
"type": "AAA",
|
||||
"enabled": true,
|
||||
"liveries": {}
|
||||
},
|
||||
@@ -7270,7 +7222,7 @@
|
||||
"era": "",
|
||||
"label": "AAA M45 Quadmount HB 12.7mm",
|
||||
"shortLabel": "AAA M45 Quadmount HB 12.7mm",
|
||||
"type": "AirDefence",
|
||||
"type": "AAA",
|
||||
"enabled": true,
|
||||
"liveries": {}
|
||||
},
|
||||
@@ -7280,7 +7232,7 @@
|
||||
"era": "",
|
||||
"label": "AAA M1 37mm",
|
||||
"shortLabel": "AAA M1 37mm",
|
||||
"type": "AirDefence",
|
||||
"type": "AAA",
|
||||
"enabled": true,
|
||||
"liveries": {}
|
||||
},
|
||||
|
||||
@@ -151,11 +151,12 @@ export const visibilityControlsTooltips: string[] = ["Toggle human players visib
|
||||
export const IADSTypes = ["AAA", "MANPADS", "SAM Site", "Radar"];
|
||||
export const IADSDensities: {[key: string]: number}= {"AAA": 0.8, "MANPADS": 0.3, "SAM Site": 0.1, "Radar": 0.05};
|
||||
|
||||
export const SHOW_CONTACT_LINES = "Show unit contact lines";
|
||||
export const HIDE_GROUP_MEMBERS = "Hide group members when zoomed out";
|
||||
export const SHOW_UNIT_LABELS = "Show unit labels";
|
||||
export const SHOW_UNIT_PATHS = "Show unit paths";
|
||||
export const SHOW_UNIT_TARGETS = "Show unit targets";
|
||||
export const SHOW_UNIT_CONTACTS = "Show selected units contact lines";
|
||||
export const SHOW_UNITS_RINGS = "Show selected units threat range rings";
|
||||
export const SHOW_UNIT_PATHS = "Show selected unit paths";
|
||||
export const SHOW_UNIT_TARGETS = "Show selected unit targets";
|
||||
|
||||
export enum DataIndexes {
|
||||
startOfData = 0,
|
||||
|
||||
@@ -12,7 +12,7 @@ import { DestinationPreviewMarker } from "./markers/destinationpreviewmarker";
|
||||
import { TemporaryUnitMarker } from "./markers/temporaryunitmarker";
|
||||
import { ClickableMiniMap } from "./clickableminimap";
|
||||
import { SVGInjector } from '@tanem/svg-injector'
|
||||
import { mapLayers, mapBounds, minimapBoundaries, IDLE, COALITIONAREA_DRAW_POLYGON, visibilityControls, visibilityControlsTooltips, MOVE_UNIT, SHOW_CONTACT_LINES, HIDE_GROUP_MEMBERS, SHOW_UNIT_PATHS, SHOW_UNIT_TARGETS, visibilityControlsTypes, SHOW_UNIT_LABELS } from "../constants/constants";
|
||||
import { mapLayers, mapBounds, minimapBoundaries, IDLE, COALITIONAREA_DRAW_POLYGON, visibilityControls, visibilityControlsTooltips, MOVE_UNIT, SHOW_UNIT_CONTACTS, HIDE_GROUP_MEMBERS, SHOW_UNIT_PATHS, SHOW_UNIT_TARGETS, visibilityControlsTypes, SHOW_UNIT_LABELS } from "../constants/constants";
|
||||
import { TargetMarker } from "./markers/targetmarker";
|
||||
import { CoalitionArea } from "./coalitionarea/coalitionarea";
|
||||
import { CoalitionAreaContextMenu } from "../contextmenus/coalitionareacontextmenu";
|
||||
@@ -209,7 +209,7 @@ export class Map extends L.Map {
|
||||
document.querySelector("#unit-visibility-control")?.append(...this.#optionButtons["visibility"]);
|
||||
|
||||
/* Create the checkboxes to select the advanced visibility options */
|
||||
this.addVisibilityOption(SHOW_CONTACT_LINES, false);
|
||||
this.addVisibilityOption(SHOW_UNIT_CONTACTS, false);
|
||||
this.addVisibilityOption(HIDE_GROUP_MEMBERS, true);
|
||||
this.addVisibilityOption(SHOW_UNIT_PATHS, true);
|
||||
this.addVisibilityOption(SHOW_UNIT_TARGETS, true);
|
||||
@@ -528,39 +528,38 @@ export class Map extends L.Map {
|
||||
}
|
||||
|
||||
this.hideMapContextMenu();
|
||||
if (!this.#shiftKey) {
|
||||
if (this.#state === IDLE) {
|
||||
if (this.#state == IDLE) {
|
||||
this.showMapContextMenu(e.originalEvent.x, e.originalEvent.y, e.latlng);
|
||||
var clickedCoalitionArea = null;
|
||||
if (this.#state === IDLE) {
|
||||
if (this.#state == IDLE) {
|
||||
this.showMapContextMenu(e.originalEvent.x, e.originalEvent.y, e.latlng);
|
||||
var clickedCoalitionArea = null;
|
||||
|
||||
/* Coalition areas are ordered in the #coalitionAreas array according to their zindex. Select the upper one */
|
||||
for (let coalitionArea of this.#coalitionAreas) {
|
||||
if (coalitionArea.getBounds().contains(e.latlng)) {
|
||||
if (coalitionArea.getSelected())
|
||||
clickedCoalitionArea = coalitionArea;
|
||||
else
|
||||
this.getMapContextMenu().setCoalitionArea(coalitionArea);
|
||||
}
|
||||
/* Coalition areas are ordered in the #coalitionAreas array according to their zindex. Select the upper one */
|
||||
for (let coalitionArea of this.#coalitionAreas) {
|
||||
if (coalitionArea.getBounds().contains(e.latlng)) {
|
||||
if (coalitionArea.getSelected())
|
||||
clickedCoalitionArea = coalitionArea;
|
||||
else
|
||||
this.getMapContextMenu().setCoalitionArea(coalitionArea);
|
||||
}
|
||||
if (clickedCoalitionArea)
|
||||
this.showCoalitionAreaContextMenu(e.originalEvent.x, e.originalEvent.y, e.latlng, clickedCoalitionArea);
|
||||
}
|
||||
}
|
||||
else if (this.#state === MOVE_UNIT) {
|
||||
if (!e.originalEvent.ctrlKey) {
|
||||
getApp().getUnitsManager().selectedUnitsClearDestinations();
|
||||
}
|
||||
getApp().getUnitsManager().selectedUnitsAddDestination(this.#computeDestinationRotation && this.#destinationRotationCenter != null ? this.#destinationRotationCenter : e.latlng, this.#shiftKey, this.#destinationGroupRotation)
|
||||
|
||||
this.#destinationGroupRotation = 0;
|
||||
this.#destinationRotationCenter = null;
|
||||
this.#computeDestinationRotation = false;
|
||||
}
|
||||
else {
|
||||
this.setState(IDLE);
|
||||
if (clickedCoalitionArea)
|
||||
this.showCoalitionAreaContextMenu(e.originalEvent.x, e.originalEvent.y, e.latlng, clickedCoalitionArea);
|
||||
}
|
||||
}
|
||||
else if (this.#state === MOVE_UNIT) {
|
||||
if (!e.originalEvent.ctrlKey) {
|
||||
getApp().getUnitsManager().selectedUnitsClearDestinations();
|
||||
}
|
||||
getApp().getUnitsManager().selectedUnitsAddDestination(this.#computeDestinationRotation && this.#destinationRotationCenter != null ? this.#destinationRotationCenter : e.latlng, this.#shiftKey, this.#destinationGroupRotation)
|
||||
|
||||
this.#destinationGroupRotation = 0;
|
||||
this.#destinationRotationCenter = null;
|
||||
this.#computeDestinationRotation = false;
|
||||
}
|
||||
else {
|
||||
this.setState(IDLE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#onSelectionStart(e: any) {
|
||||
@@ -593,12 +592,12 @@ export class Map extends L.Map {
|
||||
}
|
||||
|
||||
this.#longPressTimer = window.setTimeout(() => {
|
||||
if (e.originalEvent.button != 2 || e.originalEvent.ctrlKey || e.originalEvent.shiftKey)
|
||||
return;
|
||||
|
||||
this.hideMapContextMenu();
|
||||
this.#longPressHandled = true;
|
||||
|
||||
if (e.originalEvent.button != 2 || e.originalEvent.ctrlKey || e.originalEvent.shiftKey)
|
||||
return;
|
||||
|
||||
var options: { [key: string]: { text: string, tooltip: string } } = {};
|
||||
const selectedUnits = getApp().getUnitsManager().getSelectedUnits();
|
||||
const selectedUnitTypes = getApp().getUnitsManager().getSelectedUnitsCategories();
|
||||
|
||||
@@ -204,10 +204,16 @@ export function mToNm(m: number) {
|
||||
return m * 0.000539957;
|
||||
}
|
||||
|
||||
export function nmToM(nm: number) {
|
||||
return nm / 0.000539957;
|
||||
}
|
||||
|
||||
|
||||
export function nmToFt(nm: number) {
|
||||
return nm * 6076.12;
|
||||
}
|
||||
|
||||
|
||||
export function polyContains(latlng: LatLng, polygon: Polygon) {
|
||||
var poly = polygon.toGeoJSON();
|
||||
return turf.inside(turf.point([latlng.lng, latlng.lat]), poly);
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Marker, LatLng, Polyline, Icon, DivIcon, CircleMarker, Map, Point } from 'leaflet';
|
||||
import { Marker, LatLng, Polyline, Icon, DivIcon, CircleMarker, Map, Point, Circle } from 'leaflet';
|
||||
import { getApp } from '..';
|
||||
import { enumToCoalition, enumToEmissioNCountermeasure, getMarkerCategoryByName, enumToROE, enumToReactionToThreat, enumToState, getUnitDatabaseByCategory, mToFt, msToKnots, rad2deg, bearing, deg2rad, ftToM, getGroundElevation, coalitionToEnum } from '../other/utils';
|
||||
import { enumToCoalition, enumToEmissioNCountermeasure, getMarkerCategoryByName, enumToROE, enumToReactionToThreat, enumToState, getUnitDatabaseByCategory, mToFt, msToKnots, rad2deg, bearing, deg2rad, ftToM, getGroundElevation, coalitionToEnum, nmToFt, nmToM } from '../other/utils';
|
||||
import { CustomMarker } from '../map/markers/custommarker';
|
||||
import { SVGInjector } from '@tanem/svg-injector';
|
||||
import { UnitDatabase } from './databases/unitdatabase';
|
||||
import { TargetMarker } from '../map/markers/targetmarker';
|
||||
import { DLINK, DataIndexes, GAME_MASTER, HIDE_GROUP_MEMBERS, IDLE, IRST, MOVE_UNIT, OPTIC, RADAR, ROEs, RWR, SHOW_CONTACT_LINES, SHOW_UNIT_PATHS, SHOW_UNIT_TARGETS, VISUAL, emissionsCountermeasures, reactionsToThreat, states } from '../constants/constants';
|
||||
import { DLINK, DataIndexes, GAME_MASTER, HIDE_GROUP_MEMBERS, IDLE, IRST, MOVE_UNIT, OPTIC, RADAR, ROEs, RWR, SHOW_UNIT_CONTACTS, SHOW_UNITS_RINGS, SHOW_UNIT_PATHS, SHOW_UNIT_TARGETS, VISUAL, emissionsCountermeasures, reactionsToThreat, states } from '../constants/constants';
|
||||
import { DataExtractor } from '../server/dataextractor';
|
||||
import { groundUnitDatabase } from './databases/groundunitdatabase';
|
||||
import { navyUnitDatabase } from './databases/navyunitdatabase';
|
||||
@@ -86,7 +86,8 @@ export class Unit extends CustomMarker {
|
||||
#waitingForDoubleClick: boolean = false;
|
||||
#pathMarkers: Marker[] = [];
|
||||
#pathPolyline: Polyline;
|
||||
#contactsPolylines: Polyline[];
|
||||
#contactsPolylines: Polyline[] = [];
|
||||
#rangeRingCircles: Circle[] = [];
|
||||
#miniMapMarker: CircleMarker | null = null;
|
||||
#targetPositionMarker: TargetMarker;
|
||||
#targetPositionPolyline: Polyline;
|
||||
@@ -148,7 +149,6 @@ export class Unit extends CustomMarker {
|
||||
|
||||
this.#pathPolyline = new Polyline([], { color: '#2d3e50', weight: 3, opacity: 0.5, smoothFactor: 1 });
|
||||
this.#pathPolyline.addTo(getApp().getMap());
|
||||
this.#contactsPolylines = [];
|
||||
this.#targetPositionMarker = new TargetMarker(new LatLng(0, 0));
|
||||
this.#targetPositionPolyline = new Polyline([], { color: '#FF0000', weight: 3, opacity: 0.5, smoothFactor: 1 });
|
||||
|
||||
@@ -251,6 +251,7 @@ export class Unit extends CustomMarker {
|
||||
drawLines() {
|
||||
this.#drawPath();
|
||||
this.#drawContacts();
|
||||
this.#drawRanges();
|
||||
this.#drawTarget();
|
||||
}
|
||||
|
||||
@@ -1093,7 +1094,7 @@ export class Unit extends CustomMarker {
|
||||
|
||||
#drawContacts() {
|
||||
this.#clearContacts();
|
||||
if (getApp().getMap().getVisibilityOptions()[SHOW_CONTACT_LINES]) {
|
||||
if (getApp().getMap().getVisibilityOptions()[SHOW_UNIT_CONTACTS]) {
|
||||
for (let index in this.#contacts) {
|
||||
var contactData = this.#contacts[index];
|
||||
var contact: Unit | Weapon | null;
|
||||
@@ -1133,12 +1134,31 @@ export class Unit extends CustomMarker {
|
||||
}
|
||||
}
|
||||
|
||||
#drawRanges() {
|
||||
this.#clearRanges();
|
||||
if (getApp().getMap().getVisibilityOptions()[SHOW_UNITS_RINGS]) {
|
||||
var engagementRange = this.getDatabase()?.getByName(this.getName())?.engagementRange;
|
||||
var acquisitionRange = this.getDatabase()?.getByName(this.getName())?.acquisitionRange
|
||||
if (engagementRange) {
|
||||
var rangeCircle = new Circle(this.getPosition(), { radius: nmToM(engagementRange), color: "#FF0000", weight: 3, opacity: 1 });
|
||||
rangeCircle.addTo(getApp().getMap());
|
||||
this.#rangeRingCircles.push(rangeCircle)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#clearContacts() {
|
||||
for (let index in this.#contactsPolylines) {
|
||||
getApp().getMap().removeLayer(this.#contactsPolylines[index])
|
||||
}
|
||||
}
|
||||
|
||||
#clearRanges() {
|
||||
for (let index in this.#rangeRingCircles) {
|
||||
getApp().getMap().removeLayer(this.#rangeRingCircles[index])
|
||||
}
|
||||
}
|
||||
|
||||
#drawTarget() {
|
||||
if (this.#targetPosition.lat != 0 && this.#targetPosition.lng != 0 && getApp().getMap().getVisibilityOptions()[SHOW_UNIT_PATHS]) {
|
||||
this.#drawTargetPosition(this.#targetPosition);
|
||||
|
||||
Reference in New Issue
Block a user