diff --git a/addons/dagr/XEH_postInit.sqf b/addons/dagr/XEH_postInit.sqf index 17fa744074..39f2a7ea28 100644 --- a/addons/dagr/XEH_postInit.sqf +++ b/addons/dagr/XEH_postInit.sqf @@ -1,5 +1,7 @@ #include "script_component.hpp" +if (!hasInterface) exitWith {}; + #include "initKeybinds.sqf" GVAR(outputPFH) = -1; diff --git a/addons/dagr/functions/fnc_menuInit.sqf b/addons/dagr/functions/fnc_menuInit.sqf index ae1eed9a2b..739f41df0b 100644 --- a/addons/dagr/functions/fnc_menuInit.sqf +++ b/addons/dagr/functions/fnc_menuInit.sqf @@ -69,7 +69,7 @@ GVAR(showOutOfSpace) = false; GVAR(PWR) = false; GVAR(menuRun) = true; [{ - if (!dialog || GVAR(PWR)) exitWith { + if (!dialog || GVAR(PWR) || !GVAR(menuRun)) exitWith { closeDialog 266860; GVAR(menuRun) = false; [_this select 1] call CBA_fnc_removePerFrameHandler; diff --git a/addons/dagr/functions/fnc_toggleOverlay.sqf b/addons/dagr/functions/fnc_toggleOverlay.sqf index b05cb23fe5..1fcb87d0ff 100644 --- a/addons/dagr/functions/fnc_toggleOverlay.sqf +++ b/addons/dagr/functions/fnc_toggleOverlay.sqf @@ -17,6 +17,10 @@ GVAR(run) = !GVAR(run); if (GVAR(run)) then { + if (GVAR(menuRun) && dialog) then { + GVAR(menuRun) = false; + closeDialog 0; + }; GVAR(hidden) = true; [{ EXPLODE_1_PVT(_this select 0,_vehicle); diff --git a/addons/dagr/initKeybinds.sqf b/addons/dagr/initKeybinds.sqf index ce4f3cf568..5fbee3a3b4 100644 --- a/addons/dagr/initKeybinds.sqf +++ b/addons/dagr/initKeybinds.sqf @@ -28,3 +28,32 @@ }, {false}, [0, [false, false, false]], false] call cba_fnc_addKeybind; // (empty default key) + +//Add deviceKey entry: +private ["_conditonCode", "_toggleCode", "_closeCode"]; +_conditonCode = { + ([ACE_player, "ACE_DAGR"] call EFUNC(common,hasItem)); +}; +_toggleCode = { + // Conditions: canInteract + if !([ACE_player, objNull, []] call EFUNC(common,canInteractWith)) exitWith {}; + + // Statement + [] call FUNC(toggleOverlay); + if (!GVAR(run)) then { + [] call FUNC(menuInit); + }; +}; +_closeCode = { + // Statement + if (GVAR(run)) then { + //If dispaly is open, close it: + [] call FUNC(toggleOverlay); + }; + if (dialog && GVAR(menuRun)) then { + //If dialog is open, close it: + GVAR(menuRun) = false; + closeDialog 0; + }; +}; +["DAGR", QUOTE(PATHTOF(UI\DAGR_Icon.paa)), _conditonCode, _toggleCode, _closeCode] call EFUNC(common,deviceKeyRegisterNew);