2015-07-18 17:46:46 +00:00
|
|
|
/*
|
|
|
|
* Author: SilentSpike
|
|
|
|
* Correctly handles toggling of spectator interface elements for clean UX
|
|
|
|
*
|
|
|
|
* Arguments:
|
2017-06-08 13:31:51 +00:00
|
|
|
* 0: Display <DISPLAY>
|
2015-07-20 14:02:56 +00:00
|
|
|
* 1: Toogle compass <BOOL> <OPTIONAL>
|
|
|
|
* 2: Toogle help <BOOL> <OPTIONAL>
|
|
|
|
* 3: Toogle interface <BOOL> <OPTIONAL>
|
|
|
|
* 4: Toogle map <BOOL> <OPTIONAL>
|
|
|
|
* 5: Toogle toolbar <BOOL> <OPTIONAL>
|
|
|
|
* 6: Toogle unit list <BOOL> <OPTIONAL>
|
2015-07-18 17:46:46 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None <NIL>
|
|
|
|
*
|
|
|
|
* Example:
|
2017-06-08 13:31:51 +00:00
|
|
|
* [_display, nil, true] call ace_spectator_fnc_toggleInterface
|
2015-07-18 17:46:46 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2015-07-18 14:42:07 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-07-20 14:02:56 +00:00
|
|
|
params ["_display", ["_toggleComp",false], ["_toggleHelp",false], ["_toggleInterface",false], ["_toggleMap",false], ["_toggleTool",false], ["_toggleUnit",false]];
|
2015-07-18 14:42:07 +00:00
|
|
|
|
2015-07-25 11:28:03 +00:00
|
|
|
private ["_comp","_help","_map","_tool","_unit"];
|
2015-07-24 18:02:27 +00:00
|
|
|
_comp = _display displayCtrl IDC_COMP;
|
|
|
|
_help = _display displayCtrl IDC_HELP;
|
|
|
|
_map = _display displayCtrl IDC_MAP;
|
|
|
|
_tool = _display displayCtrl IDC_TOOL;
|
|
|
|
_unit = _display displayCtrl IDC_UNIT;
|
|
|
|
|
2015-08-07 00:51:46 +00:00
|
|
|
// Map operates outside of interface
|
2015-07-20 14:02:56 +00:00
|
|
|
GVAR(showMap) = [GVAR(showMap), !GVAR(showMap)] select _toggleMap;
|
2015-07-24 18:02:27 +00:00
|
|
|
_map ctrlShow GVAR(showMap);
|
2015-07-20 14:02:56 +00:00
|
|
|
|
|
|
|
if (GVAR(showMap)) then {
|
|
|
|
// When map is shown, temporarily hide interface to stop overlapping
|
|
|
|
{
|
2015-07-24 18:02:27 +00:00
|
|
|
_x ctrlShow false;
|
|
|
|
} forEach [_comp,_help,_tool,_unit];
|
2015-07-24 14:36:36 +00:00
|
|
|
|
2015-07-24 18:02:27 +00:00
|
|
|
// Centre map on camera/unit upon opening
|
|
|
|
if (_toggleMap) then {
|
2015-09-09 22:21:49 +00:00
|
|
|
_map ctrlMapAnimAdd [0, 0.5, [GVAR(camUnit),GVAR(freeCamera)] select (GVAR(camMode) == 0)];
|
2015-07-24 18:02:27 +00:00
|
|
|
ctrlMapAnimCommit _map;
|
|
|
|
};
|
2015-07-20 14:02:56 +00:00
|
|
|
} 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;
|
2015-08-07 00:51:46 +00:00
|
|
|
GVAR(showHelp) = [GVAR(showHelp), !GVAR(showHelp)] select _toggleHelp;
|
2015-07-20 14:02:56 +00:00
|
|
|
GVAR(showTool) = [GVAR(showTool), !GVAR(showTool)] select _toggleTool;
|
|
|
|
GVAR(showUnit) = [GVAR(showUnit), !GVAR(showUnit)] select _toggleUnit;
|
|
|
|
|
2015-07-24 18:02:27 +00:00
|
|
|
_comp ctrlShow GVAR(showComp);
|
2015-08-07 00:51:46 +00:00
|
|
|
_help ctrlShow GVAR(showHelp);
|
2015-07-24 18:02:27 +00:00
|
|
|
_tool ctrlShow GVAR(showTool);
|
|
|
|
_unit ctrlShow GVAR(showUnit);
|
2015-07-20 14:02:56 +00:00
|
|
|
} else {
|
|
|
|
{
|
2015-07-24 18:02:27 +00:00
|
|
|
_x ctrlShow false;
|
2015-08-07 00:51:46 +00:00
|
|
|
} forEach [_comp,_help,_tool,_unit];
|
2015-07-20 14:02:56 +00:00
|
|
|
};
|
|
|
|
};
|
2015-07-24 18:02:27 +00:00
|
|
|
|
2015-07-25 11:28:03 +00:00
|
|
|
// Only run PFHs when respective control is shown, otherwise kill
|
2015-07-24 18:02:27 +00:00
|
|
|
if (ctrlShown _comp) then {
|
2015-07-25 11:28:03 +00:00
|
|
|
if (isNil QGVAR(compHandler)) then { GVAR(compHandler) = [FUNC(handleCompass), 0, _display] call CBA_fnc_addPerFrameHandler; };
|
2015-07-24 18:02:27 +00:00
|
|
|
} else {
|
|
|
|
GVAR(compHandler) = nil;
|
|
|
|
};
|
|
|
|
|
|
|
|
if (ctrlShown _tool) then {
|
2015-07-25 11:28:03 +00:00
|
|
|
if (isNil QGVAR(toolHandler)) then { GVAR(toolHandler) = [FUNC(handleToolbar), 0, _display] call CBA_fnc_addPerFrameHandler; };
|
2015-07-24 18:02:27 +00:00
|
|
|
} else {
|
|
|
|
GVAR(toolHandler) = nil;
|
|
|
|
};
|