From 66f08e8fcea1637f88aab535bb1e99e42985f1fa Mon Sep 17 00:00:00 2001 From: Pax1601 Date: Mon, 31 Jul 2023 14:08:36 +0200 Subject: [PATCH] Fixed ROEs --- client/demo.js | 18 +++++++++--------- client/src/constants/constants.ts | 2 +- client/src/map/map.ts | 4 +++- client/src/panels/unitcontrolpanel.ts | 2 +- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/client/demo.js b/client/demo.js index 11cd10a4..3550e864 100644 --- a/client/demo.js +++ b/client/demo.js @@ -8,7 +8,7 @@ const DEMO_UNIT_DATA = { formationOffset: { x: 0, y: 0, z: 0 }, targetID: 2, targetPosition: { lat: 0, lng: 0, alt: 0 }, - ROE: 2, + ROE: 1, reactionToThreat: 1, emissionsCountermeasures: 1, TACAN: { isOn: false, XY: 'Y', callsign: 'TKR', channel: 40 }, @@ -24,7 +24,7 @@ const DEMO_UNIT_DATA = { formationOffset: { x: 0, y: 0, z: 0 }, targetID: 0, targetPosition: { lat: 0, lng: 0, alt: 0 }, - ROE: 2, + ROE: 1, reactionToThreat: 1, emissionsCountermeasures: 1, TACAN: { isOn: false, XY: 'Y', callsign: 'TKR', channel: 40 }, @@ -39,7 +39,7 @@ const DEMO_UNIT_DATA = { formationOffset: { x: 0, y: 0, z: 0 }, targetID: 0, targetPosition: { lat: 0, lng: 0, alt: 0 }, - ROE: 2, + ROE: 1, reactionToThreat: 1, emissionsCountermeasures: 1, TACAN: { isOn: false, XY: 'Y', callsign: 'TKR', channel: 40 }, @@ -54,7 +54,7 @@ const DEMO_UNIT_DATA = { formationOffset: { x: 0, y: 0, z: 0 }, targetID: 0, targetPosition: { lat: 0, lng: 0, alt: 0 }, - ROE: 2, + ROE: 1, reactionToThreat: 1, emissionsCountermeasures: 1, TACAN: { isOn: false, XY: 'Y', callsign: 'TKR', channel: 40 }, @@ -64,13 +64,13 @@ const DEMO_UNIT_DATA = { contacts: [{ID: 1001, detectionMethod: 16}], activePath: [ ], isLeader: true - }, ["5"]:{ category: "GroundUnit", alive: true, human: false, controlled: true, coalition: 1, country: 0, name: "Gepard", unitName: "Cool guy 2-2", groupName: "Cool group 4", state: 1, task: "Being cool", + }, ["5"]:{ category: "GroundUnit", alive: true, human: false, controlled: true, coalition: 1, country: 0, name: "S_75M_Volhov", unitName: "Cool guy 2-2", groupName: "Cool group 4", state: 1, task: "Being cool", hasTask: false, position: { lat: 37.21, lng: -116.1, alt: 1000 }, speed: 200, heading: 315 * Math.PI / 180, isTanker: false, isAWACS: false, onOff: true, followRoads: false, fuel: 50, desiredSpeed: 300, desiredSpeedType: 1, desiredAltitude: 1000, desiredAltitudeType: 1, leaderID: 0, formationOffset: { x: 0, y: 0, z: 0 }, targetID: 0, targetPosition: { lat: 0, lng: 0, alt: 0 }, - ROE: 2, + ROE: 1, reactionToThreat: 1, emissionsCountermeasures: 1, TACAN: { isOn: false, XY: 'Y', callsign: 'TKR', channel: 40 }, @@ -99,9 +99,9 @@ class DemoDataGenerator { app.use('/demo', basicAuth({ users: { - 'admin': 'socks', - 'blue': 'bluesocks', - 'red': 'redsocks' + 'admin': 'password', + 'blue': 'bluepassword', + 'red': 'redpassword' }, })) diff --git a/client/src/constants/constants.ts b/client/src/constants/constants.ts index fc208481..8d29bbb7 100644 --- a/client/src/constants/constants.ts +++ b/client/src/constants/constants.ts @@ -13,7 +13,7 @@ export const RWR = 16; export const DLINK = 32; export const states: string[] = ["none", "idle", "reach-destination", "attack", "follow", "land", "refuel", "AWACS", "tanker", "bomb-point", "carpet-bomb", "bomb-building", "fire-at-area"]; -export const ROEs: string[] = ["free", "designated", "return", "hold"]; +export const ROEs: string[] = ["free", "designated", "", "return", "hold"]; export const reactionsToThreat: string[] = ["none", "manoeuvre", "passive", "evade"]; export const emissionsCountermeasures: string[] = ["silent", "attack", "defend", "free"]; diff --git a/client/src/map/map.ts b/client/src/map/map.ts index 51574d35..44981aa3 100644 --- a/client/src/map/map.ts +++ b/client/src/map/map.ts @@ -150,7 +150,9 @@ export class Map extends L.Map { /* Option buttons */ this.#optionButtons["visibility"] = visibilityControls.map((option: string, index: number) => { - return this.#createOptionButton(option, `visibility/${option.toLowerCase()}.svg`, visibilityControlsTootlips[index], "toggleUnitVisibility", `{"types": "${visibilityControlsTypes[index]}"}`); + var typesArrayString = `"${visibilityControlsTypes[index][0]}"`; + visibilityControlsTypes[index].forEach((type: string, idx: number) => {if (idx > 0) typesArrayString = `${typesArrayString}, "${type}"`}); + return this.#createOptionButton(option, `visibility/${option.toLowerCase()}.svg`, visibilityControlsTootlips[index], "toggleUnitVisibility", `{"types": [${typesArrayString}]}`); }); document.querySelector("#unit-visibility-control")?.append(...this.#optionButtons["visibility"]); diff --git a/client/src/panels/unitcontrolpanel.ts b/client/src/panels/unitcontrolpanel.ts index d2e90a59..a26be730 100644 --- a/client/src/panels/unitcontrolpanel.ts +++ b/client/src/panels/unitcontrolpanel.ts @@ -39,7 +39,7 @@ export class UnitControlPanel extends Panel { // Reversing the ROEs so that the least "aggressive" option is always on the left this.#optionButtons["ROE"] = ROEs.slice(0).reverse().map((option: string, index: number) => { return this.#createOptionButton(option, `roe/${option.toLowerCase()}.svg`, ROEDescriptions.slice(0).reverse()[index], () => { getUnitsManager().selectedUnitsSetROE(option); }); - }); + }).filter((button: HTMLButtonElement, index: number) => {return ROEs[index] !== "";}); this.#optionButtons["reactionToThreat"] = reactionsToThreat.map((option: string, index: number) => { return this.#createOptionButton(option, `threat/${option.toLowerCase()}.svg`, reactionsToThreatDescriptions[index],() => { getUnitsManager().selectedUnitsSetReactionToThreat(option); });