From 1bca2e5c266cca3d2c65c165a9003f31293a52c0 Mon Sep 17 00:00:00 2001 From: Davide Passoni Date: Mon, 31 Mar 2025 11:14:06 +0200 Subject: [PATCH] fix: "Follow roads" toggle available for navy units --- .../react/src/ui/panels/unitcontrolmenu.tsx | 341 ++++++++++-------- 1 file changed, 190 insertions(+), 151 deletions(-) diff --git a/frontend/react/src/ui/panels/unitcontrolmenu.tsx b/frontend/react/src/ui/panels/unitcontrolmenu.tsx index 53aa13e8..4dc15ac1 100644 --- a/frontend/react/src/ui/panels/unitcontrolmenu.tsx +++ b/frontend/react/src/ui/panels/unitcontrolmenu.tsx @@ -420,9 +420,12 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { return ( -
{entry[1][1] as string}
+ {" "} +
+ {entry[1][1] as string} +
{["blue", "neutral", "red"].map((coalition) => { return ( @@ -576,25 +579,38 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { {selectedUnits.length > 0 && ( <> {Object.keys(unitOccurences["blue"]).length + Object.keys(unitOccurences["neutral"]).length + Object.keys(unitOccurences["red"]).length > 1 && ( -
+
{" "} - {" "} + {" "}
Click: keep as only selection
-
ctrl + click: deselect
-
shift + click: keep only units of coalition
+
+ + {" "} + ctrl + {" "} + + click: deselect{" "} +
+
+ + shift + {" "} + + click: keep only units of coalition +
{" "}
)} @@ -622,31 +638,34 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { data-[coalition='red']:border-red-500 hover:bg-white/5 `} - onClick = {(ev) => { + onClick={(ev) => { if (ev.ctrlKey) { getApp() .getUnitsManager() - .getSelectedUnits().forEach((unit) => { + .getSelectedUnits() + .forEach((unit) => { if (unit.getName() === name && unit.getCoalition() === coalition) { unit.setSelected(false); } - }) + }); } else if (ev.shiftKey) { getApp() .getUnitsManager() - .getSelectedUnits().forEach((unit) => { + .getSelectedUnits() + .forEach((unit) => { if (unit.getCoalition() !== coalition) { unit.setSelected(false); } - }) + }); } else { getApp() .getUnitsManager() - .getSelectedUnits().forEach((unit) => { + .getSelectedUnits() + .forEach((unit) => { if (unit.getName() !== name || unit.getCoalition() !== coalition) { unit.setSelected(false); } - }) + }); } }} > @@ -848,53 +867,65 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) {
{" "} - Hold fire: The unit will not shoot in - any circumstance + {" "} + Hold fire: The unit will not shoot in any circumstance
{" "} - Return fire: The unit will not fire - unless fired upon + {" "} + Return fire: The unit will not fire unless fired upon
{" "} - {" "} + {" "}
{" "} - Fire on target: The unit will not fire unless fired upon

or

ordered to do so{" "} + Fire on target: The unit will not fire unless fired upon{" "} +

+ or +

{" "} + ordered to do so{" "}
{" "} - Free: The unit will fire at any - detected enemy in range + {" "} + Free: The unit will fire at any detected enemy in range
- +
Currently, DCS blue and red ground units do not respect{" "} - and{" "} - rules of engagement, so be careful, they - may start shooting when you don't want them to. Use neutral units for finer control. + {" "} + and{" "} + {" "} + rules of engagement, so be careful, they may start shooting when you don't want them to. Use neutral units for finer + control.
@@ -948,29 +979,25 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) {
{" "} - {" "} - Green: The unit will not engage with its sensors in any circumstances. The unit will be able to move. + Green: The unit will not engage + with its sensors in any circumstances. The unit will be able to move.
{" "} - {" "} + {" "}
Auto: The unit will use its sensors to engage based on its ROE.
{" "} - {" "} - Red: The unit will be actively searching for target with its sensors. For some units, this will deploy the radar and make - the unit not able to move. + Red: The unit will be actively + searching for target with its sensors. For some units, this will deploy the radar and make the unit not able to move.
@@ -1027,31 +1054,35 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) {
{" "} - No reaction: The unit will not - react in any circumstance + {" "} + No reaction: The unit will not react in any circumstance
{" "} - Passive: The unit will use - counter-measures, but will not alter its course + {" "} + Passive: The unit will use counter-measures, but will not alter its course
{" "} - Manouevre: The unit will try - to evade the threat using manoeuvres, but no counter-measures + {" "} + Manouevre: The unit will try to evade the threat using manoeuvres, but no counter-measures
{" "} - Full evasion: the unit will try - to evade the threat both manoeuvering and using counter-measures + {" "} + Full evasion: the unit will try to evade the threat both manoeuvering and using counter-measures
@@ -1102,31 +1133,35 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) {
{" "} - Radio silence: No radar or - ECM will be used + {" "} + Radio silence: No radar or ECM will be used
{" "} - Defensive: The unit will turn - radar and ECM on only when threatened + {" "} + Defensive: The unit will turn radar and ECM on only when threatened
{" "} - Attack: The unit will use - radar and ECM when engaging other units + {" "} + Attack: The unit will use radar and ECM when engaging other units
{" "} - Free: the unit will use the - radar and ECM all the time + {" "} + Free: the unit will use the radar and ECM all the time
@@ -1344,9 +1379,9 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { >
- +
Currently, DCS blue and red ground units do not respect their rules of engagement, so be careful, they may start shooting when @@ -1446,9 +1481,9 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { {/* ============== Miss on purpose toggle END ============== */}
{/* ============== Shots scatter START ============== */} -
+
void }) {
{/* ============== Operate as toggle START ============== */} {selectedUnits.every((unit) => unit.getCoalition() === "neutral") && ( -
+
void }) { )}
{/* ============== Follow roads toggle START ============== */} -
- - Follow roads - - { - getApp() - .getUnitsManager() - .setFollowRoads(!selectedUnitsData.followRoads, null, () => - setForcedUnitsData({ - ...forcedUnitsData, - followRoads: !selectedUnitsData.followRoads, - }) - ); - }} - tooltip={() => ( - - )} - tooltipRelativeToParent={true} - tooltipPosition="above" - /> -
+ {selectedCategories.every((category) => category === "GroundUnit") && ( +
+ + Follow roads + + { + getApp() + .getUnitsManager() + .setFollowRoads(!selectedUnitsData.followRoads, null, () => + setForcedUnitsData({ + ...forcedUnitsData, + followRoads: !selectedUnitsData.followRoads, + }) + ); + }} + tooltip={() => ( + + )} + tooltipRelativeToParent={true} + tooltipPosition="above" + /> +
+ )} {/* ============== Follow roads toggle END ============== */} {/* ============== Unit active toggle START ============== */}
@@ -2021,9 +2058,10 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { value={activeRadioSettings ? activeRadioSettings.TACAN.channel : 1} > - + { @@ -2256,9 +2294,11 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { className={` flex content-center gap-2 rounded-full ${selectedUnits[0].getFuel() > 40 && `bg-green-700`} - ${selectedUnits[0].getFuel() > 10 && selectedUnits[0].getFuel() <= 40 && ` - bg-yellow-700 - `} + ${ + selectedUnits[0].getFuel() > 10 && + selectedUnits[0].getFuel() <= 40 && + `bg-yellow-700` + } ${selectedUnits[0].getFuel() <= 10 && `bg-red-700`} px-2 py-1 text-sm font-bold text-white `} @@ -2278,10 +2318,9 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { )*/}
- +
{Math.round(mToFt(selectedUnits[0].getPosition().alt ?? 0))} ft