From 7db5a34b249eef43c3d02b999b0344dc7ec92a8b Mon Sep 17 00:00:00 2001
From: PabstMirror <pabstmirror@gmail.com>
Date: Tue, 20 Oct 2015 13:26:42 -0500
Subject: [PATCH 1/4] Interaction Menu - Add setting for animation speed

---
 addons/interact_menu/ACE_Settings.hpp         |  9 +++
 addons/interact_menu/functions/fnc_render.sqf | 63 ++++++++-----------
 .../functions/fnc_renderMenu.sqf              |  6 +-
 addons/interact_menu/stringtable.xml          |  6 ++
 4 files changed, 43 insertions(+), 41 deletions(-)

diff --git a/addons/interact_menu/ACE_Settings.hpp b/addons/interact_menu/ACE_Settings.hpp
index 381405987c..2d516ee6e3 100644
--- a/addons/interact_menu/ACE_Settings.hpp
+++ b/addons/interact_menu/ACE_Settings.hpp
@@ -96,4 +96,13 @@ class ACE_Settings {
         displayName = CSTRING(addBuildingActions);
         description = CSTRING(addBuildingActionsDescription);
     };
+    class GVAR(menuAnimationSpeed) {
+        value = 0;
+        typeName = "SCALAR";
+        isClientSettable = 1;
+        category = CSTRING(Category_InteractionMenu);
+        displayName = CSTRING(menuAnimationSpeed);
+        description = CSTRING(menuAnimationSpeed_Description);
+        values[] = {"$str_speed_normal", "2x", "3x (gotta go fast)"};
+    };
 };
diff --git a/addons/interact_menu/functions/fnc_render.sqf b/addons/interact_menu/functions/fnc_render.sqf
index 54f197a2a3..0addd42483 100644
--- a/addons/interact_menu/functions/fnc_render.sqf
+++ b/addons/interact_menu/functions/fnc_render.sqf
@@ -14,13 +14,12 @@
 
 BEGIN_COUNTER(fnc_render);
 
-private ["_cursorPos2", "_p1", "_p2", "_forEachIndex", "_x", "_cursorScreenPos", "_closestDistance", "_closestSelection", "_sPos", "_disSq", "_closest", "_cTime", "_delta", "_foundTarget", "_misMatch", "_hoverPath", "_i", "_actionData", "_player", "_target"];
-
-_foundTarget = false;
+local _foundTarget = false;
 
 if (GVAR(openedMenuType) >= 0) then {
-    // _cursorPos1 = positionCameraToWorld [0, 0, 2];
-    _cursorPos2 = positionCameraToWorld [0, 0, 2];
+    BEGIN_COUNTER(fnc_renderMenuOpen);
+
+    local _cursorPos2 = positionCameraToWorld [0, 0, 2];
 
     // Render all available nearby interactions
     call FUNC(renderActionPoints);
@@ -30,27 +29,26 @@ if (GVAR(openedMenuType) >= 0) then {
         [[0.5,0.5], "\a3\ui_f\data\IGUI\Cfg\Cursors\selected_ca.paa"] call FUNC(renderSelector);
     };
 
-    _cursorScreenPos = [worldToScreen _cursorPos2, GVAR(cursorPos)] select (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]);
+    local _cursorScreenPos = [worldToScreen _cursorPos2, GVAR(cursorPos)] select (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]);
 
