diff --git a/addons/spectator/functions/fnc_handleInterface.sqf b/addons/spectator/functions/fnc_handleInterface.sqf index 27fe32647e..be4f0ff45e 100644 --- a/addons/spectator/functions/fnc_handleInterface.sqf +++ b/addons/spectator/functions/fnc_handleInterface.sqf @@ -96,9 +96,7 @@ switch (toLower _mode) do { }; // Always show interface and hide map upon opening - GVAR(showInterface) = true; - GVAR(showMap) = false; - [] call FUNC(updateInterface); + [_display,nil,nil,!GVAR(showInterface),GVAR(showMap)] call FUNC(updateInterface); // Keep unit tree up to date [FUNC(handleUnits), 21, _display] call CBA_fnc_addPerFrameHandler; @@ -161,20 +159,16 @@ switch (toLower _mode) do { [player,false] call FUNC(setSpectator); // Handle esc menu goes here, currently closes for purposes of testing }; case 2: { // 1 - GVAR(showUnit) = !GVAR(showUnit); - [] call FUNC(updateInterface); + [_display,nil,nil,nil,nil,nil,true] call FUNC(updateInterface); }; case 3: { // 2 - GVAR(showTool) = !GVAR(showTool); - [] call FUNC(updateInterface); + [_display,nil,nil,nil,nil,true] call FUNC(updateInterface); }; case 4: { // 3 - GVAR(showComp) = !GVAR(showComp); - [] call FUNC(updateInterface); + [_display,true] call FUNC(updateInterface); }; case 14: { // Backspace - GVAR(showInterface) = !GVAR(showInterface); - [] call FUNC(updateInterface); + [_display,nil,nil,true] call FUNC(updateInterface); }; case 16: { // Q GVAR(camBoom) set [0,true]; @@ -195,15 +189,13 @@ switch (toLower _mode) do { GVAR(camDolly) set [3,true]; }; case 35: { // H - GVAR(showHelp) = !GVAR(showHelp); - [] call FUNC(updateInterface); + [_display,nil,true] call FUNC(updateInterface); }; case 44: { // Z GVAR(camBoom) set [1,true]; }; case 50: { // M - GVAR(showMap) = !GVAR(showMap); - [] call FUNC(updateInterface); + [_display,nil,nil,nil,true] call FUNC(updateInterface); //[_show] call FUNC(handleMap); }; case 57: { // Spacebar diff --git a/addons/spectator/functions/fnc_updateInterface.sqf b/addons/spectator/functions/fnc_updateInterface.sqf index ee8d544b3c..66c1e6bca1 100644 --- a/addons/spectator/functions/fnc_updateInterface.sqf +++ b/addons/spectator/functions/fnc_updateInterface.sqf @@ -3,7 +3,13 @@ * Correctly handles toggling of spectator interface elements for clean UX * * Arguments: - * None + * 0: Display + * 1: Toogle compass + * 2: Toogle help + * 3: Toogle interface + * 4: Toogle map + * 5: Toogle toolbar + * 6: Toogle unit list * * Return Value: * None @@ -16,25 +22,42 @@ #include "script_component.hpp" -private ["_display","_elements","_show"]; -disableSerialization; +params ["_display", ["_toggleComp",false], ["_toggleHelp",false], ["_toggleInterface",false], ["_toggleMap",false], ["_toggleTool",false], ["_toggleUnit",false]]; -_display = GETUVAR(GVAR(display),displayNull); -_elements = [IDC_COMP,IDC_TOOL,IDC_UNIT]; -_show = [GVAR(showComp),GVAR(showTool),GVAR(showUnit)]; +// Map and help operate outside of interface +GVAR(showHelp) = [GVAR(showHelp), !GVAR(showHelp)] select _toggleHelp; +GVAR(showMap) = [GVAR(showMap), !GVAR(showMap)] select _toggleMap; -// Hide/show interface elements as appropriate -if (GVAR(showInterface)) then { - // Hide while map is open to prevent active element weirdness - { - (_display displayCtrl _x) ctrlShow ([(_show select _forEachIndex),false] select GVAR(showMap)); - } forEach _elements; -} else { - { - (_display displayCtrl _x) ctrlShow GVAR(showInterface); - } forEach _elements; +// When help changes with map open, minimise the map +if (GVAR(showMap) && _toggleHelp) then { + GVAR(showHelp) = true; + GVAR(showMap) = false; }; -// Map and help operate seperate from interface (_display displayCtrl IDC_HELP) ctrlShow GVAR(showHelp); (_display displayCtrl IDC_MAP) ctrlShow GVAR(showMap); + +if (GVAR(showMap)) then { + // When map is shown, temporarily hide interface to stop overlapping + { + (_display displayCtrl _x) ctrlShow false; + } forEach [IDC_COMP,IDC_HELP,IDC_TOOL,IDC_UNIT]; +} else { + // Can only toggle interface with map minimised + GVAR(showInterface) = [GVAR(showInterface), !GVAR(showInterface)] select _toggleInterface; + + if (GVAR(showInterface)) then { + // Can only toggle interface elements with interface shown + GVAR(showComp) = [GVAR(showComp), !GVAR(showComp)] select _toggleComp; + GVAR(showTool) = [GVAR(showTool), !GVAR(showTool)] select _toggleTool; + GVAR(showUnit) = [GVAR(showUnit), !GVAR(showUnit)] select _toggleUnit; + + (_display displayCtrl IDC_COMP) ctrlShow GVAR(showComp); + (_display displayCtrl IDC_TOOL) ctrlShow GVAR(showTool); + (_display displayCtrl IDC_UNIT) ctrlShow GVAR(showUnit); + } else { + { + (_display displayCtrl _x) ctrlShow false; + } forEach [IDC_COMP,IDC_TOOL,IDC_UNIT]; + }; +};