diff --git a/addons/interact_menu/XEH_preInit.sqf b/addons/interact_menu/XEH_preInit.sqf index 4ede3196fe..c2ae253fc0 100644 --- a/addons/interact_menu/XEH_preInit.sqf +++ b/addons/interact_menu/XEH_preInit.sqf @@ -20,6 +20,7 @@ PREP(render); PREP(renderBaseMenu); PREP(renderIcon); PREP(renderMenu); +PREP(renderSelector); PREP(splitPath); GVAR(keyDown) = false; diff --git a/addons/interact_menu/functions/fnc_render.sqf b/addons/interact_menu/functions/fnc_render.sqf index 523520ee91..9dabd6a974 100644 --- a/addons/interact_menu/functions/fnc_render.sqf +++ b/addons/interact_menu/functions/fnc_render.sqf @@ -12,6 +12,8 @@ */ #include "script_component.hpp" +BEGIN_COUNTER(fnc_render); + 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]; @@ -97,7 +99,11 @@ if (GVAR(keyDown)) then { { _action = _x; - _pos = (((positionCameraToWorld [0, 0, 0]) call EFUNC(common,positionToASL)) vectorAdd GVAR(selfMenuOffset)) call EFUNC(common,ASLToPosition); + _pos = if !(visibleMap) then { + (((positionCameraToWorld [0, 0, 0]) call EFUNC(common,positionToASL)) vectorAdd GVAR(selfMenuOffset)) call EFUNC(common,ASLToPosition) + } else { + [0.5, 0.5] + }; [_target, _action, _pos] call FUNC(renderBaseMenu); } forEach _classActions; }; @@ -115,14 +121,11 @@ if(GVAR(keyDown) || GVAR(keyDownSelfAction)) then { _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; - }; + _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; }; } forEach GVAR(currentOptions); @@ -131,15 +134,14 @@ if(GVAR(keyDown) || GVAR(keyDownSelfAction)) then { _closest = GVAR(currentOptions) select _closestSelection; - _pos = _closest select 1; + _sPos = _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"]; + + GVAR(rotationAngle) = (GVAR(rotationAngle) + (270*_delta)) mod 360; + [_sPos] call FUNC(renderSelector); + _foundTarget = true; GVAR(actionSelected) = true; GVAR(selectedAction) = (_closest select 0) select 1; @@ -207,3 +209,5 @@ for "_i" from GVAR(iconCount) to (count GVAR(iconCtrls))-1 do { }; GVAR(iconCtrls) resize GVAR(iconCount); GVAR(iconCount) = 0; + +END_COUNTER(fnc_render); diff --git a/addons/interact_menu/functions/fnc_renderBaseMenu.sqf b/addons/interact_menu/functions/fnc_renderBaseMenu.sqf index 5c744b4721..7fd95b5972 100644 --- a/addons/interact_menu/functions/fnc_renderBaseMenu.sqf +++ b/addons/interact_menu/functions/fnc_renderBaseMenu.sqf @@ -5,7 +5,7 @@ * Argument: * 0: Object * 1: Action node - * 2: 3D position (Optional) + * 2: 3D position or 2D position (Optional) * * Return value: * Was the menu rendered @@ -14,6 +14,8 @@ */ #include "script_component.hpp" +BEGIN_COUNTER(fnc_renderBaseMenu) + private ["_distance","_pos","_weaponDir","_ref","_cameraPos","_sPos","_activeActionTree"]; EXPLODE_2_PVT(_this,_object,_baseActionNode); @@ -41,16 +43,16 @@ if((count _this) > 2) then { _pos = _pos vectorAdd ((visiblePositionASL _object) vectorDiff (getPosASL _object)); }; -_cameraToActionVec = (_pos call EFUNC(common,positionToASL)) vectorDiff ((positionCameraToWorld [0,0,0]) call EFUNC(common,positionToASL)); -GVAR(refSystem) = _cameraToActionVec call EFUNC(common,createOrthonormalReference); -GVAR(menuScale) = (0.15 max (0.15 * ((positionCameraToWorld [0, 0, 0]) distance _pos))) / GVAR(selfMenuScale); - // For non-self actions, exit if the action is too far away if (GVAR(keyDown) && {(ACE_player modelToWorld (ACE_player selectionPosition "pilot")) distance _pos >= _distance}) exitWith {false}; // Exit if the action is behind you -_sPos = worldToScreen _pos; +_sPos = if (count _pos != 2) then { + worldToScreen _pos +} else { + pos +}; if(count _sPos == 0) exitWith {false}; // Exit if the action is off screen @@ -58,6 +60,8 @@ if ((_sPos select 0) < safeZoneXAbs || (_sPos select 0) > safeZoneXAbs + safeZon if ((_sPos select 1) < safeZoneY || (_sPos select 1) > safeZoneY + safeZoneH) exitWith {false}; +BEGIN_COUNTER(fnc_collectActiveActionTree) + // Collect active tree private "_uid"; _uid = format [QGVAR(ATCache_%1), _actionData select 0]; @@ -67,6 +71,8 @@ _activeActionTree = [ _object, _uid, 1.0, "interactMenuClosed" ] call EFUNC(common,cachedCall); +END_COUNTER(fnc_collectActiveActionTree) + /* diag_log "Printing: _activeActionTree"; _fnc_print = { @@ -84,6 +90,12 @@ if (count _activeActionTree == 0) exitWith {false}; //EXPLODE_2_PVT(_activeActionTree,_actionData,_actionChildren); -[[], _activeActionTree, _pos, [180,360]] call FUNC(renderMenu); +BEGIN_COUNTER(fnc_renderMenus); + +[[], _activeActionTree, _sPos, [180,360]] call FUNC(renderMenu); + +END_COUNTER(fnc_renderMenus); + +END_COUNTER(fnc_renderBaseMenu) true diff --git a/addons/interact_menu/functions/fnc_renderIcon.sqf b/addons/interact_menu/functions/fnc_renderIcon.sqf index 348070bc97..36c0b7ab19 100644 --- a/addons/interact_menu/functions/fnc_renderIcon.sqf +++ b/addons/interact_menu/functions/fnc_renderIcon.sqf @@ -5,7 +5,7 @@ * Argument: * 0: Text * 1: Color - * 2: 3d position ASL + * 2: 2d position * 3: ? * 4: ? * 5: ? @@ -18,30 +18,25 @@ */ #include "script_component.hpp" #define DEFAULT_ICON QUOTE(\z\ace\addons\interaction\ui\dot_ca.paa) -private ["_color", "_pos", "_sPos", "_ctrl", "_icon"]; +private ["_color", "_sPos", "_ctrl", "_icon"]; _text = _this select 0; _color = _this select 1; -_pos = _this select 2; +_sPos = _this select 2; _icon = _this select 6; //systemChat format ["Icon %1 - %2,%3,%4", _text, _pos select 0, _pos select 1, _pos select 2]; -_sPos = worldToScreen _pos; -if(count _sPos > 0) then { - - if(GVAR(iconCount) > (count GVAR(iconCtrls))-1) then { - _displayNum = [46,91919] select (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]); - //systemChat format ["Displaynum: %1", _displayNum]; - GVAR(iconCtrls) pushBack ((findDisplay _displayNum) ctrlCreate ["RscStructuredText", 54021+GVAR(iconCount)]); - }; - _ctrl = GVAR(iconCtrls) select GVAR(iconCount); - GVAR(iconCount) = GVAR(iconCount) + 1; - if(_icon == "") then { - _icon = DEFAULT_ICON; - }; - _text = format ["
%4", _icon, _color, _color, _text]; - _ctrl ctrlSetStructuredText (parseText _text); - _ctrl ctrlSetPosition [(_sPos select 0)-(0.2*SafeZoneW), (_sPos select 1)-(0.0095*SafeZoneW), 0.4*SafeZoneW, 0.035*SafeZoneW]; - //_ctrl ctrlSetBackgroundColor [1, 0, 0, 0.1]; - _ctrl ctrlCommit 0; +if(GVAR(iconCount) > (count GVAR(iconCtrls))-1) then { + _displayNum = [46,91919] select (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]); + GVAR(iconCtrls) pushBack ((findDisplay _displayNum) ctrlCreate ["RscStructuredText", 54021+GVAR(iconCount)]); }; +_ctrl = GVAR(iconCtrls) select GVAR(iconCount); +GVAR(iconCount) = GVAR(iconCount) + 1; +if(_icon == "") then { + _icon = DEFAULT_ICON; +}; +_text = format ["
%4", _icon, _color, _color, _text]; +_ctrl ctrlSetStructuredText (parseText _text); +_ctrl ctrlSetPosition [(_sPos select 0)-(0.2*SafeZoneW), (_sPos select 1)-(0.0095*SafeZoneW), 0.4*SafeZoneW, 0.035*SafeZoneW]; +//_ctrl ctrlSetBackgroundColor [1, 0, 0, 0.1]; +_ctrl ctrlCommit 0; diff --git a/addons/interact_menu/functions/fnc_renderMenu.sqf b/addons/interact_menu/functions/fnc_renderMenu.sqf index 0206e93952..16fadd4eda 100644 --- a/addons/interact_menu/functions/fnc_renderMenu.sqf +++ b/addons/interact_menu/functions/fnc_renderMenu.sqf @@ -5,7 +5,7 @@ * Argument: * 0: Parent path * 1: Action data - * 2: 3D position + * 2: 2D position * 3: Angle range available for rendering * * Return value: @@ -17,12 +17,14 @@ private ["_menuInSelectedPath", "_path", "_menuDepth", "_currentRenderDepth", "_x", "_offset", "_newPos", "_forEachIndex"]; -EXPLODE_4_PVT(_this,_parentPath,_action,_pos,_angles); +EXPLODE_4_PVT(_this,_parentPath,_action,_sPos,_angles); EXPLODE_3_PVT(_action,_actionData,_activeChildren,_actionObject); EXPLODE_2_PVT(_angles,_centerAngle,_maxAngleSpan); _menuDepth = (count GVAR(menuDepthPath)); +//BEGIN_COUNTER(constructing_paths); + // Store path to action _path = +_parentPath; _path pushBack [_actionData select 0,_actionObject]; @@ -38,24 +40,39 @@ _menuInSelectedPath = true; }; } forEach _path; +//END_COUNTER(constructing_paths); +//BEGIN_COUNTER(constructing_colors); + // Render icon // ARGB Color (First Hex Pair is transparancy) _color = "#FFFFFFFF"; -if(!_menuInSelectedPath) then { //_menuDepth > 0 && +if(!_menuInSelectedPath) then { if (_menuDepth > 0) then { _color = format ["#%1FFFFFF", [255 * ((((count _path) - 1)/_menuDepth) max 0.25)] call EFUNC(common,toHex)]; } else { _color = format ["#%1FFFFFF", [255 * 0.75] call EFUNC(common,toHex)]; }; }; -[_actionData select 1, _color, _pos, 1, 1, 0, _actionData select 2, 0.5, 0.025, "TahomaB"] call FUNC(renderIcon); + +//END_COUNTER(constructing_colors); +//BEGIN_COUNTER(fnc_renderIcons); + +[_actionData select 1, _color, _sPos, 1, 1, 0, _actionData select 2, 0.5, 0.025, "TahomaB"] call FUNC(renderIcon); + +//END_COUNTER(fnc_renderIcons); + +//BEGIN_COUNTER(currentOptions); // Add the action to current options -GVAR(currentOptions) pushBack [_this, _pos, _path]; +GVAR(currentOptions) pushBack [_this, _sPos, _path]; + +//END_COUNTER(currentOptions); // Exit without rendering children if it isn't if !(_menuInSelectedPath) exitWith {true}; +//BEGIN_COUNTER(children); + private ["_numChildren","_angleSpan","_angle","_angleInterval","_scale","_offset"]; _numChildren = count _activeChildren; _angleSpan = _maxAngleSpan min (55 * ((_numChildren) - 1)); @@ -75,6 +92,7 @@ if (_numChildren == 1) then { }; // Scale menu based on the amount of children +GVAR(menuScale) = 0.15; _scale = GVAR(menuScale) * (((0.8 * (0.46 / sin (0.5 * _angleInterval))) min 1.4) max 0.5); // Animate menu scale if (_menuInSelectedPath && (_menuDepth == count _path)) then { @@ -83,16 +101,17 @@ if (_menuInSelectedPath && (_menuDepth == count _path)) then { _target = _actionObject; _player = ACE_player; + +//END_COUNTER(children); _angle = _centerAngle - _angleSpan / 2; { - + //BEGIN_COUNTER(children); private ["_offset","_newPos"]; - _offset = ((GVAR(refSystem) select 1) vectorMultiply (-_scale * cos _angle)) vectorAdd - ((GVAR(refSystem) select 2) vectorMultiply (-_scale * sin _angle)); - _newPos = ((_pos call EFUNC(common,positionToASL)) vectorAdd _offset) call EFUNC(common,ASLToPosition); + _newPos = [(_sPos select 0) -_scale * cos _angle, + (_sPos select 1) +_scale * (sin _angle) * 4/3]; //drawLine3D [_pos, _newPos, [1,0,0,0.8]]; - + //END_COUNTER(children); [_path, _x, _newPos, [_angle, 140]] call FUNC(renderMenu); _angle = _angle + _angleInterval; diff --git a/addons/interact_menu/functions/fnc_renderSelector.sqf b/addons/interact_menu/functions/fnc_renderSelector.sqf new file mode 100644 index 0000000000..8600671b24 --- /dev/null +++ b/addons/interact_menu/functions/fnc_renderSelector.sqf @@ -0,0 +1,29 @@ +/* + * Author: CAA-Picard + * Render a single interaction icon + * + * Argument: + * 0: 2d position + * + * Return value: + * None + * + * Public: No + */ +#include "script_component.hpp" +#define DEFAULT_ICON QUOTE(\z\ace\addons\interaction\ui\dot_ca.paa) +private ["_color", "_sPos", "_ctrl", "_icon"]; +_sPos = _this select 0; + +if(GVAR(iconCount) > (count GVAR(iconCtrls))-1) then { + _displayNum = [46,91919] select (uiNamespace getVariable [QGVAR(cursorMenuOpened),false]); + GVAR(iconCtrls) pushBack ((findDisplay _displayNum) ctrlCreate ["RscStructuredText", 54021+GVAR(iconCount)]); +}; +_ctrl = GVAR(iconCtrls) select GVAR(iconCount); +GVAR(iconCount) = GVAR(iconCount) + 1; + +_text = format ["", format [QUOTE(PATHTOF(ui\selector%1.paa)), floor (((abs GVAR(rotationAngle)) mod 90) / 6)]]; +_ctrl ctrlSetStructuredText (parseText _text); +_ctrl ctrlSetPosition [(_sPos select 0)-(0.2*SafeZoneW), (_sPos select 1)-(0.012*SafeZoneW), 0.4*SafeZoneW, 0.035*SafeZoneW]; +//_ctrl ctrlSetBackgroundColor [1, 0, 0, 0.1]; +_ctrl ctrlCommit 0; diff --git a/addons/interact_menu/ui/selector0.paa b/addons/interact_menu/ui/selector0.paa new file mode 100644 index 0000000000..107c0df8ba Binary files /dev/null and b/addons/interact_menu/ui/selector0.paa differ diff --git a/addons/interact_menu/ui/selector1.paa b/addons/interact_menu/ui/selector1.paa new file mode 100644 index 0000000000..17f95562ee Binary files /dev/null and b/addons/interact_menu/ui/selector1.paa differ diff --git a/addons/interact_menu/ui/selector10.paa b/addons/interact_menu/ui/selector10.paa new file mode 100644 index 0000000000..ed783b45ec Binary files /dev/null and b/addons/interact_menu/ui/selector10.paa differ diff --git a/addons/interact_menu/ui/selector11.paa b/addons/interact_menu/ui/selector11.paa new file mode 100644 index 0000000000..cc70b12ef3 Binary files /dev/null and b/addons/interact_menu/ui/selector11.paa differ diff --git a/addons/interact_menu/ui/selector12.paa b/addons/interact_menu/ui/selector12.paa new file mode 100644 index 0000000000..b7aac55c75 Binary files /dev/null and b/addons/interact_menu/ui/selector12.paa differ diff --git a/addons/interact_menu/ui/selector13.paa b/addons/interact_menu/ui/selector13.paa new file mode 100644 index 0000000000..1adcca3c8e Binary files /dev/null and b/addons/interact_menu/ui/selector13.paa differ diff --git a/addons/interact_menu/ui/selector14.paa b/addons/interact_menu/ui/selector14.paa new file mode 100644 index 0000000000..f46fde1063 Binary files /dev/null and b/addons/interact_menu/ui/selector14.paa differ diff --git a/addons/interact_menu/ui/selector2.paa b/addons/interact_menu/ui/selector2.paa new file mode 100644 index 0000000000..7da669f90b Binary files /dev/null and b/addons/interact_menu/ui/selector2.paa differ diff --git a/addons/interact_menu/ui/selector3.paa b/addons/interact_menu/ui/selector3.paa new file mode 100644 index 0000000000..c9becb268a Binary files /dev/null and b/addons/interact_menu/ui/selector3.paa differ diff --git a/addons/interact_menu/ui/selector4.paa b/addons/interact_menu/ui/selector4.paa new file mode 100644 index 0000000000..eccec64c3a Binary files /dev/null and b/addons/interact_menu/ui/selector4.paa differ diff --git a/addons/interact_menu/ui/selector5.paa b/addons/interact_menu/ui/selector5.paa new file mode 100644 index 0000000000..0647f14c2e Binary files /dev/null and b/addons/interact_menu/ui/selector5.paa differ diff --git a/addons/interact_menu/ui/selector6.paa b/addons/interact_menu/ui/selector6.paa new file mode 100644 index 0000000000..a9555c2497 Binary files /dev/null and b/addons/interact_menu/ui/selector6.paa differ diff --git a/addons/interact_menu/ui/selector7.paa b/addons/interact_menu/ui/selector7.paa new file mode 100644 index 0000000000..b64f36af46 Binary files /dev/null and b/addons/interact_menu/ui/selector7.paa differ diff --git a/addons/interact_menu/ui/selector8.paa b/addons/interact_menu/ui/selector8.paa new file mode 100644 index 0000000000..4c3a422258 Binary files /dev/null and b/addons/interact_menu/ui/selector8.paa differ diff --git a/addons/interact_menu/ui/selector9.paa b/addons/interact_menu/ui/selector9.paa new file mode 100644 index 0000000000..c39a780c4f Binary files /dev/null and b/addons/interact_menu/ui/selector9.paa differ diff --git a/extras/assets/selector/selector0.png b/extras/assets/selector/selector0.png new file mode 100644 index 0000000000..f744338e2a Binary files /dev/null and b/extras/assets/selector/selector0.png differ diff --git a/extras/assets/selector/selector1.png b/extras/assets/selector/selector1.png new file mode 100644 index 0000000000..f9b6dd1938 Binary files /dev/null and b/extras/assets/selector/selector1.png differ diff --git a/extras/assets/selector/selector10.png b/extras/assets/selector/selector10.png new file mode 100644 index 0000000000..5cc738dc4a Binary files /dev/null and b/extras/assets/selector/selector10.png differ diff --git a/extras/assets/selector/selector11.png b/extras/assets/selector/selector11.png new file mode 100644 index 0000000000..8fadc4ccee Binary files /dev/null and b/extras/assets/selector/selector11.png differ diff --git a/extras/assets/selector/selector12.png b/extras/assets/selector/selector12.png new file mode 100644 index 0000000000..3267afcd53 Binary files /dev/null and b/extras/assets/selector/selector12.png differ diff --git a/extras/assets/selector/selector13.png b/extras/assets/selector/selector13.png new file mode 100644 index 0000000000..37db70e41a Binary files /dev/null and b/extras/assets/selector/selector13.png differ diff --git a/extras/assets/selector/selector14.png b/extras/assets/selector/selector14.png new file mode 100644 index 0000000000..9521b05c4c Binary files /dev/null and b/extras/assets/selector/selector14.png differ diff --git a/extras/assets/selector/selector2.png b/extras/assets/selector/selector2.png new file mode 100644 index 0000000000..313c788f03 Binary files /dev/null and b/extras/assets/selector/selector2.png differ diff --git a/extras/assets/selector/selector3.png b/extras/assets/selector/selector3.png new file mode 100644 index 0000000000..8268eca772 Binary files /dev/null and b/extras/assets/selector/selector3.png differ diff --git a/extras/assets/selector/selector4.png b/extras/assets/selector/selector4.png new file mode 100644 index 0000000000..5aadafc90e Binary files /dev/null and b/extras/assets/selector/selector4.png differ diff --git a/extras/assets/selector/selector5.png b/extras/assets/selector/selector5.png new file mode 100644 index 0000000000..a1e98e9489 Binary files /dev/null and b/extras/assets/selector/selector5.png differ diff --git a/extras/assets/selector/selector6.png b/extras/assets/selector/selector6.png new file mode 100644 index 0000000000..a1a8e6abcf Binary files /dev/null and b/extras/assets/selector/selector6.png differ diff --git a/extras/assets/selector/selector7.png b/extras/assets/selector/selector7.png new file mode 100644 index 0000000000..2735c5b95a Binary files /dev/null and b/extras/assets/selector/selector7.png differ diff --git a/extras/assets/selector/selector8.png b/extras/assets/selector/selector8.png new file mode 100644 index 0000000000..1ac4b51426 Binary files /dev/null and b/extras/assets/selector/selector8.png differ diff --git a/extras/assets/selector/selector9.png b/extras/assets/selector/selector9.png new file mode 100644 index 0000000000..1d7ed98ce7 Binary files /dev/null and b/extras/assets/selector/selector9.png differ