interact_menu: tab to space

This commit is contained in:
Nicolás Badano 2015-02-19 10:49:36 -03:00
parent 53f632c716
commit d055315661
9 changed files with 172 additions and 173 deletions

View File

@ -77,7 +77,7 @@ _recurseFnc = {
_children,
GVAR(uidCounter)
];
GVAR(uidCounter) = GVAR(uidCounter) + 1;
GVAR(uidCounter) = GVAR(uidCounter) + 1;
_actions pushBack _entry;
};
};
@ -97,6 +97,6 @@ _actions = [[
GVAR(uidCounter)
]
];
GVAR(uidCounter) = GVAR(uidCounter) + 1;
GVAR(uidCounter) = GVAR(uidCounter) + 1;
_object setVariable [QUOTE(GVAR(actionData)), _actions];

View File

@ -2,7 +2,7 @@
#include "script_component.hpp"
if(!GVAR(keyDown)) then {
GVAR(keyDown) = true;
GVAR(keyDownTime) = diag_tickTime;
GVAR(keyDown) = true;
GVAR(keyDownTime) = diag_tickTime;
};
true

View File

@ -2,10 +2,10 @@
#include "script_component.hpp"
if(!GVAR(keyDownSelfAction)) then {
GVAR(keyDownSelfAction) = true;
GVAR(keyDown) = false;
GVAR(keyDownTime) = diag_tickTime;
GVAR(keyDownSelfAction) = true;
GVAR(keyDown) = false;
GVAR(keyDownTime) = diag_tickTime;
GVAR(selfMenuOffset) = [sin getDir ACE_player, cos getDir ACE_player, 0] vectorMultiply 2;
GVAR(selfMenuOffset) = [sin getDir ACE_player, cos getDir ACE_player, 0] vectorMultiply 2;
};
true

View File

@ -3,10 +3,10 @@
GVAR(keyDown) = false;
if(GVAR(actionSelected)) then {
this = GVAR(selectedTarget);
this = GVAR(selectedTarget);
_player = ACE_Player;
_target = GVAR(selectedTarget);
[GVAR(selectedTarget), player] call GVAR(selectedAction);
[GVAR(selectedTarget), player] call GVAR(selectedAction);
};
GVAR(expanded) = false;
GVAR(lastPath) = [];

View File

@ -3,10 +3,10 @@
GVAR(keyDownSelfAction) = false;
if(GVAR(actionSelected)) then {
this = GVAR(selectedTarget);
this = GVAR(selectedTarget);
_player = ACE_Player;
_target = GVAR(selectedTarget);
[GVAR(selectedTarget), player] call GVAR(selectedAction);
[GVAR(selectedTarget), player] call GVAR(selectedAction);
};
GVAR(expanded) = false;
GVAR(lastPath) = [];

View File

