diff --git a/frontend/react/src/events.ts b/frontend/react/src/events.ts index b8693d13..a6f4f9f3 100644 --- a/frontend/react/src/events.ts +++ b/frontend/react/src/events.ts @@ -892,3 +892,19 @@ export class WeaponsRefreshedEvent { if (DEBUG) console.log(`Event ${this.name} dispatched`); } } + +export class CoordinatesFreezeEvent { + static on(callback: () => void) { + document.addEventListener( + this.name, + (ev: CustomEventInit) => { + callback(); + } + ) + } + + static dispatch() { + document.dispatchEvent(new CustomEvent(this.name)); + if (DEBUG) console.log(`Event ${this.name} dispatched`); + } +} diff --git a/frontend/react/src/map/map.ts b/frontend/react/src/map/map.ts index 48ec8bde..d146c1c9 100644 --- a/frontend/react/src/map/map.ts +++ b/frontend/react/src/map/map.ts @@ -49,6 +49,7 @@ import { ConfigLoadedEvent, ContextActionChangedEvent, ContextActionSetChangedEvent, + CoordinatesFreezeEvent, HiddenTypesChangedEvent, MapContextMenuRequestEvent, MapOptionsChangedEvent, @@ -509,7 +510,7 @@ export class Map extends L.Map { code: "ShiftLeft", altKey: false, ctrlKey: false, - }); + }) } setLayerName(layerName: string) { @@ -1031,6 +1032,7 @@ export class Map extends L.Map { } #onLeftShortClick(e: L.LeafletMouseEvent) { + CoordinatesFreezeEvent.dispatch(); if (Date.now() - this.#leftMouseDownEpoch < SHORT_PRESS_MILLISECONDS) { this.#debounceTimeout = window.setTimeout(() => { if (!this.#isSelecting) { diff --git a/frontend/react/src/other/utils.ts b/frontend/react/src/other/utils.ts index df0b6577..4b39e816 100644 --- a/frontend/react/src/other/utils.ts +++ b/frontend/react/src/other/utils.ts @@ -83,6 +83,13 @@ export function ConvertDDToDMS(D: number, lng: boolean) { else return zeroPad(deg, 2) + "°" + zeroPad(min, 2) + "'" + zeroPad(sec, 2) + "." + zeroPad(dec, 2) + '"'; } +export function DDToDDM(decimalDegrees) { + const degrees = Math.trunc(decimalDegrees); + const minutes = Math.abs((decimalDegrees - degrees) * 60); + + return `${Math.abs(degrees)}° ${minutes.toFixed(4)}'`; +} + export function deg2rad(deg: number) { var pi = Math.PI; return deg * (pi / 180); @@ -762,4 +769,8 @@ export function secondsToTimeString(seconds: number) { const secs = Math.floor(seconds % 60); return `${zeroPad(hours, 2)}:${zeroPad(minutes, 2)}:${zeroPad(secs, 2)}`; +} + +export function isTrustedEnvironment() { + return window.location.protocol === "https:"; } \ No newline at end of file diff --git a/frontend/react/src/ui/components/ollocation.tsx b/frontend/react/src/ui/components/ollocation.tsx index 34e142f5..f5ab162a 100644 --- a/frontend/react/src/ui/components/ollocation.tsx +++ b/frontend/react/src/ui/components/ollocation.tsx @@ -1,8 +1,8 @@ import React, { useState } from "react"; import { LatLng } from "leaflet"; -import { ConvertDDToDMS, latLngToMGRS, latLngToUTM, zeroAppend } from "../../other/utils"; +import { ConvertDDToDMS, DDToDDM, latLngToMGRS, latLngToUTM, zeroAppend } from "../../other/utils"; -export function OlLocation(props: { location: LatLng; className?: string; referenceSystem?: string; onClick?: () => void }) { +export function OlLocation(props: { location: LatLng; className?: string; referenceSystem?: string; onClick?: () => void; onRefSystemChange?: (refSystem: string) => any }) { const [referenceSystem, setReferenceSystem] = props.referenceSystem ? [props.referenceSystem, () => {}] : useState("LatLngDec"); const MGRS = latLngToMGRS(props.location.lat, props.location.lng, 6); if (referenceSystem === "MGRS") { @@ -17,6 +17,7 @@ export function OlLocation(props: { location: LatLng; className?: string; refere ? props.onClick : (ev) => { setReferenceSystem("LatLngDec"); + props.onRefSystemChange ? props.onRefSystemChange("LatLngDec") : null; ev.stopPropagation(); } } @@ -44,6 +45,7 @@ export function OlLocation(props: { location: LatLng; className?: string; refere ? props.onClick : (ev) => { setReferenceSystem("LatLngDMS"); + props.onRefSystemChange ? props.onRefSystemChange("LatLngDMS") : null; ev.stopPropagation(); } } @@ -82,7 +84,8 @@ export function OlLocation(props: { location: LatLng; className?: string; refere props.onClick ? props.onClick : (ev) => { - setReferenceSystem("MGRS"); + setReferenceSystem("LatLngDDM"); + props.onRefSystemChange ? props.onRefSystemChange("LatLngDDM") : null; ev.stopPropagation(); } } @@ -109,6 +112,46 @@ export function OlLocation(props: { location: LatLng; className?: string; refere ); + } else if (referenceSystem === "LatLngDDM") { + return ( +
{ + setReferenceSystem("MGRS"); + props.onRefSystemChange ? props.onRefSystemChange("MGRS") : null; + ev.stopPropagation(); + } + } + > +
+ + {props.location.lat >= 0 ? "N" : "S"} + + {DDToDDM(props.location.lat)} +
+
+ + {props.location.lng >= 0 ? "E" : "W"} + + {DDToDDM(props.location.lng)} +
+
+ ); } else { } } diff --git a/frontend/react/src/ui/modals/keybindmodal.tsx b/frontend/react/src/ui/modals/keybindmodal.tsx index fd98864d..bd4e8a65 100644 --- a/frontend/react/src/ui/modals/keybindmodal.tsx +++ b/frontend/react/src/ui/modals/keybindmodal.tsx @@ -62,7 +62,7 @@ export function KeybindModal(props: { open: boolean }) { return ( -
+
{inUseShortcuts.map((shortcut) => ( - {shortcut.getOptions().label} + {shortcut.getOptions().label} ))}
@@ -105,7 +105,7 @@ export function KeybindModal(props: { open: boolean }) {
)} -
+
{shortcut && (
@@ -959,9 +935,7 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { {" "} {" "} Full evasion: the unit will try to evade the threat both manoeuvering and using counter-measures
@@ -1016,9 +990,7 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { {" "} {" "} Radio silence: No radar or ECM will be used @@ -1026,9 +998,7 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { {" "} {" "} Defensive: The unit will turn radar and ECM on only when threatened @@ -1036,9 +1006,7 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { {" "} {" "} Attack: The unit will use radar and ECM when engaging other units @@ -1046,9 +1014,7 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { {" "} {" "} Free: the unit will use the radar and ECM all the time @@ -1269,9 +1235,7 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) {
@@ -1451,9 +1415,7 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { {/* ============== Operate as toggle START ============== */} {selectedUnits.every((unit) => unit.getCoalition() === "neutral") && (
void }) { >
Barrel height:{" "}
void }) { }} >
m
Muzzle velocity:{" "}
void }) { }} >
m/s
Aim time:{" "}
void }) { }} >
s
Shots to fire:{" "}
void }) {
Shots base interval:{" "}
void }) { }} >
s
Shots base scatter:{" "}
void }) { }} >
deg
Engagement range:{" "}
void }) { }} >
m
Targeting range:{" "}
void }) { }} >
m
Aim method range:{" "}
void }) { }} >
m
Acquisition range:{" "}
void }) { }} >
m
diff --git a/frontend/react/src/unit/unit.ts b/frontend/react/src/unit/unit.ts index eece5f48..1bb25f9d 100644 --- a/frontend/react/src/unit/unit.ts +++ b/frontend/react/src/unit/unit.ts @@ -60,6 +60,7 @@ import * as turf from "@turf/turf"; import { Carrier } from "../mission/carrier"; import { ContactsUpdatedEvent, + CoordinatesFreezeEvent, HiddenTypesChangedEvent, MapOptionsChangedEvent, UnitContextMenuRequestEvent, @@ -1611,6 +1612,7 @@ export abstract class Unit extends CustomMarker { } #onLeftShortClick(e: any) { + CoordinatesFreezeEvent.dispatch(); DomEvent.stop(e); DomEvent.preventDefault(e); e.originalEvent.stopImmediatePropagation();