Refactor the interact_menu so options for multiple objects can coexist inside a single action point

This commit is contained in:
Nicolás Badano 2015-03-17 00:37:28 -03:00
parent eb4ccd9505
commit 3030b78ea2
4 changed files with 14 additions and 13 deletions

View File

@ -69,4 +69,4 @@ if ((count _activeChildren) == 0 && ((_origActionData select 3) isEqualTo {})) e
[]
};
[_origActionData, _activeChildren]
[_origActionData, _activeChildren, _object]

View File

@ -142,8 +142,8 @@ if(GVAR(keyDown) || GVAR(keyDownSelfAction)) then {
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selectover_ca.paa", [1,0,0,.75], _pos, 0.6*SafeZoneW, 0.6*SafeZoneW, GVAR(rotationAngle), "", 0.5, 0.025, "TahomaB"];
_foundTarget = true;
GVAR(actionSelected) = true;
GVAR(selectedTarget) = (_closest select 0) select 0;
GVAR(selectedAction) = (_closest select 0) select 1;
GVAR(selectedTarget) = (GVAR(selectedAction)) select 2;
GVAR(selectedStatement) = ((GVAR(selectedAction)) select 0) select 3;
_misMatch = false;
@ -153,7 +153,7 @@ if(GVAR(keyDown) || GVAR(keyDownSelfAction)) then {
_misMatch = true;
} else {
{
if(_x != (_hoverPath select _forEachIndex)) exitWith {
if !(_x isEqualTo (_hoverPath select _forEachIndex)) exitWith {
_misMatch = true;
};
} forEach GVAR(lastPath);

View File

@ -66,12 +66,11 @@ _activeActionTree = [
_object, _uid, 0.2
] call EFUNC(common,cachedCall);
// Check if there's something left for rendering
if (count _activeActionTree == 0) exitWith {false};
//EXPLODE_2_PVT(_activeActionTree,_actionData,_actionChildren);
[_object, _activeActionTree, _pos, [180,360]] call FUNC(renderMenu);
[[], _activeActionTree, _pos, [180,360]] call FUNC(renderMenu);
true

View File

@ -3,7 +3,7 @@
* Render an interaction menu and it's children recursively
*
* Argument:
* 0: Object <OBJECT>
* 0: Parent path <ARRAY>
* 1: Action data <ARRAY>
* 2: 3D position <ARRAY>
* 3: Angle range available for rendering <ARRAY>
@ -15,16 +15,18 @@
*/
#include "script_component.hpp"
private ["_menuInSelectedPath", "_path", "_menuDepth", "_currentRenderDepth", "_x", "_offset", "_newPos", "_forEachIndex"];
private ["_menuInSelectedPath", "_localPath", "_path", "_menuDepth", "_currentRenderDepth", "_x", "_offset", "_newPos", "_forEachIndex"];
EXPLODE_4_PVT(_this,_object,_action,_pos,_angles);
EXPLODE_2_PVT(_action,_actionData,_activeChildren);
EXPLODE_4_PVT(_this,_parentPath,_action,_pos,_angles);
EXPLODE_3_PVT(_action,_actionData,_activeChildren,_actionObject);
EXPLODE_2_PVT(_angles,_centerAngle,_maxAngleSpan);
_menuDepth = (count GVAR(menuDepthPath)) - 1;
// Store path to action
_path = [_object] + (_actionData select 7);
_localPath = _actionData select 7;
_path = +_parentPath;
_path pushBack [_localPath select ((count _localPath) - 1), _actionObject];
// Check if the menu is on the selected path
_menuInSelectedPath = true;
@ -32,7 +34,7 @@ _menuInSelectedPath = true;
if (_forEachIndex >= (count GVAR(menuDepthPath))) exitWith {
_menuInSelectedPath = false;
};
if (_x != (GVAR(menuDepthPath) select _forEachIndex)) exitWith {
if !(_x isEqualTo (GVAR(menuDepthPath) select _forEachIndex)) exitWith {
_menuInSelectedPath = false;
};
} forEach _path;
@ -63,7 +65,7 @@ if (_angleSpan >= 305) then {
_angle = _centerAngle - _angleSpan / 2;
{
_target = _object;
_target = _actionObject;
_player = ACE_player;
_mod = (0.15 max (0.15 * ((positionCameraToWorld [0, 0, 0]) distance _pos))) / GVAR(selfMenuScale);
@ -74,7 +76,7 @@ _angle = _centerAngle - _angleSpan / 2;
//drawLine3D [_pos, _newPos, [1,0,0,0.5]];
[_object, _x, _newPos, [_angle, 140]] call FUNC(renderMenu);
[_path, _x, _newPos, [_angle, 140]] call FUNC(renderMenu);
if (_angleSpan == 360) then {
_angle = _angle + _angleSpan / (count _activeChildren);