2015-02-21 20:11:03 +00:00
|
|
|
/*
|
2015-03-24 04:18:00 +00:00
|
|
|
* Author: NouberNou and esteldunedain
|
2015-02-21 20:11:03 +00:00
|
|
|
* Render all available nearby interactions
|
|
|
|
*
|
|
|
|
* Argument:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Return value:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-01-18 18:38:27 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-03-23 21:08:31 +00:00
|
|
|
BEGIN_COUNTER(fnc_render);
|
|
|
|
|
2015-01-18 18:38:27 +00:00
|
|
|
private ["_cursorPos1", "_cursorPos2", "_cursorVec", "_p1", "_p2", "_p", "_v", "_cp", "_forEachIndex", "_renderTargets", "_x", "_cursorScreenPos", "_closestDistance", "_closestSelection", "_pos", "_sPos", "_disSq", "_closest", "_cTime", "_delta", "_foundTarget", "_misMatch", "_hoverPath", "_i"];
|
|
|
|
_foundTarget = false;
|
|
|
|
_cursorPos1 = positionCameraToWorld [0, 0, 0];
|
|
|
|
_cursorPos2 = positionCameraToWorld [0, 0, 2];
|
2015-02-27 04:55:16 +00:00
|
|
|
|
|
|
|
|
2015-03-24 15:27:27 +00:00
|
|
|
if (GVAR(openedMenuType) >= 0) then {
|
|
|
|
// Render all available nearby interactions
|
|
|
|
call FUNC(renderActionPoints);
|
2015-02-27 04:55:16 +00:00
|
|
|
|
2015-02-28 20:48:46 +00:00
|
|
|
// Draw the red selector only when there's no cursor
|
|
|
|
if !(uiNamespace getVariable [QGVAR(cursorMenuOpened),false]) then {
|
2015-03-23 22:16:10 +00:00
|
|
|
[[0.5,0.5], "\a3\ui_f\data\IGUI\Cfg\Cursors\selected_ca.paa"] call FUNC(renderSelector);
|
2015-02-28 20:48:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
_cursorScreenPos = [worldToScreen _cursorPos2, GVAR(cursorPos)] select (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]);
|
2015-02-18 21:58:06 +00:00
|
|
|
|
2015-02-19 13:49:36 +00:00
|
|
|
_closestDistance = 1000000;
|
|
|
|
_closestSelection = -1;
|
|
|
|
{
|
2015-03-23 21:08:31 +00:00
|
|
|
_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;
|
|
|
|
_closestSelection = _forEachIndex;
|
2015-02-19 13:49:36 +00:00
|
|
|
};
|
|
|
|
} forEach GVAR(currentOptions);
|
2015-02-18 21:58:06 +00:00
|
|
|
|
|
|
|
|
2015-02-27 04:55:16 +00:00
|
|
|
if(_closestSelection == -1) exitWith {};
|
2015-02-18 21:58:06 +00:00
|
|
|
|
2015-02-27 04:55:16 +00:00
|
|
|
_closest = GVAR(currentOptions) select _closestSelection;
|
2015-02-18 21:58:06 +00:00
|
|
|
|
2015-03-23 21:08:31 +00:00
|
|
|
_sPos = _closest select 1;
|
2015-02-27 04:55:16 +00:00
|
|
|
_cTime = diag_tickTime;
|
|
|
|
_delta = _cTime - GVAR(lastTime);
|
|
|
|
GVAR(lastTime) = _cTime;
|
2015-03-23 21:08:31 +00:00
|
|
|
|
|
|
|
GVAR(rotationAngle) = (GVAR(rotationAngle) + (270*_delta)) mod 360;
|
2015-03-23 22:16:10 +00:00
|
|
|
[_sPos, format [QUOTE(PATHTOF(ui\selector%1.paa)), floor (((abs GVAR(rotationAngle)) mod 90) / 6)]] call FUNC(renderSelector);
|
2015-03-23 21:08:31 +00:00
|
|
|
|
2015-02-27 04:55:16 +00:00
|
|
|
_foundTarget = true;
|
|
|
|
GVAR(actionSelected) = true;
|
2015-03-11 03:21:05 +00:00
|
|
|
GVAR(selectedAction) = (_closest select 0) select 1;
|
2015-03-17 03:37:28 +00:00
|
|
|
GVAR(selectedTarget) = (GVAR(selectedAction)) select 2;
|
2015-03-11 03:21:05 +00:00
|
|
|
|
2015-02-27 04:55:16 +00:00
|
|
|
_misMatch = false;
|
|
|
|
_hoverPath = (_closest select 2);
|
2015-03-03 02:29:57 +00:00
|
|
|
|
2015-02-27 04:55:16 +00:00
|
|
|
if((count GVAR(lastPath)) != (count _hoverPath)) then {
|
|
|
|
_misMatch = true;
|
|
|
|
} else {
|
|
|
|
{
|
2015-03-17 03:37:28 +00:00
|
|
|
if !(_x isEqualTo (_hoverPath select _forEachIndex)) exitWith {
|
2015-02-27 04:55:16 +00:00
|
|
|
_misMatch = true;
|
2015-02-19 13:49:36 +00:00
|
|
|
};
|
2015-02-27 04:55:16 +00:00
|
|
|
} forEach GVAR(lastPath);
|
|
|
|
};
|
|
|
|
|
2015-03-21 12:37:01 +00:00
|
|
|
if(_misMatch && {diag_tickTime-GVAR(expandedTime) > 0.25}) then {
|
2015-02-27 04:55:16 +00:00
|
|
|
GVAR(startHoverTime) = diag_tickTime;
|
2015-03-21 12:37:01 +00:00
|
|
|
GVAR(lastPath) = _hoverPath;
|
2015-02-27 04:55:16 +00:00
|
|
|
GVAR(expanded) = false;
|
|
|
|
} else {
|
|
|
|
if(!GVAR(expanded) && diag_tickTime-GVAR(startHoverTime) > 0.25) then {
|
|
|
|
GVAR(expanded) = true;
|
2015-03-21 12:37:01 +00:00
|
|
|
|
|
|
|
// Start the expanding menu animation only if the user is not going up the menu
|
|
|
|
if !([GVAR(menuDepthPath),GVAR(lastPath)] call FUNC(isSubPath)) then {
|
|
|
|
GVAR(expandedTime) = diag_tickTime;
|
|
|
|
};
|
2015-02-27 04:55:16 +00:00
|
|
|
GVAR(menuDepthPath) = +GVAR(lastPath);
|
2015-03-11 02:45:46 +00:00
|
|
|
|
2015-03-11 03:39:23 +00:00
|
|
|
// Execute the current action if it's run on hover
|
|
|
|
private "_runOnHover";
|
2015-03-20 02:32:44 +00:00
|
|
|
_runOnHover = ((GVAR(selectedAction) select 0) select 9) select 3;
|
2015-03-11 03:39:23 +00:00
|
|
|
if (_runOnHover) then {
|
2015-03-11 02:45:46 +00:00
|
|
|
this = GVAR(selectedTarget);
|
|
|
|
_player = ACE_Player;
|
|
|
|
_target = GVAR(selectedTarget);
|
2015-03-21 23:30:27 +00:00
|
|
|
|
|
|
|
// Clear the conditions caches
|
|
|
|
["clearConditionCaches", []] call EFUNC(common,localEvent);
|
|
|
|
|
|
|
|
// Check the action conditions
|
|
|
|
_actionData = GVAR(selectedAction) select 0;
|
|
|
|
if ([_target, _player, _actionData select 6] call (_actionData select 4)) then {
|
2015-03-21 23:37:01 +00:00
|
|
|
// Call the statement
|
2015-03-21 23:30:27 +00:00
|
|
|
[_target, _player, _actionData select 6] call (_actionData select 3);
|
2015-03-21 23:37:01 +00:00
|
|
|
|
|
|
|
// Clear the conditions caches again if the action was performed
|
|
|
|
["clearConditionCaches", []] call EFUNC(common,localEvent);
|
2015-03-21 23:30:27 +00:00
|
|
|
};
|
2015-03-11 02:45:46 +00:00
|
|
|
};
|
2015-02-19 13:49:36 +00:00
|
|
|
};
|
|
|
|
};
|
2015-01-18 18:38:27 +00:00
|
|
|
};
|
2015-02-27 04:55:16 +00:00
|
|
|
|
2015-01-18 18:38:27 +00:00
|
|
|
if(!_foundTarget && GVAR(actionSelected)) then {
|
2015-02-19 13:49:36 +00:00
|
|
|
GVAR(actionSelected) = false;
|
|
|
|
GVAR(expanded) = false;
|
|
|
|
GVAR(lastPath) = [];
|
2015-01-18 18:38:27 +00:00
|
|
|
};
|
|
|
|
for "_i" from GVAR(iconCount) to (count GVAR(iconCtrls))-1 do {
|
2015-02-19 13:49:36 +00:00
|
|
|
ctrlDelete (GVAR(iconCtrls) select _i);
|
2015-01-18 18:38:27 +00:00
|
|
|
};
|
|
|
|
GVAR(iconCtrls) resize GVAR(iconCount);
|
|
|
|
GVAR(iconCount) = 0;
|
2015-03-23 21:08:31 +00:00
|
|
|
|
|
|
|
END_COUNTER(fnc_render);
|