@ -9,7 +9,7 @@ if(!GVAR(keyDown)) then {
{
_actionObject = _x;
_actionData = _actionObject getVariable [QUOTE(GVAR(actionData)), []];
if((count _actionData) > 0) then {
_renderData = [];
{

View File

@ -7,107 +7,107 @@ _cursorPos1 = positionCameraToWorld [0, 0, 0];
_cursorPos2 = positionCameraToWorld [0, 0, 2];
GVAR(currentOptions) = [];
if((count GVAR(toRender)) > 0 && (GVAR(keyDown) || GVAR(keyDownSelfAction))) then {
if((count GVAR(vecLineMap)) == 0 || ((count GVAR(menuDepthPath)) > 0 && (getPosASL player) distance GVAR(lastPos) > 0.01)) then {
GVAR(lastPos) = getPosASL player;
_cursorVec = [_cursorPos2, _cursorPos1] call BIS_fnc_vectorFromXtoY;
_p1 = [0,0,0];
_p2 = +_cursorVec;
_p = (_cursorVec call CBA_fnc_vect2polar);
_v = [(_p select 0), (_p select 1), (_p select 2)+90] call CBA_fnc_polar2vect;
_cp = [_cursorVec, _v] call BIS_fnc_crossProduct;
if((count GVAR(vecLineMap)) == 0 || ((count GVAR(menuDepthPath)) > 0 && (getPosASL player) distance GVAR(lastPos) > 0.01)) then {
GVAR(lastPos) = getPosASL player;
_cursorVec = [_cursorPos2, _cursorPos1] call BIS_fnc_vectorFromXtoY;
_p1 = [0,0,0];
_p2 = +_cursorVec;
_p = (_cursorVec call CBA_fnc_vect2polar);
_v = [(_p select 0), (_p select 1), (_p select 2)+90] call CBA_fnc_polar2vect;
_cp = [_cursorVec, _v] call BIS_fnc_crossProduct;
GVAR(vecLineMap) = [_cp, _p1, _p2] call FUNC(rotateVectLineGetMap);
};
if (GVAR(keyDown)) then {
// Render all nearby interaction menus
{
if(!(_forEachIndex in GVAR(filter))) then {
GVAR(renderDepth) = 0;
_renderTargets = _x;
{
[_renderTargets select 0, _x, 0, [270, 360]] call FUNC(renderMenu);
} forEach (_renderTargets select 1);
};
} forEach GVAR(toRender);
} else {
// Render only the self action menu
_actions = (ACE_player getVariable QGVAR(selfActionData)) select 0;
_pos = (ACE_player modelToWorld (ACE_player selectionPosition "spine3")) vectorAdd GVAR(selfMenuOffset) vectorAdd [0,0,0.25];
[ACE_player, _actions, 0, [270, 360], _pos] call FUNC(renderMenu);
};
GVAR(vecLineMap) = [_cp, _p1, _p2] call FUNC(rotateVectLineGetMap);
};
if (GVAR(keyDown)) then {
// Render all nearby interaction menus
{
if(!(_forEachIndex in GVAR(filter))) then {
GVAR(renderDepth) = 0;
_renderTargets = _x;
{
[_renderTargets select 0, _x, 0, [270, 360]] call FUNC(renderMenu);
} forEach (_renderTargets select 1);
};
} forEach GVAR(toRender);
} else {
// Render only the self action menu
_actions = (ACE_player getVariable QGVAR(selfActionData)) select 0;
_pos = (ACE_player modelToWorld (ACE_player selectionPosition "spine3")) vectorAdd GVAR(selfMenuOffset) vectorAdd [0,0,0.25];
[ACE_player, _actions, 0, [270, 360], _pos] call FUNC(renderMenu);
};
// player sideChat format["c: %1", count GVAR(toRender)];
// player sideChat format["c: %1", count GVAR(toRender)];
};
if(GVAR(keyDown) || GVAR(keyDownSelfAction)) then {
_cursorScreenPos = worldToScreen _cursorPos2;
_closestDistance = 1000000;
_closestSelection = -1;
{
_pos = _x select 1;
_sPos = worldToScreen _pos;
if(count _sPos > 0) then {
_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;
};
};
} forEach GVAR(currentOptions);
_cursorScreenPos = worldToScreen _cursorPos2;
_closestDistance = 1000000;
_closestSelection = -1;
{
_pos = _x select 1;
_sPos = worldToScreen _pos;
if(count _sPos > 0) then {
_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;
};
};
} forEach GVAR(currentOptions);
if(_closestSelection != -1) then {
if(_closestSelection != -1) then {
_closest = GVAR(currentOptions) select _closestSelection;
_closest = GVAR(currentOptions) select _closestSelection;
_pos = _closest select 1;
_cTime = diag_tickTime;
_delta = _cTime - GVAR(lastTime);
GVAR(lastTime) = _cTime;
GVAR(rotationAngle) = GVAR(rotationAngle) + (180*_delta);
if(GVAR(rotationAngle) > 360) then {
GVAR(rotationAngle) = GVAR(rotationAngle) - 360;
};
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) select 3;
_misMatch = false;
_hoverPath = (_closest select 2);
if((count GVAR(lastPath)) != (count _hoverPath)) then {
_misMatch = true;
} else {
{
if(_x != (_hoverPath select _forEachIndex)) exitWith {
_misMatch = true;
};
} forEach GVAR(lastPath);
};
_pos = _closest select 1;
_cTime = diag_tickTime;
_delta = _cTime - GVAR(lastTime);
GVAR(lastTime) = _cTime;
GVAR(rotationAngle) = GVAR(rotationAngle) + (180*_delta);
if(GVAR(rotationAngle) > 360) then {
GVAR(rotationAngle) = GVAR(rotationAngle) - 360;
};
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) select 3;
_misMatch = false;
_hoverPath = (_closest select 2);
if((count GVAR(lastPath)) != (count _hoverPath)) then {
_misMatch = true;
} else {
{
if(_x != (_hoverPath select _forEachIndex)) exitWith {
_misMatch = true;
};
} forEach GVAR(lastPath);
};
if(_misMatch) then {
GVAR(lastPath) = _hoverPath;
GVAR(startHoverTime) = diag_tickTime;
GVAR(expanded) = false;
} else {
if(!GVAR(expanded) && diag_tickTime-GVAR(startHoverTime) > 0.25) then {
GVAR(expanded) = true;
GVAR(menuDepthPath) = +GVAR(lastPath);
};
};
};
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selected_ca.paa", [1,0,0,1], _cursorPos2, 1, 1, 0, "", 0.5, 0.025, "TahomaB"];
if(_misMatch) then {
GVAR(lastPath) = _hoverPath;
GVAR(startHoverTime) = diag_tickTime;
GVAR(expanded) = false;
} else {
if(!GVAR(expanded) && diag_tickTime-GVAR(startHoverTime) > 0.25) then {
GVAR(expanded) = true;
GVAR(menuDepthPath) = +GVAR(lastPath);
};
};
};
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\selected_ca.paa", [1,0,0,1], _cursorPos2, 1, 1, 0, "", 0.5, 0.025, "TahomaB"];
};
if(!_foundTarget && GVAR(actionSelected)) then {
GVAR(actionSelected) = false;
GVAR(expanded) = false;
GVAR(lastPath) = [];
if(!GVAR(keyDown)) then {
GVAR(vecLineMap) = [];
};
GVAR(actionSelected) = false;
GVAR(expanded) = false;
GVAR(lastPath) = [];
if(!GVAR(keyDown)) then {
GVAR(vecLineMap) = [];
};
};
for "_i" from GVAR(iconCount) to (count GVAR(iconCtrls))-1 do {
ctrlDelete (GVAR(iconCtrls) select _i);
ctrlDelete (GVAR(iconCtrls) select _i);
};
GVAR(iconCtrls) resize GVAR(iconCount);
GVAR(iconCount) = 0;

