From 664d08d4aa729767d366c855c38af199d3139f76 Mon Sep 17 00:00:00 2001 From: commy2 Date: Sat, 25 Apr 2015 08:23:54 +0200 Subject: [PATCH] add option to only use action when clicking --- addons/interact_menu/XEH_clientInit.sqf | 6 ++---- addons/interact_menu/config.cpp | 12 +++++++++--- .../functions/fnc_handlePlayerChanged.sqf | 6 +++++- addons/interact_menu/functions/fnc_keyUp.sqf | 6 ++++++ addons/interact_menu/stringtable.xml | 6 +++++- 5 files changed, 27 insertions(+), 9 deletions(-) diff --git a/addons/interact_menu/XEH_clientInit.sqf b/addons/interact_menu/XEH_clientInit.sqf index b8a8fc899b..1a7dba3065 100644 --- a/addons/interact_menu/XEH_clientInit.sqf +++ b/addons/interact_menu/XEH_clientInit.sqf @@ -32,8 +32,7 @@ addMissionEventHandler ["Draw3D", DFUNC(render)]; if !([ACE_player, objNull, ["isNotInside","isNotDragging", "isNotCarrying", "isNotSwimming", "notOnMap", "isNotEscorting", "isNotSurrendering"]] call EFUNC(common,canInteractWith)) exitWith {false}; // Statement [0] call FUNC(keyDown) -}, -{[0] call FUNC(keyUp)}, +},{[0,false] call FUNC(keyUp)}, [219, [false, false, false]], false] call cba_fnc_addKeybind; //Left Windows Key ["ACE3", QGVAR(SelfInteractKey), (localize "STR_ACE_Interact_Menu_SelfInteractKey"), @@ -42,8 +41,7 @@ addMissionEventHandler ["Draw3D", DFUNC(render)]; if !([ACE_player, objNull, ["isNotInside","isNotDragging", "isNotCarrying", "isNotSwimming", "notOnMap", "isNotEscorting", "isNotSurrendering"]] call EFUNC(common,canInteractWith)) exitWith {false}; // Statement [1] call FUNC(keyDown) -}, -{[1] call FUNC(keyUp)}, +},{[1,false] call FUNC(keyUp)}, [219, [false, true, false]], false] call cba_fnc_addKeybind; //Left Windows Key + Ctrl/Strg diff --git a/addons/interact_menu/config.cpp b/addons/interact_menu/config.cpp index c79c9cd6d1..5ca0ebdc5f 100644 --- a/addons/interact_menu/config.cpp +++ b/addons/interact_menu/config.cpp @@ -42,25 +42,31 @@ class ACE_Settings { typeName = "COLOR"; isClientSettable = 1; displayName = "$STR_ACE_Interact_Menu_ColorTextMax"; - }; + }; class GVAR(colorTextMin) { value[] = {1, 1, 1, 0.25}; typeName = "COLOR"; isClientSettable = 1; displayName = "$STR_ACE_Interact_Menu_ColorTextMin"; - }; + }; class GVAR(colorShadowMax) { value[] = {0, 0, 0, 1}; typeName = "COLOR"; isClientSettable = 1; displayName = "$STR_ACE_Interact_Menu_ColorShadowMax"; - }; + }; class GVAR(colorShadowMin) { value[] = {0, 0, 0, 0.25}; typeName = "COLOR"; isClientSettable = 1; displayName = "$STR_ACE_Interact_Menu_ColorShadowMin"; }; + class GVAR(actionOnKeyRelease) { + value = 1; + typeName = "BOOL"; + isClientSettable = 1; + displayName = "$STR_ACE_Interact_Menu_ActionOnKeyRelease"; + }; }; class ACE_Extensions { diff --git a/addons/interact_menu/functions/fnc_handlePlayerChanged.sqf b/addons/interact_menu/functions/fnc_handlePlayerChanged.sqf index fe25853733..f1f6e78f6d 100644 --- a/addons/interact_menu/functions/fnc_handlePlayerChanged.sqf +++ b/addons/interact_menu/functions/fnc_handlePlayerChanged.sqf @@ -15,7 +15,11 @@ EXPLODE_2_PVT(_this,_newUnit,_oldUnit); // add to new unit private "_ehid"; -_ehid = [_newUnit, "DefaultAction", {EGVAR(interact_menu,openedMenuType) >= 0}, {}] call EFUNC(common,addActionEventHandler); +_ehid = [_newUnit, "DefaultAction", {GVAR(openedMenuType) >= 0}, { + if !(GVAR(actionOnKeyRelease)) then { + [GVAR(openedMenuType),true] call FUNC(keyUp); + }; +}] call EFUNC(common,addActionEventHandler); _newUnit setVariable [QGVAR(AAEHID), _ehid]; diff --git a/addons/interact_menu/functions/fnc_keyUp.sqf b/addons/interact_menu/functions/fnc_keyUp.sqf index 735130e69a..7b24497802 100644 --- a/addons/interact_menu/functions/fnc_keyUp.sqf +++ b/addons/interact_menu/functions/fnc_keyUp.sqf @@ -12,6 +12,9 @@ */ #include "script_component.hpp" +private "_calledByClicking"; +_calledByClicking = _this select 1; + // Exit if there's no menu opened if (GVAR(openedMenuType) < 0) exitWith {true}; @@ -29,6 +32,9 @@ if(GVAR(actionSelected)) then { // Clear the conditions caches ["clearConditionCaches", []] call EFUNC(common,localEvent); + // exit scope if selecting an action on key release is disabled + if (!(GVAR(actionOnKeyRelease)) && !_calledByClicking) exitWith {}; + // Check the action conditions _actionData = GVAR(selectedAction) select 0; if ([_target, _player, _actionData select 6] call (_actionData select 4)) then { diff --git a/addons/interact_menu/stringtable.xml b/addons/interact_menu/stringtable.xml index 55d67788f4..d9e2e1366b 100644 --- a/addons/interact_menu/stringtable.xml +++ b/addons/interact_menu/stringtable.xml @@ -83,5 +83,9 @@ Interaction - Shadow Min + + Do action when releasing menu key + Aktion nach Loslassen der Taste ausführen + - \ No newline at end of file +