ACE3/addons/spectator/functions/fnc_toggleInterface.sqf

68 lines
2.3 KiB
Plaintext
Raw Normal View History

2015-07-18 17:46:46 +00:00
/*
* Author: SilentSpike
* Correctly handles toggling of spectator interface elements for clean UX
*
* Arguments:
2015-07-20 14:02:56 +00:00
* 0: Display
* 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:
2015-07-20 21:45:11 +00:00
* [_dsiplay, 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-20 14:02:56 +00:00
// Map and help operate outside of interface
GVAR(showHelp) = [GVAR(showHelp), !GVAR(showHelp)] select _toggleHelp;
GVAR(showMap) = [GVAR(showMap), !GVAR(showMap)] select _toggleMap;
2015-07-18 14:42:07 +00:00
2015-07-20 14:02:56 +00:00
// When help changes with map open, minimise the map
if (GVAR(showMap) && _toggleHelp) then {
GVAR(showHelp) = true;
GVAR(showMap) = false;
2015-07-18 14:42:07 +00:00
};
2015-07-19 21:30:44 +00:00
(_display displayCtrl IDC_HELP) ctrlShow GVAR(showHelp);
(_display displayCtrl IDC_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
{
(_display displayCtrl _x) ctrlShow false;
} forEach [IDC_COMP,IDC_HELP,IDC_TOOL,IDC_UNIT];
2015-07-24 14:36:36 +00:00
// Centre map on camera/unit
(_display displayCtrl IDC_MAP) ctrlMapAnimAdd [0, 0.5, [GVAR(camUnit),GVAR(camera)] select (GVAR(camMode) == 0)];
ctrlMapAnimCommit (_display displayCtrl IDC_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;
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];
};
};