View File

@ -9,18 +9,18 @@ _icon = _this select 6;
_sPos = worldToScreen _pos;
// _sPos = _pos;
if(count _sPos > 0) then {
// player sideChat format["render!"];
if(GVAR(iconCount) > (count GVAR(iconCtrls))-1) then {
GVAR(iconCtrls) pushBack ((findDisplay 46) ctrlCreate ["RscStructuredText", 54021+GVAR(iconCount)]);
};
_ctrl = GVAR(iconCtrls) select GVAR(iconCount);
GVAR(iconCount) = GVAR(iconCount) + 1;
// player sideChat format["render!"];
if(GVAR(iconCount) > (count GVAR(iconCtrls))-1) then {
GVAR(iconCtrls) pushBack ((findDisplay 46) ctrlCreate ["RscStructuredText", 54021+GVAR(iconCount)]);
};
_ctrl = GVAR(iconCtrls) select GVAR(iconCount);
GVAR(iconCount) = GVAR(iconCount) + 1;
if(_icon == "") then {
_icon = DEFAULT_ICON;
};
_text = format ["<img image='%1'/><t color ='%2'>%3</t>", _icon, _color, _text];
_ctrl ctrlSetStructuredText (parseText _text);
_ctrl ctrlSetPosition [(_sPos select 0)-(0.011*SafeZoneW), (_sPos select 1)-(0.0095*SafeZoneW), 0.4*SafeZoneW, 0.025*SafeZoneW];
// _ctrl ctrlSetBackgroundColor [1,0,0,1];
_ctrl ctrlCommit 0;
_ctrl ctrlSetStructuredText (parseText _text);
_ctrl ctrlSetPosition [(_sPos select 0)-(0.011*SafeZoneW), (_sPos select 1)-(0.0095*SafeZoneW), 0.4*SafeZoneW, 0.025*SafeZoneW];
// _ctrl ctrlSetBackgroundColor [1,0,0,1];
_ctrl ctrlCommit 0;
};

View File

