Handle escape menu with toggle iteractMenu (#5144)

* Handle escape menu with toggle iteractMenu

* Work on non-cursor menu

* Close cursor menu if open when switching

* Update fnc_handleEscapeMenu.sqf
This commit is contained in:
PabstMirror 2017-05-31 11:41:53 -05:00 committed by GitHub
parent e6a291bc3b
commit bdab342548
4 changed files with 43 additions and 1 deletions

View File

@ -29,4 +29,10 @@ class Extended_DisplayLoad_EventHandlers {
class RscDiary {
ADDON = QUOTE(call COMPILE_FILE(XEH_displayLoad));
};
class RscDisplayInterrupt {
ADDON = QUOTE(_this call FUNC(handleEscapeMenu));
};
class RscDisplayMPInterrupt {
ADDON = QUOTE(_this call FUNC(handleEscapeMenu));
};
};

View File

@ -9,6 +9,7 @@ PREP(collectActiveActionTree);
PREP(createAction);
PREP(ctrlSetParsedTextCached);
PREP(findActionNode);
PREP(handleEscapeMenu);
PREP(isSubPath);
PREP(keyDown);
PREP(keyUp);

View File

@ -0,0 +1,25 @@
/*
* Author: PabstMirror
* Handle the escape key being pressed.
*
* Arguments:
* 0: Escape menu display that should be closed <DISPLAY><OPTIONAL>
*
* Return Value:
* Nothing
*
* Public: No
*/
#include "script_component.hpp"
if (GVAR(openedMenuType) < 0) exitWith {};
params [["_display", displayNull, [displayNull]]];
TRACE_2("handleEscapeMenu",_display,isNull _display);
if (!isNull _display) then {
_display closeDisplay 0;
};
GVAR(actionSelected) = false;
[GVAR(openedMenuType), false] call FUNC(keyUp);

View File

@ -59,7 +59,13 @@ if (GVAR(useCursorMenu)) then {
createDialog QGVAR(cursorMenu);
};
(finddisplay 91919) displayAddEventHandler ["KeyUp", {[_this,'keyup'] call CBA_events_fnc_keyHandler}];
(finddisplay 91919) displayAddEventHandler ["KeyDown", {[_this,'keydown'] call CBA_events_fnc_keyHandler}];
(finddisplay 91919) displayAddEventHandler ["KeyDown", {
// Handle the escape key being pressed with menu open:
if ((_this select [1,4]) isEqualTo [1,false,false,false]) exitWith { // escape key with no modifiers
[displayNull] call FUNC(handleEscapeMenu);
};
[_this,'keydown'] call CBA_events_fnc_keyHandler;
}];
// The dialog sets:
// uiNamespace getVariable QGVAR(dlgCursorMenu);
// uiNamespace getVariable QGVAR(cursorMenuOpened);
@ -73,6 +79,10 @@ if (GVAR(useCursorMenu)) then {
((finddisplay 91919) displayctrl 9922) ctrlAddEventHandler ["MouseMoving", DFUNC(handleMouseMovement)];
((finddisplay 91919) displayctrl 9922) ctrlAddEventHandler ["MouseButtonDown", DFUNC(handleMouseButtonDown)];
setMousePosition [0.5, 0.5];
} else {
if (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]) then {
(findDisplay 91919) closeDisplay 2;
};
};
GVAR(selfMenuOffset) = (AGLtoASL (positionCameraToWorld [0, 0, 2])) vectorDiff (AGLtoASL (positionCameraToWorld [0, 0, 0]));