2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
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
|
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Arguments:
|
2015-02-21 20:11:03 +00:00
|
|
|
* None
|
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Return Value:
|
2015-02-21 20:11:03 +00:00
|
|
|
* None
|
|
|
|
*
|
2016-01-08 04:43:37 +00:00
|
|
|
* Example:
|
|
|
|
* [] call ace_interact_menu_fnc_render
|
|
|
|
*
|
2015-02-21 20:11:03 +00:00
|
|
|
* Public: No
|
|
|
|
*/
|
2015-01-18 18:38:27 +00:00
|
|
|
|
2015-03-23 21:08:31 +00:00
|
|
|
BEGIN_COUNTER(fnc_render);
|
|
|
|
|
2015-11-17 20:06:12 +00:00
|
|
|
private _foundTarget = false;
|
2015-02-27 04:55:16 +00:00
|
|
|
|
2015-03-24 15:27:27 +00:00
|
|
|
if (GVAR(openedMenuType) >= 0) then {
|
2015-10-20 18:26:42 +00:00
|
|
|
BEGIN_COUNTER(fnc_renderMenuOpen);
|
|
|
|
|
2015-11-17 20:06:12 +00:00
|
|
|
private _cursorPos2 = positionCameraToWorld [0, 0, 2];
|
2015-09-27 03:02:05 +00:00
|
|
|
|
2015-03-24 15:27:27 +00:00
|
|
|
// Render all available nearby interactions
|
|
|
|
call FUNC(renderActionPoints);
|
2015-02-27 04:55:16 +00:00
|
|
|
|
2018-04-28 22:23:44 +00:00
|
|
|
// Draw the selector only when there's no cursor
|
2015-02-28 20:48:46 +00:00
|
|
|
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
|
|
|
};
|
|
|
|
|
2015-11-17 20:06:12 +00:00
|
|
|
private _cursorScreenPos = [worldToScreen _cursorPos2, GVAR(cursorPos)] select (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]);
|
2015-02-18 21:58:06 +00:00
|
|
|
|
2015-11-17 20:06:12 +00:00
|
|
|
private _closestDistance = 1000000;
|
|
|
|
private _closestSelection = -1;
|
2015-02-19 13:49:36 +00:00
|
|
|
{
|
2015-10-20 18:26:42 +00:00
|
|
|
_x params ["", "_sPos"];
|
2015-11-17 20:06:12 +00:00
|
|
|
private _distanceFromCursor = _cursorScreenPos distance2d _sPos;
|
2015-10-20 18:26:42 +00:00
|
|
|
if ((_distanceFromCursor < 0.1118) && {_distanceFromCursor < _closestDistance}) then {
|
|
|
|
_closestDistance = _distanceFromCursor;
|
2015-03-23 21:08:31 +00:00
|
|
|
_closestSelection = _forEachIndex;
|
2015-02-19 13:49:36 +00:00
|
|
|
};
|
|
|
|
} forEach GVAR(currentOptions);
|
2015-02-18 21:58:06 +00:00
|
|
|
|
2016-01-08 04:43:37 +00:00
|
|
|
if (_closestSelection == -1) exitWith {END_COUNTER(fnc_renderMenuOpen);};
|
2015-02-18 21:58:06 +00:00
|
|
|
|
2015-11-17 20:06:12 +00:00
|
|
|
private _closest = GVAR(currentOptions) select _closestSelection;
|
2015-10-20 18:26:42 +00:00
|
|
|
_closest params ["_action", "_sPos", "_hoverPath"];
|
2015-02-18 21:58:06 +00:00
|
|
|
|
2016-03-02 10:01:39 +00:00
|
|
|
private _cTime = diag_tickTime;
|
2015-11-17 20:06:12 +00:00
|
|
|
private _delta = _cTime - GVAR(lastTime);
|
2015-02-27 04:55:16 +00:00
|
|
|
GVAR(lastTime) = _cTime;
|
2015-03-23 21:08:31 +00:00
|
|
|
|
|
|
|
GVAR(rotationAngle) = (GVAR(rotationAngle) + (270*_delta)) mod 360;
|
2016-04-08 18:34:50 +00:00
|
|
|
[_sPos, format [QPATHTOF(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-10-20 18:26:42 +00:00
|
|
|
GVAR(selectedAction) = _action select 1;
|
2015-03-17 03:37:28 +00:00
|
|
|
GVAR(selectedTarget) = (GVAR(selectedAction)) select 2;
|
2015-03-11 03:21:05 +00:00
|
|
|
|
2021-02-27 17:05:05 +00:00
|
|
|
private _misMatch = (GVAR(lastPath) isNotEqualTo _hoverPath);
|
2015-02-27 04:55:16 +00:00
|
|
|
|
2016-03-02 10:01:39 +00:00
|
|
|
if(_misMatch && {diag_tickTime-GVAR(expandedTime) > linearConversion [0, 2, GVAR(menuAnimationSpeed), 0.25, 0.08333333]}) then {
|
|
|
|
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 {
|
2016-03-02 10:01:39 +00:00
|
|
|
if(!GVAR(expanded) && {diag_tickTime-GVAR(startHoverTime) > linearConversion [0, 2, GVAR(menuAnimationSpeed), 0.25, 0.08333333]}) then {
|
2015-02-27 04:55:16 +00:00
|
|
|
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 {
|
2016-03-02 10:01:39 +00:00
|
|
|
GVAR(expandedTime) = diag_tickTime;
|
2015-03-21 12:37:01 +00:00
|
|
|
};
|
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
|
2015-11-17 20:06:12 +00:00
|
|
|
private _tmp = ((GVAR(selectedAction) select 0) select 9) select 3;
|
|
|
|
private _runOnHover = true;
|
2015-11-28 03:23:27 +00:00
|
|
|
if (_tmp isEqualType {}) then {
|
2015-05-28 16:02:31 +00:00
|
|
|
_runOnHover = call _tmp;
|
|
|
|
} else {
|
2015-11-28 03:23:27 +00:00
|
|
|
if (_tmp isEqualType false) then {
|
2015-05-28 16:02:31 +00:00
|
|
|
_runOnHover = _tmp;
|
|
|
|
} else {
|
|
|
|
_runOnHover = _tmp > 0;
|
|
|
|
};
|
|
|
|
};
|
2015-03-11 03:39:23 +00:00
|
|
|
if (_runOnHover) then {
|
2015-11-17 20:06:12 +00:00
|
|
|
private _player = ACE_Player;
|
|
|
|
private _target = GVAR(selectedTarget);
|
2015-03-21 23:30:27 +00:00
|
|
|
|
|
|
|
// Clear the conditions caches
|
2016-05-24 23:57:41 +00:00
|
|
|
[QGVAR(clearConditionCaches), []] call CBA_fnc_localEvent;
|
2015-03-21 23:30:27 +00:00
|
|
|
|
2020-11-08 14:54:14 +00:00
|
|
|
// Use global variable this for action condition and action code
|
|
|
|
private _savedThis = this;
|
|
|
|
this = GVAR(selectedTarget);
|
|
|
|
|
2015-03-21 23:30:27 +00:00
|
|
|
// Check the action conditions
|
2015-11-17 20:06:12 +00:00
|
|
|
private _actionData = GVAR(selectedAction) select 0;
|
2015-03-21 23:30:27 +00:00
|
|
|
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
|
2016-05-24 23:57:41 +00:00
|
|
|
[QGVAR(clearConditionCaches), []] call CBA_fnc_localEvent;
|
2015-03-21 23:30:27 +00:00
|
|
|
};
|
2020-11-08 14:54:14 +00:00
|
|
|
|
|
|
|
// Restore this variable
|
|
|
|
this = _savedThis;
|
2015-03-11 02:45:46 +00:00
|
|
|
};
|
2015-02-19 13:49:36 +00:00
|
|
|
};
|
|
|
|
};
|
2015-10-20 18:26:42 +00:00
|
|
|
END_COUNTER(fnc_renderMenuOpen);
|
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;
|
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-04-26 17:33:08 +00:00
|
|
|
GVAR(ParsedTextCached) set [_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);
|