mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Improve toggling code and UX
This commit is contained in:
parent
2ffa3c9a85
commit
841f939012
@ -96,9 +96,7 @@ switch (toLower _mode) do {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Always show interface and hide map upon opening
|
// Always show interface and hide map upon opening
|
||||||
GVAR(showInterface) = true;
|
[_display,nil,nil,!GVAR(showInterface),GVAR(showMap)] call FUNC(updateInterface);
|
||||||
GVAR(showMap) = false;
|
|
||||||
[] call FUNC(updateInterface);
|
|
||||||
|
|
||||||
// Keep unit tree up to date
|
// Keep unit tree up to date
|
||||||
[FUNC(handleUnits), 21, _display] call CBA_fnc_addPerFrameHandler;
|
[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
|
[player,false] call FUNC(setSpectator); // Handle esc menu goes here, currently closes for purposes of testing
|
||||||
};
|
};
|
||||||
case 2: { // 1
|
case 2: { // 1
|
||||||
GVAR(showUnit) = !GVAR(showUnit);
|
[_display,nil,nil,nil,nil,nil,true] call FUNC(updateInterface);
|
||||||
[] call FUNC(updateInterface);
|
|
||||||
};
|
};
|
||||||
case 3: { // 2
|
case 3: { // 2
|
||||||
GVAR(showTool) = !GVAR(showTool);
|
[_display,nil,nil,nil,nil,true] call FUNC(updateInterface);
|
||||||
[] call FUNC(updateInterface);
|
|
||||||
};
|
};
|
||||||
case 4: { // 3
|
case 4: { // 3
|
||||||
GVAR(showComp) = !GVAR(showComp);
|
[_display,true] call FUNC(updateInterface);
|
||||||
[] call FUNC(updateInterface);
|
|
||||||
};
|
};
|
||||||
case 14: { // Backspace
|
case 14: { // Backspace
|
||||||
GVAR(showInterface) = !GVAR(showInterface);
|
[_display,nil,nil,true] call FUNC(updateInterface);
|
||||||
[] call FUNC(updateInterface);
|
|
||||||
};
|
};
|
||||||
case 16: { // Q
|
case 16: { // Q
|
||||||
GVAR(camBoom) set [0,true];
|
GVAR(camBoom) set [0,true];
|
||||||
@ -195,15 +189,13 @@ switch (toLower _mode) do {
|
|||||||
GVAR(camDolly) set [3,true];
|
GVAR(camDolly) set [3,true];
|
||||||
};
|
};
|
||||||
case 35: { // H
|
case 35: { // H
|
||||||
GVAR(showHelp) = !GVAR(showHelp);
|
[_display,nil,true] call FUNC(updateInterface);
|
||||||
[] call FUNC(updateInterface);
|
|
||||||
};
|
};
|
||||||
case 44: { // Z
|
case 44: { // Z
|
||||||
GVAR(camBoom) set [1,true];
|
GVAR(camBoom) set [1,true];
|
||||||
};
|
};
|
||||||
case 50: { // M
|
case 50: { // M
|
||||||
GVAR(showMap) = !GVAR(showMap);
|
[_display,nil,nil,nil,true] call FUNC(updateInterface);
|
||||||
[] call FUNC(updateInterface);
|
|
||||||
//[_show] call FUNC(handleMap);
|
//[_show] call FUNC(handleMap);
|
||||||
};
|
};
|
||||||
case 57: { // Spacebar
|
case 57: { // Spacebar
|
||||||
|
@ -3,7 +3,13 @@
|
|||||||
* Correctly handles toggling of spectator interface elements for clean UX
|
* Correctly handles toggling of spectator interface elements for clean UX
|
||||||
*
|
*
|
||||||
* Arguments:
|
* Arguments:
|
||||||
* None <NIL>
|
* 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>
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* None <NIL>
|
* None <NIL>
|
||||||
@ -16,25 +22,42 @@
|
|||||||
|
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_display","_elements","_show"];
|
params ["_display", ["_toggleComp",false], ["_toggleHelp",false], ["_toggleInterface",false], ["_toggleMap",false], ["_toggleTool",false], ["_toggleUnit",false]];
|
||||||
disableSerialization;
|
|
||||||
|
|
||||||
_display = GETUVAR(GVAR(display),displayNull);
|
// Map and help operate outside of interface
|
||||||
_elements = [IDC_COMP,IDC_TOOL,IDC_UNIT];
|
GVAR(showHelp) = [GVAR(showHelp), !GVAR(showHelp)] select _toggleHelp;
|
||||||
_show = [GVAR(showComp),GVAR(showTool),GVAR(showUnit)];
|
GVAR(showMap) = [GVAR(showMap), !GVAR(showMap)] select _toggleMap;
|
||||||
|
|
||||||
// Hide/show interface elements as appropriate
|
// When help changes with map open, minimise the map
|
||||||
if (GVAR(showInterface)) then {
|
if (GVAR(showMap) && _toggleHelp) then {
|
||||||
// Hide while map is open to prevent active element weirdness
|
GVAR(showHelp) = true;
|
||||||
{
|
GVAR(showMap) = false;
|
||||||
(_display displayCtrl _x) ctrlShow ([(_show select _forEachIndex),false] select GVAR(showMap));
|
|
||||||
} forEach _elements;
|
|
||||||
} else {
|
|
||||||
{
|
|
||||||
(_display displayCtrl _x) ctrlShow GVAR(showInterface);
|
|
||||||
} forEach _elements;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Map and help operate seperate from interface
|
|
||||||
(_display displayCtrl IDC_HELP) ctrlShow GVAR(showHelp);
|
(_display displayCtrl IDC_HELP) ctrlShow GVAR(showHelp);
|
||||||
(_display displayCtrl IDC_MAP) ctrlShow GVAR(showMap);
|
(_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];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user