Skip to content

Commit

Permalink
Improve Handling of Menus
Browse files Browse the repository at this point in the history
  • Loading branch information
jokoho48 committed Sep 15, 2023
1 parent bc3f084 commit 6a7870a
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 1 addition & 1 deletion addons/Streamator/Spectator/Menu/fn_addMenuItem.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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", []];
Expand Down
6 changes: 5 additions & 1 deletion addons/Streamator/Spectator/Menu/fn_executeEntry.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ private _entries = GVAR(menuEntries) getVariable [_path, []];
private _color = "#ffffff";
private _style = "<t size='%3' color='%4'>[%1] %2 </t>";
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;
Expand Down
14 changes: 7 additions & 7 deletions addons/Streamator/Spectator/Menu/fn_registerMenus.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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);
2 changes: 1 addition & 1 deletion addons/Streamator/Spectator/Menu/macros.hpp
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit 6a7870a

Please sign in to comment.