@ -12,75 +12,74 @@ _distance = _actionData select 5;
EXPLODE_2_PVT(_angles,_centerAngle,_maxAngleSpan);
if((count _this) > 4) then {
_pos = _this select 4;
_pos = _this select 4;
} else {
if(typeName (_actionData select 2) == "ARRAY") then {
_pos = _object modelToWorld (_actionData select 2);
} else {
_pos = _object modelToWorld (_object selectionPosition (_actionData select 2));
};
if(typeName (_actionData select 2) == "ARRAY") then {
_pos = _object modelToWorld (_actionData select 2);
} else {
_pos = _object modelToWorld (_object selectionPosition (_actionData select 2));
};
};
_cursorScreenPos = (positionCameraToWorld [0, 0, 0]);
if(_cursorScreenPos distance _pos <= _distance) then {
_path = [];
if((count _this) > 5) then {
_path = +(_this select 5);
};
_menuDepth = (count GVAR(menuDepthPath));
_path = [];
if((count _this) > 5) then {
_path = +(_this select 5);
};
_menuDepth = (count GVAR(menuDepthPath));
_color = "#FFFFFFFF"; // ARGB Color (First Hex Pair is transparancy)
if(_menuDepth > 0 && _index != (GVAR(menuDepthPath) select (GVAR(renderDepth)))) then {
// ARGB Color (First Hex Pair is transparancy)
_color = "#FFFFFFFF";
if(_menuDepth > 0 && _index != (GVAR(menuDepthPath) select (GVAR(renderDepth)))) then {
_color = format ["#%1FFFFFF", [255 * (((GVAR(renderDepth)/_menuDepth)) max 0.25)] call EFUNC(common,toHex)];
};
_path set[(count _path), _index];
// player sideChat format["r: %1", _actionData select 2];
[_actionData select 0, _color, _pos, 1, 1, 0, _actionData select 1, 0.5, 0.025, "TahomaB"] call FUNC(renderIcon);
GVAR(currentOptions) set[(count GVAR(currentOptions)), [_this, _pos, _path]];
_currentRenderDepth = -1;
_currentRenderDepth = GVAR(renderDepth);
GVAR(renderDepth) = GVAR(renderDepth) + 1;
if(_index == (GVAR(menuDepthPath) select (GVAR(renderDepth)-1))) then {
// Count how many actions are active
private "_numActions";
_numActions = 0;
{
this = _object;
_target = _object;
_player = ACE_player;
_active = [_object, ACE_player] call (_x select 4);
if(_active) then {
_numActions = _numActions + 1;
};
} forEach (_actionData select 6);
systemChat format ["_numActions: %1", _numActions];
};
_path set[(count _path), _index];
// player sideChat format["r: %1", _actionData select 2];
[_actionData select 0, _color, _pos, 1, 1, 0, _actionData select 1, 0.5, 0.025, "TahomaB"] call FUNC(renderIcon);
GVAR(currentOptions) set[(count GVAR(currentOptions)), [_this, _pos, _path]];
_currentRenderDepth = -1;
_currentRenderDepth = GVAR(renderDepth);
GVAR(renderDepth) = GVAR(renderDepth) + 1;
if(_index == (GVAR(menuDepthPath) select (GVAR(renderDepth)-1))) then {
// Count how many actions are active
private "_numActions";
_numActions = 0;
{
this = _object;
_target = _object;
_player = ACE_player;
_active = [_object, ACE_player] call (_x select 4);
if(_active) then {
_numActions = _numActions + 1;
};
} forEach (_actionData select 6);
systemChat format ["_numActions: %1", _numActions];
private "_angleSpan";
_angleSpan = _maxAngleSpan min (35 * (_numActions - 1));
private "_angleSpan";
_angleSpan = _maxAngleSpan min (35 * (_numActions - 1));
private "_angle";
_angle = _centerAngle - _angleSpan / 2;
{
// if(_index != (GVAR(menuDepthPath) select (GVAR(renderDepth)))) then {
this = _object;
_target = _object;
_player = ACE_player;
_active = [_object, ACE_player] call (_x select 4);
// diag_log text format["_active: %1: %2", (_x select 0), _active];
if(_active) then {
systemChat format ["_angle: %1", _angle];
_offset = [GVAR(vecLineMap), _angle] call FUNC(rotateVectLine);
_mod = 0.4 max (0.15 * (_cursorScreenPos distance _pos)); //0.5;//0.1*_distance;
_newPos = [
(_pos select 0) + ((_offset select 0)*_mod),
(_pos select 1) + ((_offset select 1)*_mod),
(_pos select 2) + ((_offset select 2)*_mod)
];
// drawLine3D [_pos, _newPos, [1,0,0,1]];
[_object, _x, _forEachIndex, [_angle, 180], _newPos, _path] call FUNC(renderMenu);
_angle = _angle + _angleSpan / (_numActions);
};
// };
} forEach (_actionData select 6);
};
GVAR(renderDepth) = GVAR(renderDepth) - 1;
private "_angle";
_angle = _centerAngle - _angleSpan / 2;
{
this = _object;
_target = _object;
_player = ACE_player;
_active = [_object, ACE_player] call (_x select 4);
// diag_log text format["_active: %1: %2", (_x select 0), _active];
if(_active) then {
systemChat format ["_angle: %1", _angle];
_offset = [GVAR(vecLineMap), _angle] call FUNC(rotateVectLine);
_mod = 0.4 max (0.15 * (_cursorScreenPos distance _pos)); //0.5;//0.1*_distance;
_newPos = [
(_pos select 0) + ((_offset select 0)*_mod),
(_pos select 1) + ((_offset select 1)*_mod),
(_pos select 2) + ((_offset select 2)*_mod)
];
// drawLine3D [_pos, _newPos, [1,0,0,1]];
[_object, _x, _forEachIndex, [_angle, 180], _newPos, _path] call FUNC(renderMenu);
_angle = _angle + _angleSpan / (_numActions);
};
} forEach (_actionData select 6);
};
GVAR(renderDepth) = GVAR(renderDepth) - 1;
};