From 6a7870acf09dc695a03ef377f077ed64509c78cb Mon Sep 17 00:00:00 2001 From: jokoho482 Date: Fri, 15 Sep 2023 13:30:42 +0200 Subject: [PATCH] Improve Handling of Menus --- .../Spectator/Menu/SubMenus/fn_miscSubMenus.sqf | 2 +- .../Spectator/Menu/SubMenus/fn_visionSubMenus.sqf | 2 +- .../Streamator/Spectator/Menu/fn_addMenuItem.sqf | 2 +- .../Streamator/Spectator/Menu/fn_executeEntry.sqf | 6 +++++- .../Streamator/Spectator/Menu/fn_registerMenus.sqf | 14 +++++++------- addons/Streamator/Spectator/Menu/macros.hpp | 2 +- include/tc/CLib | 2 +- 7 files changed, 17 insertions(+), 13 deletions(-) diff --git a/addons/Streamator/Spectator/Menu/SubMenus/fn_miscSubMenus.sqf b/addons/Streamator/Spectator/Menu/SubMenus/fn_miscSubMenus.sqf index 465c882..7753a5d 100644 --- a/addons/Streamator/Spectator/Menu/SubMenus/fn_miscSubMenus.sqf +++ b/addons/Streamator/Spectator/Menu/SubMenus/fn_miscSubMenus.sqf @@ -59,7 +59,7 @@ _ret }] call FUNC(addMenuItem); -["View Distance", "MAIN/MISC", DIK_F4, { GVAR(currentMenuPath) = "MAIN/MISC/VIEWDISTANCE"; true }, {!GVAR(MapOpen)}, true] call FUNC(addMenuItem); +["View Distance", "MAIN/MISC", DIK_F4, "MAIN/MISC/VIEWDISTANCE", {!GVAR(MapOpen)}, true] call FUNC(addMenuItem); CREATE_BACK_ACTION("MAIN/MISC/VIEWDISTANCE", "MAIN/MISC"); private _fnc_doViewDistance = { diff --git a/addons/Streamator/Spectator/Menu/SubMenus/fn_visionSubMenus.sqf b/addons/Streamator/Spectator/Menu/SubMenus/fn_visionSubMenus.sqf index dfddc4f..6cf62c8 100644 --- a/addons/Streamator/Spectator/Menu/SubMenus/fn_visionSubMenus.sqf +++ b/addons/Streamator/Spectator/Menu/SubMenus/fn_visionSubMenus.sqf @@ -50,7 +50,7 @@ true }] call FUNC(addMenuItem); // Thermal Vision Modes -["Thermal Modes", "MAIN/VISION", DIK_F4, { GVAR(currentMenuPath) = "MAIN/VISION/THERMALMODES"; true }, {true}, true] call FUNC(addMenuItem); +["Thermal Modes", "MAIN/VISION", DIK_F4, "MAIN/VISION/THERMALMODES", {true}, true] call FUNC(addMenuItem); CREATE_BACK_ACTION("MAIN/VISION/THERMALMODES", "MAIN/VISION"); private _fnc_setThermalMode = { diff --git a/addons/Streamator/Spectator/Menu/fn_addMenuItem.sqf b/addons/Streamator/Spectator/Menu/fn_addMenuItem.sqf index 9c4c86f..5ff429b 100644 --- a/addons/Streamator/Spectator/Menu/fn_addMenuItem.sqf +++ b/addons/Streamator/Spectator/Menu/fn_addMenuItem.sqf @@ -19,7 +19,7 @@ Returns: None */ -params ["_name", "_path", ["_dik", DIK_F1], ["_onUse", {LOG("Nothing here.")}, []], ["_onRender", {true}, [{}]], ["_hasSubMenus", false], ["_args", []]]; +params ["_name", "_path", ["_dik", DIK_F1], ["_onUse", {LOG("Nothing here.")}, [{}, ""]], ["_onRender", {true}, [{}]], ["_hasSubMenus", false], ["_args", []]]; if (isNil QGVAR(menuEntries)) then { GVAR(menuEntries) = false call CFUNC(createNamespace); GVAR(menuEntries) setVariable ["MAIN", []]; diff --git a/addons/Streamator/Spectator/Menu/fn_executeEntry.sqf b/addons/Streamator/Spectator/Menu/fn_executeEntry.sqf index 542ff51..4108cff 100644 --- a/addons/Streamator/Spectator/Menu/fn_executeEntry.sqf +++ b/addons/Streamator/Spectator/Menu/fn_executeEntry.sqf @@ -21,7 +21,11 @@ private _entries = GVAR(menuEntries) getVariable [_path, []]; private _color = "#ffffff"; private _style = "[%1] %2 "; if (_args call _onRender) then { - _args call _onUse; + if (_onUse isEqualType "") then { + GVAR(currentMenuPath) = _onUse; + } else { + _args call _onUse; + }; // We need to wait 2 frames for some Arma Variables to Update like Object View Distance { { QGVAR(updateMenu) call CFUNC(localEvent); } call CFUNC(execNextFrame); } call CFUNC(execNextFrame); true breakOut SCRIPTSCOPENAME; diff --git a/addons/Streamator/Spectator/Menu/fn_registerMenus.sqf b/addons/Streamator/Spectator/Menu/fn_registerMenus.sqf index 9a22a8b..5021f2d 100644 --- a/addons/Streamator/Spectator/Menu/fn_registerMenus.sqf +++ b/addons/Streamator/Spectator/Menu/fn_registerMenus.sqf @@ -16,40 +16,40 @@ GVAR(currentMenuPath) = "MAIN"; // Overlays -["Overlays", "MAIN", DIK_F1, { GVAR(currentMenuPath) = "MAIN/OVERLAYS"; true }, {true}, true] call FUNC(addMenuItem); +["Overlays", "MAIN", DIK_F1, "MAIN/OVERLAYS", {true}, true] call FUNC(addMenuItem); CREATE_BACK_ACTION_MAIN("MAIN/OVERLAYS"); call FUNC(overlaySubMenus); // Camera -["Camera Modes", "MAIN", DIK_F2, { GVAR(currentMenuPath) = "MAIN/CAMERA"; true }, {!isNull GVAR(CameraFollowTarget) && !GVAR(MapOpen)}, true] call FUNC(addMenuItem); +["Camera Modes", "MAIN", DIK_F2, "MAIN/CAMERA", {!isNull GVAR(CameraFollowTarget) && !GVAR(MapOpen)}, true] call FUNC(addMenuItem); CREATE_BACK_ACTION_MAIN("MAIN/CAMERA"); call FUNC(cameraSubMenus); // Vision Modes -["Vision Modes", "MAIN", DIK_F3, { GVAR(currentMenuPath) = "MAIN/VISION"; true }, {!GVAR(MapOpen)}, true] call FUNC(addMenuItem); +["Vision Modes", "MAIN", DIK_F3, "MAIN/VISION", {!GVAR(MapOpen)}, true] call FUNC(addMenuItem); CREATE_BACK_ACTION_MAIN("MAIN/VISION"); call FUNC(visionSubMenus); // Minimap -["Minimap", "MAIN", DIK_F4, { GVAR(currentMenuPath) = "MAIN/MINIMAP"; true }, {!GVAR(MapOpen)}, true] call FUNC(addMenuItem); +["Minimap", "MAIN", DIK_F4, "MAIN/MINIMAP", {!GVAR(MapOpen)}, true] call FUNC(addMenuItem); CREATE_BACK_ACTION_MAIN("MAIN/MINIMAP"); call FUNC(mapSubMenus); // Radio if (GVAR(TFARLoaded) || GVAR(ACRELoaded)) then { - ["Radio", "MAIN", DIK_F5, { GVAR(currentMenuPath) = "MAIN/RADIO"; true }, {true}, true] call FUNC(addMenuItem); + ["Radio", "MAIN", DIK_F5, "MAIN/RADIO", {true}, true] call FUNC(addMenuItem); CREATE_BACK_ACTION_MAIN("MAIN/RADIO"); call FUNC(radioSubMenus); }; // Crew -["Crew", "MAIN", DIK_F6, { GVAR(currentMenuPath) = "MAIN/CREW"; true }, { +["Crew", "MAIN", DIK_F6, "MAIN/CREW", { !GVAR(MapOpen) && !isNull GVAR(CameraFollowTarget) && !((vehicle GVAR(CameraFollowTarget)) isKindOf "CAManBase"); }, true] call FUNC(addMenuItem); CREATE_BACK_ACTION_MAIN("MAIN/CREW"); call FUNC(crewSubMenus); // Misc -["Misc", "MAIN", DIK_F7, { GVAR(currentMenuPath) = "MAIN/MISC"; true }, {true}, true] call FUNC(addMenuItem); +["Misc", "MAIN", DIK_F7, "MAIN/MISC", {true}, true] call FUNC(addMenuItem); CREATE_BACK_ACTION_MAIN("MAIN/MISC"); call FUNC(miscSubMenus); diff --git a/addons/Streamator/Spectator/Menu/macros.hpp b/addons/Streamator/Spectator/Menu/macros.hpp index 118b938..3aea4b2 100644 --- a/addons/Streamator/Spectator/Menu/macros.hpp +++ b/addons/Streamator/Spectator/Menu/macros.hpp @@ -1,4 +1,4 @@ #include "\tc\Streamator\addons\Streamator\Spectator\macros.hpp" -#define CREATE_BACK_ACTION(ORIGIN_PATH,TARGET_PATH) ["BACK", ORIGIN_PATH, DIK_ESCAPE, { GVAR(currentMenuPath) = TARGET_PATH; true }] call FUNC(addMenuItem) +#define CREATE_BACK_ACTION(ORIGIN_PATH,TARGET_PATH) ["BACK", ORIGIN_PATH, DIK_ESCAPE, TARGET_PATH] call FUNC(addMenuItem) #define CREATE_BACK_ACTION_MAIN(ORIGIN_PATH) CREATE_BACK_ACTION(ORIGIN_PATH,"MAIN") diff --git a/include/tc/CLib b/include/tc/CLib index 1f8390f..d7a33ff 160000 --- a/include/tc/CLib +++ b/include/tc/CLib @@ -1 +1 @@ -Subproject commit 1f8390ff59b1532cb7d799f904d673095f422cfe +Subproject commit d7a33ff7f0b4fb71208a3ffebe7315c80260df15