diff --git a/frontend/react/src/ui/panels/unitcontrolmenu.tsx b/frontend/react/src/ui/panels/unitcontrolmenu.tsx index bb2b34eb..477d7b83 100644 --- a/frontend/react/src/ui/panels/unitcontrolmenu.tsx +++ b/frontend/react/src/ui/panels/unitcontrolmenu.tsx @@ -53,7 +53,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 { Radio, TACAN } from "../../interfaces"; +import { GeneralSettings, Radio, TACAN } from "../../interfaces"; import { OlStringInput } from "../components/olstringinput"; import { OlFrequencyInput } from "../components/olfrequencyinput"; import { UnitSink } from "../../audio/unitsink"; @@ -117,8 +117,10 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { const [selectionID, setSelectionID] = useState(null as null | number); const [searchBarRefState, setSearchBarRefState] = useState(null as MutableRefObject | null); const [filterString, setFilterString] = useState(""); + const [showRadioSettings, setShowRadioSettings] = useState(false); const [showAdvancedSettings, setShowAdvancedSettings] = useState(false); - const [activeAdvancedSettings, setActiveAdvancedSettings] = useState(null as null | { radio: Radio; TACAN: TACAN }); + const [activeRadioSettings, setActiveRadioSettings] = useState(null as null | { radio: Radio; TACAN: TACAN }); + const [activeAdvancedSettings, setActiveAdvancedSettings] = useState(null as null | GeneralSettings); const [lastUpdateTime, setLastUpdateTime] = useState(0); var searchBarRef = useRef(null); @@ -137,8 +139,6 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { }); const updateData = useCallback(() => { - setShowAdvancedSettings(false); - const getters = { desiredAltitude: (unit: Unit) => Math.round(mToFt(unit.getDesiredAltitude())), desiredAltitudeType: (unit: Unit) => unit.getDesiredAltitudeType(), @@ -187,12 +187,14 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { } else updatedData[key] = newDatum; }); setSelectedUnitsData(updatedData as typeof selectedUnitsData); - if (anyForcedDataUpdated) setForcedUnitsData({...forcedUnitsData}) - }, [forcedUnitsData]) + if (anyForcedDataUpdated) setForcedUnitsData({ ...forcedUnitsData }); + }, [forcedUnitsData]); useEffect(updateData, [selectedUnits, lastUpdateTime, forcedUnitsData]); useEffect(() => { setForcedUnitsData(initializeUnitsData); + setShowRadioSettings(false); + setShowAdvancedSettings(false); }, [selectedUnits]); /* Count how many units are selected of each type, divided by coalition */ @@ -516,7 +518,7 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { {/* ============== Units list END ============== */} {/* ============== Unit basic options START ============== */} <> - {!showAdvancedSettings && ( + {!showRadioSettings && !showAdvancedSettings && (
{/* ============== Altitude selector START ============== */} {selectedCategories.every((category) => { @@ -820,7 +822,7 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) {
)} {/* ============== Tanker and AWACS available button END ============== */} - {/* ============== Advanced settings buttons START ============== */} + {/* ============== Radio settings buttons START ============== */} {selectedUnits.length === 1 && (selectedUnits[0].isTanker() || selectedUnits[0].isAWACS()) && (
)} + {/* ============== Radio settings buttons END ============== */} + {/* ============== Advanced settings buttons START ============== */} + {selectedUnits.length === 1 && + !selectedUnits[0].isTanker() && + !selectedUnits[0].isAWACS() && + ["Aircraft", "Helicopter"].includes(selectedUnits[0].getCategory()) && ( +
+ +
+ )} {/* ============== Advanced settings buttons END ============== */} {selectedCategories.every((category) => { @@ -1101,17 +1126,17 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { {/* ============== Audio sink toggle END ============== */} )} - {/* ============== Advanced settings START ============== */} - {showAdvancedSettings && ( + {/* ============== Radio settings START ============== */} + {showRadioSettings && (
-
Advanced settings
+
Radio settings
Callsign
@@ -1123,8 +1148,8 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { { - if (activeAdvancedSettings) activeAdvancedSettings.radio.callsign = idx + 1; - setActiveAdvancedSettings(deepCopyTable(activeAdvancedSettings)); + if (activeRadioSettings) activeRadioSettings.radio.callsign = idx + 1; + setActiveRadioSettings(deepCopyTable(activeRadioSettings)); }} > {name} @@ -1142,8 +1167,8 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { { - if (activeAdvancedSettings) activeAdvancedSettings.radio.callsign = idx + 1; - setActiveAdvancedSettings(deepCopyTable(activeAdvancedSettings)); + if (activeRadioSettings) activeRadioSettings.radio.callsign = idx + 1; + setActiveRadioSettings(deepCopyTable(activeRadioSettings)); }} > {name} @@ -1160,20 +1185,20 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { min={1} max={9} onChange={(e) => { - if (activeAdvancedSettings) activeAdvancedSettings.radio.callsignNumber = Math.max(Math.min(Number(e.target.value), 9), 1); - setActiveAdvancedSettings(deepCopyTable(activeAdvancedSettings)); + if (activeRadioSettings) activeRadioSettings.radio.callsignNumber = Math.max(Math.min(Number(e.target.value), 9), 1); + setActiveRadioSettings(deepCopyTable(activeRadioSettings)); }} onDecrease={() => { - if (activeAdvancedSettings) - activeAdvancedSettings.radio.callsignNumber = Math.max(Math.min(Number(activeAdvancedSettings.radio.callsignNumber - 1), 9), 1); - setActiveAdvancedSettings(deepCopyTable(activeAdvancedSettings)); + if (activeRadioSettings) + activeRadioSettings.radio.callsignNumber = Math.max(Math.min(Number(activeRadioSettings.radio.callsignNumber - 1), 9), 1); + setActiveRadioSettings(deepCopyTable(activeRadioSettings)); }} onIncrease={() => { - if (activeAdvancedSettings) - activeAdvancedSettings.radio.callsignNumber = Math.max(Math.min(Number(activeAdvancedSettings.radio.callsignNumber + 1), 9), 1); - setActiveAdvancedSettings(deepCopyTable(activeAdvancedSettings)); + if (activeRadioSettings) + activeRadioSettings.radio.callsignNumber = Math.max(Math.min(Number(activeRadioSettings.radio.callsignNumber + 1), 9), 1); + setActiveRadioSettings(deepCopyTable(activeRadioSettings)); }} - value={activeAdvancedSettings ? activeAdvancedSettings.radio.callsignNumber : 1} + value={activeRadioSettings ? activeRadioSettings.radio.callsignNumber : 1} >
TACAN
@@ -1182,30 +1207,29 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { min={1} max={126} onChange={(e) => { - if (activeAdvancedSettings) activeAdvancedSettings.TACAN.channel = Math.max(Math.min(Number(e.target.value), 126), 1); - setActiveAdvancedSettings(deepCopyTable(activeAdvancedSettings)); + if (activeRadioSettings) activeRadioSettings.TACAN.channel = Math.max(Math.min(Number(e.target.value), 126), 1); + setActiveRadioSettings(deepCopyTable(activeRadioSettings)); }} onDecrease={() => { - if (activeAdvancedSettings) - activeAdvancedSettings.TACAN.channel = Math.max(Math.min(Number(activeAdvancedSettings.TACAN.channel - 1), 126), 1); - setActiveAdvancedSettings(deepCopyTable(activeAdvancedSettings)); + if (activeRadioSettings) activeRadioSettings.TACAN.channel = Math.max(Math.min(Number(activeRadioSettings.TACAN.channel - 1), 126), 1); + setActiveRadioSettings(deepCopyTable(activeRadioSettings)); }} onIncrease={() => { - if (activeAdvancedSettings) - activeAdvancedSettings.TACAN.channel = Math.max(Math.min(Number(activeAdvancedSettings.TACAN.channel + 1), 126), 1); - setActiveAdvancedSettings(deepCopyTable(activeAdvancedSettings)); + if (activeRadioSettings) activeRadioSettings.TACAN.channel = Math.max(Math.min(Number(activeRadioSettings.TACAN.channel + 1), 126), 1); + setActiveRadioSettings(deepCopyTable(activeRadioSettings)); }} - value={activeAdvancedSettings ? activeAdvancedSettings.TACAN.channel : 1} + value={activeRadioSettings ? activeRadioSettings.TACAN.channel : 1} > - + { - if (activeAdvancedSettings) activeAdvancedSettings.TACAN.XY = "X"; - setActiveAdvancedSettings(deepCopyTable(activeAdvancedSettings)); + if (activeRadioSettings) activeRadioSettings.TACAN.XY = "X"; + setActiveRadioSettings(deepCopyTable(activeRadioSettings)); }} > X @@ -1213,33 +1237,33 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) { { - if (activeAdvancedSettings) activeAdvancedSettings.TACAN.XY = "Y"; - setActiveAdvancedSettings(deepCopyTable(activeAdvancedSettings)); + if (activeRadioSettings) activeRadioSettings.TACAN.XY = "Y"; + setActiveRadioSettings(deepCopyTable(activeRadioSettings)); }} > Y { - if (activeAdvancedSettings) { - activeAdvancedSettings.TACAN.callsign = e.target.value; - if (activeAdvancedSettings.TACAN.callsign.length > 3) - activeAdvancedSettings.TACAN.callsign = activeAdvancedSettings.TACAN.callsign.slice(0, 3); + if (activeRadioSettings) { + activeRadioSettings.TACAN.callsign = e.target.value; + if (activeRadioSettings.TACAN.callsign.length > 3) + activeRadioSettings.TACAN.callsign = activeRadioSettings.TACAN.callsign.slice(0, 3); } - setActiveAdvancedSettings(deepCopyTable(activeAdvancedSettings)); + setActiveRadioSettings(deepCopyTable(activeRadioSettings)); }} />
Enabled{" "} { - if (activeAdvancedSettings) activeAdvancedSettings.TACAN.isOn = !activeAdvancedSettings.TACAN.isOn; - setActiveAdvancedSettings(deepCopyTable(activeAdvancedSettings)); + if (activeRadioSettings) activeRadioSettings.TACAN.isOn = !activeRadioSettings.TACAN.isOn; + setActiveRadioSettings(deepCopyTable(activeRadioSettings)); }} />
@@ -1247,16 +1271,109 @@ export function UnitControlMenu(props: { open: boolean; onClose: () => void }) {
Radio frequency
{ - if (activeAdvancedSettings) { - activeAdvancedSettings.radio.frequency = value; - setActiveAdvancedSettings(deepCopyTable(activeAdvancedSettings)); + if (activeRadioSettings) { + activeRadioSettings.radio.frequency = value; + setActiveRadioSettings(deepCopyTable(activeRadioSettings)); } }} />
+
+ + +
+ + )} + {/* ============== Radio settings END ============== */} + {/* ============== Advanced settings START ============== */} + {showAdvancedSettings && ( +
+
Radio settings
+
+ Prohibit AA + { + setActiveAdvancedSettings({ ...(activeAdvancedSettings as GeneralSettings), prohibitAA: !activeAdvancedSettings?.prohibitAA }); + }} + toggled={activeAdvancedSettings?.prohibitAA} + /> +
+
+ Prohibit AG + { + setActiveAdvancedSettings({ ...(activeAdvancedSettings as GeneralSettings), prohibitAG: !activeAdvancedSettings?.prohibitAG }); + }} + toggled={activeAdvancedSettings?.prohibitAG} + /> +
+
+ Prohibit Jettison + { + setActiveAdvancedSettings({ + ...(activeAdvancedSettings as GeneralSettings), + prohibitJettison: !activeAdvancedSettings?.prohibitJettison, + }); + }} + toggled={activeAdvancedSettings?.prohibitJettison} + /> +
+
+ Prohibit afterburner + { + setActiveAdvancedSettings({ + ...(activeAdvancedSettings as GeneralSettings), + prohibitAfterburner: !activeAdvancedSettings?.prohibitAfterburner, + }); + }} + toggled={activeAdvancedSettings?.prohibitAfterburner} + /> +
+