-    _closestDistance = 1000000;
-    _closestSelection = -1;
+    local _closestDistance = 1000000;
+    local _closestSelection = -1;
     {
-        _sPos = _x select 1;
-        _disSq = (((_cursorScreenPos select 0) - (_sPos select 0))^2 + ((_cursorScreenPos select 1) - (_sPos select 1))^2);
-        if(_disSq < 0.0125 && _disSq < _closestDistance) then {
-            _closestDistance = _disSq;
+        _x params ["", "_sPos"];
+        local _distanceFromCursor = _cursorScreenPos distance2d _sPos;
+        if ((_distanceFromCursor < 0.1118) && {_distanceFromCursor < _closestDistance}) then {
+            _closestDistance = _distanceFromCursor;
             _closestSelection = _forEachIndex;
         };
     } forEach GVAR(currentOptions);
 
-
     if(_closestSelection == -1) exitWith {};
 
-    _closest = GVAR(currentOptions) select _closestSelection;
+    local _closest = GVAR(currentOptions) select _closestSelection;
+    _closest params ["_action", "_sPos", "_hoverPath"];
 
-    _sPos = _closest select 1;
-    _cTime = ACE_diagTime;
-    _delta = _cTime - GVAR(lastTime);
+    local _cTime = ACE_diagTime;
+    local _delta = _cTime - GVAR(lastTime);
     GVAR(lastTime) = _cTime;
 
     GVAR(rotationAngle) = (GVAR(rotationAngle) + (270*_delta)) mod 360;
@@ -58,28 +56,17 @@ if (GVAR(openedMenuType) >= 0) then {
 
     _foundTarget = true;
     GVAR(actionSelected) = true;
-    GVAR(selectedAction) = (_closest select 0) select 1;
+    GVAR(selectedAction) = _action select 1;
     GVAR(selectedTarget) = (GVAR(selectedAction)) select 2;
 
-    _misMatch = false;
-    _hoverPath = (_closest select 2);
+    local _misMatch = !(GVAR(lastPath) isEqualTo _hoverPath);
 
-    if((count GVAR(lastPath)) != (count _hoverPath)) then {
-        _misMatch = true;
-    } else {
-        {
-            if !(_x isEqualTo (_hoverPath select _forEachIndex)) exitWith {
-                _misMatch = true;
-            };
-        } forEach GVAR(lastPath);
-    };
-
-    if(_misMatch && {ACE_diagTime-GVAR(expandedTime) > 0.25}) then {
+    if(_misMatch && {ACE_diagTime-GVAR(expandedTime) > linearConversion [0, 2, GVAR(menuAnimationSpeed), 0.25, 0.08333333]}) then {
         GVAR(startHoverTime) = ACE_diagTime;
         GVAR(lastPath) = _hoverPath;
         GVAR(expanded) = false;
     } else {
-        if(!GVAR(expanded) && ACE_diagTime-GVAR(startHoverTime) > 0.25) then {
+        if(!GVAR(expanded) && {ACE_diagTime-GVAR(startHoverTime) > linearConversion [0, 2, GVAR(menuAnimationSpeed), 0.25, 0.08333333]}) then {
             GVAR(expanded) = true;
 
             // Start the expanding menu animation only if the user is not going up the menu
@@ -89,9 +76,8 @@ if (GVAR(openedMenuType) >= 0) then {
             GVAR(menuDepthPath) = +GVAR(lastPath);
 
             // Execute the current action if it's run on hover
-            private "_runOnHover";
-            _tmp = ((GVAR(selectedAction) select 0) select 9) select 3;
-            _runOnHover = true;
+            local _tmp = ((GVAR(selectedAction) select 0) select 9) select 3;
+            local _runOnHover = true;
             if ((typeName _tmp) == "CODE" ) then {
                 _runOnHover = call _tmp;
             } else {
@@ -103,14 +89,14 @@ if (GVAR(openedMenuType) >= 0) then {
             };
             if (_runOnHover) then {
                 this = GVAR(selectedTarget);
-                _player = ACE_Player;
-                _target = GVAR(selectedTarget);
+                local _player = ACE_Player;
+                local _target = GVAR(selectedTarget);
 
                 // Clear the conditions caches
                 ["clearConditionCaches", []] call EFUNC(common,localEvent);
 
                 // Check the action conditions
-                _actionData = GVAR(selectedAction) select 0;
+                local _actionData = GVAR(selectedAction) select 0;
                 if ([_target, _player, _actionData select 6] call (_actionData select 4)) then {
                     // Call the statement
                     [_target, _player, _actionData select 6] call (_actionData select 3);
@@ -121,6 +107,7 @@ if (GVAR(openedMenuType) >= 0) then {
             };
         };
     };
+    END_COUNTER(fnc_renderMenuOpen);
 };
 
 if(!_foundTarget && GVAR(actionSelected)) then {
diff --git a/addons/interact_menu/functions/fnc_renderMenu.sqf b/addons/interact_menu/functions/fnc_renderMenu.sqf
index 21c434fe03..8b8ae963d9 100644
--- a/addons/interact_menu/functions/fnc_renderMenu.sqf
+++ b/addons/interact_menu/functions/fnc_renderMenu.sqf
@@ -101,9 +101,9 @@ if (GVAR(UseListMenu)) then {
 };
 
 // Animate menu scale
-if (_menuInSelectedPath && (_menuDepth == count _path)) then {
-    _scaleX = _scaleX * (0.3 + 0.7 * (((ACE_diagTime - GVAR(expandedTime)) * 8) min 1));
-    _scaleY = _scaleY * (0.3 + 0.7 * (((ACE_diagTime - GVAR(expandedTime)) * 8) min 1));
+if (_menuInSelectedPath && {_menuDepth == count _path}) then {
+    _scaleX = _scaleX * (0.3 + 0.7 * (((ACE_diagTime - GVAR(expandedTime)) * linearConversion [0, 2, GVAR(menuAnimationSpeed), 8, 16]) min 1));
+    _scaleY = _scaleY * (0.3 + 0.7 * (((ACE_diagTime - GVAR(expandedTime)) * linearConversion [0, 2, GVAR(menuAnimationSpeed), 8, 16]) min 1));
 };
 
 _target = _actionObject;
diff --git a/addons/interact_menu/stringtable.xml b/addons/interact_menu/stringtable.xml
index 42966c43c1..37da2aa95c 100644
--- a/addons/interact_menu/stringtable.xml
+++ b/addons/interact_menu/stringtable.xml
@@ -299,5 +299,11 @@
             <Czech>Menu interakce</Czech>
             <Spanish>Menú de interacción</Spanish>
         </Key>
+        <Key ID="STR_ACE_Interact_Menu_menuAnimationSpeed">
+            <English>Interaction Animation Speed</English>
+        </Key>
+        <Key ID="STR_ACE_Interact_Menu_menuAnimationSpeed_Description">
+            <English>Makes menu animations faster and decreases the time needed to hover to show sub actions</English>
+        </Key>
     </Package>
 </Project>

From 554c303be07b085430fc1892c545b0d35d55acaf Mon Sep 17 00:00:00 2001
From: PabstMirror <pabstmirror@gmail.com>
Date: Tue, 20 Oct 2015 13:31:09 -0500
Subject: [PATCH 2/4] InteractionMenu - Auto Expand First Level

---
 addons/interact_menu/functions/fnc_keyDown.sqf | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/addons/interact_menu/functions/fnc_keyDown.sqf b/addons/interact_menu/functions/fnc_keyDown.sqf
index 8c8ecf0c20..56c0e6e19c 100644
--- a/addons/interact_menu/functions/fnc_keyDown.sqf
+++ b/addons/interact_menu/functions/fnc_keyDown.sqf
@@ -78,6 +78,21 @@ if (GVAR(useCursorMenu)) then {
 GVAR(selfMenuOffset) = ((positionCameraToWorld [0, 0, 2]) call EFUNC(common,positionToASL)) vectorDiff
                        ((positionCameraToWorld [0, 0, 0]) call EFUNC(common,positionToASL));
 
+if (GVAR(menuAnimationSpeed) > 0) then {
+    //Auto expand the first level when self, mounted vehicle or zeus (skips the first animation as there is only one choice)
+    if (GVAR(openedMenuType) == 0) then {
+        if (isNull curatorCamera) then {
+            if (vehicle ACE_player != ACE_player) then {
+                GVAR(menuDepthPath) = [["ACE_SelfActions", (vehicle ACE_player)]];
+            };
+        } else {
+            GVAR(menuDepthPath) = [["ACE_ZeusActions", (getAssignedCuratorLogic player)]];
+        };
+    } else {
+        GVAR(menuDepthPath) = [["ACE_SelfActions", ACE_player]];
+    };
+};                   
+                       
 ["interactMenuOpened", [_menuType]] call EFUNC(common,localEvent);
 
 true

From 3ec9fca73e47fc2c6e7a8cfb8d40bc48ceec6dfd Mon Sep 17 00:00:00 2001
From: PabstMirror <pabstmirror@gmail.com>
Date: Tue, 17 Nov 2015 14:06:12 -0600
Subject: [PATCH 3/4] local -> private

---
 addons/interact_menu/functions/fnc_render.sqf | 30 +++++++++----------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/addons/interact_menu/functions/fnc_render.sqf b/addons/interact_menu/functions/fnc_render.sqf
index 0addd42483..1a14acae07 100644
--- a/addons/interact_menu/functions/fnc_render.sqf
+++ b/addons/interact_menu/functions/fnc_render.sqf
@@ -14,12 +14,12 @@
 
 BEGIN_COUNTER(fnc_render);
 
-local _foundTarget = false;
+private _foundTarget = false;
 
 if (GVAR(openedMenuType) >= 0) then {
     BEGIN_COUNTER(fnc_renderMenuOpen);
 
-    local _cursorPos2 = positionCameraToWorld [0, 0, 2];
+    private _cursorPos2 = positionCameraToWorld [0, 0, 2];
 
     // Render all available nearby interactions
     call FUNC(renderActionPoints);
@@ -29,13 +29,13 @@ if (GVAR(openedMenuType) >= 0) then {
         [[0.5,0.5], "\a3\ui_f\data\IGUI\Cfg\Cursors\selected_ca.paa"] call FUNC(renderSelector);
     };
 
-    local _cursorScreenPos = [worldToScreen _cursorPos2, GVAR(cursorPos)] select (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]);
+    private _cursorScreenPos = [worldToScreen _cursorPos2, GVAR(cursorPos)] select (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]);
 
-    local _closestDistance = 1000000;
-    local _closestSelection = -1;
+    private _closestDistance = 1000000;
+    private _closestSelection = -1;
     {
         _x params ["", "_sPos"];
-        local _distanceFromCursor = _cursorScreenPos distance2d _sPos;
+        private _distanceFromCursor = _cursorScreenPos distance2d _sPos;
         if ((_distanceFromCursor < 0.1118) && {_distanceFromCursor < _closestDistance}) then {
             _closestDistance = _distanceFromCursor;
             _closestSelection = _forEachIndex;
@@ -44,11 +44,11 @@ if (GVAR(openedMenuType) >= 0) then {
 
     if(_closestSelection == -1) exitWith {};
 
-    local _closest = GVAR(currentOptions) select _closestSelection;
+    private _closest = GVAR(currentOptions) select _closestSelection;
     _closest params ["_action", "_sPos", "_hoverPath"];
 
-    local _cTime = ACE_diagTime;
-    local _delta = _cTime - GVAR(lastTime);
+    private _cTime = ACE_diagTime;
+    private _delta = _cTime - GVAR(lastTime);
     GVAR(lastTime) = _cTime;
 
     GVAR(rotationAngle) = (GVAR(rotationAngle) + (270*_delta)) mod 360;
@@ -59,7 +59,7 @@ if (GVAR(openedMenuType) >= 0) then {
     GVAR(selectedAction) = _action select 1;
     GVAR(selectedTarget) = (GVAR(selectedAction)) select 2;
 
-    local _misMatch = !(GVAR(lastPath) isEqualTo _hoverPath);
+    private _misMatch = !(GVAR(lastPath) isEqualTo _hoverPath);
 
     if(_misMatch && {ACE_diagTime-GVAR(expandedTime) > linearConversion [0, 2, GVAR(menuAnimationSpeed), 0.25, 0.08333333]}) then {
         GVAR(startHoverTime) = ACE_diagTime;
@@ -76,8 +76,8 @@ if (GVAR(openedMenuType) >= 0) then {
             GVAR(menuDepthPath) = +GVAR(lastPath);
 
             // Execute the current action if it's run on hover
-            local _tmp = ((GVAR(selectedAction) select 0) select 9) select 3;
-            local _runOnHover = true;
+            private _tmp = ((GVAR(selectedAction) select 0) select 9) select 3;
+            private _runOnHover = true;
             if ((typeName _tmp) == "CODE" ) then {
                 _runOnHover = call _tmp;
             } else {
@@ -89,14 +89,14 @@ if (GVAR(openedMenuType) >= 0) then {
             };
             if (_runOnHover) then {
                 this = GVAR(selectedTarget);
-                local _player = ACE_Player;
-                local _target = GVAR(selectedTarget);
+                private _player = ACE_Player;
+                private _target = GVAR(selectedTarget);
 
                 // Clear the conditions caches
                 ["clearConditionCaches", []] call EFUNC(common,localEvent);
 
                 // Check the action conditions
-                local _actionData = GVAR(selectedAction) select 0;
+                private _actionData = GVAR(selectedAction) select 0;
                 if ([_target, _player, _actionData select 6] call (_actionData select 4)) then {
                     // Call the statement
                     [_target, _player, _actionData select 6] call (_actionData select 3);

From 7b526a99a32add4550d1096bbb3c18adb319b87d Mon Sep 17 00:00:00 2001
From: PabstMirror <pabstmirror@gmail.com>
Date: Fri, 20 Nov 2015 14:53:16 -0600
Subject: [PATCH 4/4] Cleanup

---
 addons/interact_menu/ACE_Settings.hpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/addons/interact_menu/ACE_Settings.hpp b/addons/interact_menu/ACE_Settings.hpp
index 2d516ee6e3..075408499b 100644
--- a/addons/interact_menu/ACE_Settings.hpp
+++ b/addons/interact_menu/ACE_Settings.hpp
@@ -103,6 +103,6 @@ class ACE_Settings {
         category = CSTRING(Category_InteractionMenu);
         displayName = CSTRING(menuAnimationSpeed);
         description = CSTRING(menuAnimationSpeed_Description);
-        values[] = {"$str_speed_normal", "2x", "3x (gotta go fast)"};
+        values[] = {"$str_speed_normal", "2x", "3x"};
     };
 };