From a6373e936da59b74b10483b2b2fc21e6554fa68d Mon Sep 17 00:00:00 2001 From: commy2 Date: Sun, 23 Feb 2020 11:59:14 +0100 Subject: [PATCH] fix MenuClosed event may not fire on menu type replacement --- addons/interact_menu/XEH_clientInit.sqf | 1 + addons/interact_menu/functions/fnc_keyDown.sqf | 6 ++++++ addons/interact_menu/functions/fnc_keyUp.sqf | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/interact_menu/XEH_clientInit.sqf b/addons/interact_menu/XEH_clientInit.sqf index 30b6a4469a..bc4870ef54 100644 --- a/addons/interact_menu/XEH_clientInit.sqf +++ b/addons/interact_menu/XEH_clientInit.sqf @@ -105,6 +105,7 @@ format ["%1 (%2)", (localize LSTRING(SelfInteractKey)), localize ELSTRING(common if (_menuBackgroundSetting == 1) exitWith {[QGVAR(menuBackground), true] call EFUNC(common,blurScreen);}; if (_menuBackgroundSetting == 2) exitWith {0 cutRsc [QGVAR(menuBackground), "PLAIN", 1, false];}; }] call CBA_fnc_addEventHandler; + ["ace_interactMenuClosed", { params ["_menuType"]; private _menuBackgroundSetting = [GVAR(menuBackground), GVAR(menuBackgroundSelf)] select _menuType; diff --git a/addons/interact_menu/functions/fnc_keyDown.sqf b/addons/interact_menu/functions/fnc_keyDown.sqf index 8460e338e8..c080fa4481 100644 --- a/addons/interact_menu/functions/fnc_keyDown.sqf +++ b/addons/interact_menu/functions/fnc_keyDown.sqf @@ -36,6 +36,12 @@ if (_menuType == 0) then { GVAR(keyDownSelfAction) = true; }; GVAR(keyDownTime) = diag_tickTime; + +// Raise MenuClosed event whenever one type is replaced with another, because KeyUp code is not guaranteed. +if (GVAR(openedMenuType) != -1) then { + ["ace_interactMenuClosed", [GVAR(openedMenuType)]] call CBA_fnc_localEvent; +}; + GVAR(openedMenuType) = _menuType; GVAR(lastTimeSearchedActions) = -1000; GVAR(ParsedTextCached) = []; diff --git a/addons/interact_menu/functions/fnc_keyUp.sqf b/addons/interact_menu/functions/fnc_keyUp.sqf index be98452177..2504ca2b78 100644 --- a/addons/interact_menu/functions/fnc_keyUp.sqf +++ b/addons/interact_menu/functions/fnc_keyUp.sqf @@ -24,7 +24,7 @@ if (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]) then { (findDisplay 91919) closeDisplay 2; }; -if(GVAR(actionSelected)) then { +if (GVAR(actionSelected)) then { this = GVAR(selectedTarget); private _player = ACE_Player;