diff --git a/frontend/react/src/constants/constants.ts b/frontend/react/src/constants/constants.ts index 2174cc44..3e74f4cd 100644 --- a/frontend/react/src/constants/constants.ts +++ b/frontend/react/src/constants/constants.ts @@ -96,13 +96,8 @@ export const states: string[] = [ UnitState.LAND_AT_POINT, ]; -export enum RADAR_STATES { - RED = 'red', - GREEN = 'green', - AUTO = 'auto' -} - export const ROEs: string[] = ["free", "designated", "", "return", "hold"]; +export const alarmStates: string[] = ["green", "auto", "red"]; export const reactionsToThreat: string[] = ["none", "manoeuvre", "passive", "evade"]; export const emissionsCountermeasures: string[] = ["silent", "attack", "defend", "free"]; diff --git a/frontend/react/src/interfaces.ts b/frontend/react/src/interfaces.ts index d8f892de..1c0d3726 100644 --- a/frontend/react/src/interfaces.ts +++ b/frontend/react/src/interfaces.ts @@ -213,6 +213,7 @@ export interface UnitData { markerCategory: string; ID: number; alive: boolean; + alarmState: AlarmState | undefined; human: boolean; controlled: boolean; coalition: string; @@ -395,4 +396,10 @@ export interface Drawing { hiddenOnPlanner?: boolean; file?: string; scale?: number; +} + +export enum AlarmState { + AUTO = 'auto', + GREEN = 'green', + RED = 'red' } \ No newline at end of file diff --git a/frontend/react/src/map/markers/stylesheets/units.css b/frontend/react/src/map/markers/stylesheets/units.css index da063531..9583e1f4 100644 --- a/frontend/react/src/map/markers/stylesheets/units.css +++ b/frontend/react/src/map/markers/stylesheets/units.css @@ -631,12 +631,12 @@ left: 35px; bottom: 8px; } -.unit[data-radar-state="GREEN"] .unit-radar-state { +.unit[data-radar-state="green"] .unit-radar-state { border: 1px solid white; background: rgb(0, 226, 0); } -.unit[data-radar-state="RED"] .unit-radar-state { +.unit[data-radar-state="red"] .unit-radar-state { border: 1px solid white; background: red; } diff --git a/frontend/react/src/other/utils.ts b/frontend/react/src/other/utils.ts index b4506c10..68f5f004 100644 --- a/frontend/react/src/other/utils.ts +++ b/frontend/react/src/other/utils.ts @@ -547,7 +547,7 @@ export function roundToNearestFive(number) { return Math.round(number / 5) * 5; } -export function toDCSFormationOffset(offset: {x: number, y: number, z: number}) { +export function toDCSFormationOffset(offset: { x: number, y: number, z: number }) { // X: front-rear, positive front // Y: top-bottom, positive top // Z: left-right, positive right @@ -555,7 +555,7 @@ export function toDCSFormationOffset(offset: {x: number, y: number, z: number}) return { x: -offset.y, y: offset.z, z: offset.x }; } -export function fromDCSFormationOffset(offset: {x: number, y: number, z: number}) { +export function fromDCSFormationOffset(offset: { x: number, y: number, z: number }) { return { x: offset.z, y: -offset.x, z: offset.y }; } @@ -649,10 +649,10 @@ export function normalizeAngle(angle: number): number { } export function decimalToRGBA(decimal: number): string { - const r = (decimal >>> 24) & 0xff; - const g = (decimal >>> 16) & 0xff; - const b = (decimal >>> 8) & 0xff; - const a = (decimal & 0xff) / 255; + const r = (decimal >>> 24) & 0xff; + const g = (decimal >>> 16) & 0xff; + const b = (decimal >>> 8) & 0xff; + const a = (decimal & 0xff) / 255; return `rgba(${r}, ${g}, ${b}, ${a.toFixed(2)})`; } diff --git a/frontend/react/src/ui/panels/unitcontrolmenu.tsx b/frontend/react/src/ui/panels/unitcontrolmenu.tsx index 56d810ba..369c09cf 100644 --- a/frontend/react/src/ui/panels/unitcontrolmenu.tsx +++ b/frontend/react/src/ui/panels/unitcontrolmenu.tsx @@ -8,6 +8,7 @@ import { OlButtonGroup, OlButtonGroupItem } from "../components/olbuttongroup"; import { OlCheckbox } from "../components/olcheckbox"; import { ROEs, + alarmStates, altitudeIncrements, emissionsCountermeasures, maxAltitudeValues, @@ -53,7 +54,7 @@ import { OlSearchBar } from "../components/olsearchbar"; import { OlDropdown, OlDropdownItem } from "../components/oldropdown"; import { FaRadio, FaVolumeHigh } from "react-icons/fa6"; import { OlNumberInput } from "../components/olnumberinput"; -import { GeneralSettings, Radio, TACAN } from "../../interfaces"; +import { AlarmState, GeneralSettings, Radio, TACAN } from "../../interfaces"; import { OlStringInput } from "../components/olstringinput"; import { OlFrequencyInput } from "../components/olfrequencyinput"; import { UnitSink } from "../../audio/unitsink"; @@ -85,6 +86,7 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { radio: undefined as undefined | Radio, TACAN: undefined as undefined | TACAN, generalSettings: undefined as undefined | GeneralSettings, + alarmState: undefined as undefined | AlarmState }; } @@ -165,6 +167,7 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { onOff: (unit: Unit) => unit.getOnOff(), radio: (unit: Unit) => unit.getRadio(), TACAN: (unit: Unit) => unit.getTACAN(), + alarmState: (unit: Unit) => unit.getAlarmState(), generalSettings: (unit: Unit) => unit.getGeneralSettings(), isAudioSink: (unit: Unit) => { return ( @@ -818,6 +821,82 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { )} {/* ============== Rules of Engagement END ============== */} + + {/* ============== Alarm state selector START ============== */} + {selectedUnitsData.alarmState && +