Merge pull request #2777 from acemod/interactionAnimationSetting

Interaction Menu Animation Setting And PreExpand First Level
This commit is contained in:
PabstMirror 2015-11-20 14:56:37 -06:00
commit 063042cb36
5 changed files with 58 additions and 41 deletions

View File

@ -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"};
};
};

View File

@ -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

View File

@ -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;
private _foundTarget = false;
if (GVAR(openedMenuType) >= 0) then {
// _cursorPos1 = positionCameraToWorld [0, 0, 2];
_cursorPos2 = positionCameraToWorld [0, 0, 2];
BEGIN_COUNTER(fnc_renderMenuOpen);
private _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]);
private _cursorScreenPos = [worldToScreen _cursorPos2, GVAR(cursorPos)] select (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]);
_closestDistance = 1000000;
_closestSelection = -1;
private _closestDistance = 1000000;
private _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"];
private _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;
private _closest = GVAR(currentOptions) select _closestSelection;
_closest params ["_action", "_sPos", "_hoverPath"];
_sPos = _closest select 1;
_cTime = ACE_diagTime;
_delta = _cTime - GVAR(lastTime);
private _cTime = ACE_diagTime;
private _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);
private _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;
private _tmp = ((GVAR(selectedAction) select 0) select 9) select 3;
private _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);
private _player = ACE_Player;
private _target = GVAR(selectedTarget);
// Clear the conditions caches
["clearConditionCaches", []] call EFUNC(common,localEvent);
// Check the action conditions
_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);
@ -121,6 +107,7 @@ if (GVAR(openedMenuType) >= 0) then {
};
};
};
END_COUNTER(fnc_renderMenuOpen);
};
if(!_foundTarget && GVAR(actionSelected)) then {

View File

@ -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;

View File

@ -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>