From 6a04408a74d4617e76981276692063c57853cf3a Mon Sep 17 00:00:00 2001 From: Nou Date: Sun, 18 Jan 2015 10:38:27 -0800 Subject: [PATCH] Initial nou menu commit. --- addons/interact_menu/$PBOPREFIX$ | 1 + addons/interact_menu/CfgEventHandlers.hpp | 19 ++++ addons/interact_menu/XEH_clientInit.sqf | 26 +++++ addons/interact_menu/XEH_preInit.sqf | 49 +++++++++ addons/interact_menu/config.cpp | 15 +++ .../functions/fnc_compileMenu.sqf | 95 ++++++++++++++++ .../interact_menu/functions/fnc_keyDown.sqf | 8 ++ addons/interact_menu/functions/fnc_keyUp.sqf | 15 +++ addons/interact_menu/functions/fnc_probe.sqf | 42 +++++++ addons/interact_menu/functions/fnc_render.sqf | 104 ++++++++++++++++++ .../functions/fnc_renderIcon.sqf | 28 +++++ .../functions/fnc_renderMenu.sqf | 63 +++++++++++ .../functions/fnc_rotateVectLine.sqf | 40 +++++++ .../functions/fnc_rotateVectLineGetMap.sqf | 39 +++++++ .../functions/fnc_setToRender.sqf | 6 + .../functions/script_component.hpp | 1 + addons/interact_menu/script_component.hpp | 12 ++ addons/interaction/XEH_preInit.sqf | 4 + 18 files changed, 567 insertions(+) create mode 100644 addons/interact_menu/$PBOPREFIX$ create mode 100644 addons/interact_menu/CfgEventHandlers.hpp create mode 100644 addons/interact_menu/XEH_clientInit.sqf create mode 100644 addons/interact_menu/XEH_preInit.sqf create mode 100644 addons/interact_menu/config.cpp create mode 100644 addons/interact_menu/functions/fnc_compileMenu.sqf create mode 100644 addons/interact_menu/functions/fnc_keyDown.sqf create mode 100644 addons/interact_menu/functions/fnc_keyUp.sqf create mode 100644 addons/interact_menu/functions/fnc_probe.sqf create mode 100644 addons/interact_menu/functions/fnc_render.sqf create mode 100644 addons/interact_menu/functions/fnc_renderIcon.sqf create mode 100644 addons/interact_menu/functions/fnc_renderMenu.sqf create mode 100644 addons/interact_menu/functions/fnc_rotateVectLine.sqf create mode 100644 addons/interact_menu/functions/fnc_rotateVectLineGetMap.sqf create mode 100644 addons/interact_menu/functions/fnc_setToRender.sqf create mode 100644 addons/interact_menu/functions/script_component.hpp create mode 100644 addons/interact_menu/script_component.hpp diff --git a/addons/interact_menu/$PBOPREFIX$ b/addons/interact_menu/$PBOPREFIX$ new file mode 100644 index 0000000000..482dc4fa24 --- /dev/null +++ b/addons/interact_menu/$PBOPREFIX$ @@ -0,0 +1 @@ +z\ace\addons\interact_menu \ No newline at end of file diff --git a/addons/interact_menu/CfgEventHandlers.hpp b/addons/interact_menu/CfgEventHandlers.hpp new file mode 100644 index 0000000000..ae9c93b32e --- /dev/null +++ b/addons/interact_menu/CfgEventHandlers.hpp @@ -0,0 +1,19 @@ +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; + +class Extended_PostInit_EventHandlers { + class ADDON { + clientInit = QUOTE( call COMPILE_FILE(XEH_clientInit) ); + }; +}; + +class Extended_InitPost_EventHandlers { + class All { + class GVAR(compileMenu) { + init = QUOTE(_this call FUNC(compileMenu)); + }; + }; +}; \ No newline at end of file diff --git a/addons/interact_menu/XEH_clientInit.sqf b/addons/interact_menu/XEH_clientInit.sqf new file mode 100644 index 0000000000..16f557182d --- /dev/null +++ b/addons/interact_menu/XEH_clientInit.sqf @@ -0,0 +1,26 @@ +//XEH_clientInit.sqf +#include "script_component.hpp" + +_fnc = { + _this call FUNC(render); +}; +[_fnc, 0, []] call cba_fnc_addPerFrameHandler; + +_fnc = { + _this call FUNC(probe); +}; +[_fnc, 0.5, []] call cba_fnc_addPerFrameHandler; + +["ACE3", +"Interact Key", +{_this call FUNC(keyDown)}, +[15, [false, false, false]], +false, +"keydown"] call cba_fnc_registerKeybind; + +["ACE3", +"Interact Key", +{_this call FUNC(keyUp)}, +[15, [false, false, false]], +false, +"keyUp"] call cba_fnc_registerKeybind; \ No newline at end of file diff --git a/addons/interact_menu/XEH_preInit.sqf b/addons/interact_menu/XEH_preInit.sqf new file mode 100644 index 0000000000..0f86582531 --- /dev/null +++ b/addons/interact_menu/XEH_preInit.sqf @@ -0,0 +1,49 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP(setToRender); +PREP(render); +PREP(renderIcon); +PREP(renderMenu); +PREP(probe); +PREP(rotateVectLineGetMap); +PREP(rotateVectLine); +PREP(keyDown); +PREP(keyUp); +PREP(compileMenu); + +GVAR(toRender) = []; + +GVAR(keyDown) = false; +GVAR(keyDownTime) = 0; + +GVAR(lastTime) = diag_tickTime; +GVAR(rotationAngle) = 0; + +GVAR(selectedAction) = {}; +GVAR(actionSelected) = false; +GVAR(selectedTarget) = objNull; + +GVAR(filter) = []; + +GVAR(menuDepthPath) = []; +GVAR(renderDepth) = 0; +GVAR(lastRenderDepth) = 0; +GVAR(vecLineMap) = []; +GVAR(lastPos) = [0,0,0]; + +GVAR(currentOptions) = []; + +GVAR(lastPath) = []; + +GVAR(expanded) = false; + +GVAR(maxRenderDepth) = 0; +GVAR(startHoverTime) = diag_tickTime; +GVAR(iconCtrls) = []; +GVAR(iconCount) = 0; + +GVAR(objectActionsHash) = HASH_CREATE; + +ADDON = true; \ No newline at end of file diff --git a/addons/interact_menu/config.cpp b/addons/interact_menu/config.cpp new file mode 100644 index 0000000000..a7b7bae6df --- /dev/null +++ b/addons/interact_menu/config.cpp @@ -0,0 +1,15 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_common"}; + author[] = {""}; + authorUrl = ""; + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" diff --git a/addons/interact_menu/functions/fnc_compileMenu.sqf b/addons/interact_menu/functions/fnc_compileMenu.sqf new file mode 100644 index 0000000000..36845eb9ee --- /dev/null +++ b/addons/interact_menu/functions/fnc_compileMenu.sqf @@ -0,0 +1,95 @@ +//fnc_compileMenu.sqf +#include "script_component.hpp"; +diag_log text format["COMPILE ACTIONS: %1", _this]; + +_object = _this select 0; +_objectType = typeOf _object; + + +/* +displayName = "$STR_ACE_Interaction_TeamManagement"; +distance = 4; +condition = QUOTE(alive _target && {!isPlayer _target} && {_target in units group _player} && {GVAR(EnableTeamManagement)}); +statement = ""; +showDisabled = 0; +priority = 3.2; +icon = PATHTOF(UI\team\team_management_ca.paa); +subMenu[] = {"ACE_TeamManagement", 0}; +hotkey = "M"; +enableInside = 1; +*/ + +/* +[ + [ + "Launch", + "\a3\ui_f\data\IGUI\Cfg\Actions\eject_ca.paa", + [0,0,0], + { (_this select 0) setVelocity [0,0,10]; }, + { true }, + 1, + [] + ] +] +*/ + +_actionsCfg = configFile >> "CfgVehicles" >> _objectType >> "ACE_Actions"; + + +_recurseFnc = { + private ["_actions", "_displayName", "_distance", "_icon", "_statement", "_condition", "_showDisabled", + "_enableInside", "_children", "_entry", "_actionsCfg"]; + _actions = []; + _actionsCfg = _this select 0; + for "_i" from 0 to (count _actionsCfg)-1 do { + _entryCfg = _actionsCfg select _i; + if(isClass _entryCfg) then { + _displayName = getText (_entryCfg >> "displayName"); + _distance = getNumber (_entryCfg >> "distance"); + _icon = getText (_entryCfg >> "icon"); + _statement = compile (getText (_entryCfg >> "statement")); + + _condition = getText (_entryCfg >> "condition"); + + _showDisabled = getNumber (_entryCfg >> "showDisabled"); + _enableInside = getNumber (_entryCfg >> "enableInside"); + + _condition = compile _condition; + diag_log text format["_condition: %1", _condition]; + _children = []; + if(isArray (_entryCfg >> "subMenu")) then { + _subMenuDef = getArray (_entryCfg >> "subMenu"); + _childMenuName = _subMenuDef select 0; + _childMenuCfg = configFile >> "CfgVehicles" >> _objectType >> "ACE_Actions" >> _childMenuName; + _children = [_childMenuCfg] call _recurseFnc; + }; + _entry = [ + _displayName, + _icon, + [0,0,0], + _statement, + _condition, + _distance, + _children + ]; + + _actions pushBack _entry; + }; + }; + _actions +}; + +_actions = [_actionsCfg] call _recurseFnc; + +_actions = [[ + "TEST!", + "\a3\ui_f\data\IGUI\Cfg\Actions\eject_ca.paa", + "Spine3", + { true }, + { true }, + 5, + _actions +]]; + + +_object setVariable [QUOTE(GVAR(actionData)), _actions]; \ No newline at end of file diff --git a/addons/interact_menu/functions/fnc_keyDown.sqf b/addons/interact_menu/functions/fnc_keyDown.sqf new file mode 100644 index 0000000000..e18ec69ae8 --- /dev/null +++ b/addons/interact_menu/functions/fnc_keyDown.sqf @@ -0,0 +1,8 @@ +//fnc_keyDown.sqf +#include "script_component.hpp" + +if(!GVAR(keyDown)) then { + GVAR(keyDown) = true; + GVAR(keyDownTime) = diag_tickTime; +}; +true diff --git a/addons/interact_menu/functions/fnc_keyUp.sqf b/addons/interact_menu/functions/fnc_keyUp.sqf new file mode 100644 index 0000000000..8f91b1322d --- /dev/null +++ b/addons/interact_menu/functions/fnc_keyUp.sqf @@ -0,0 +1,15 @@ +//fnc_keyUp.sqf +#include "script_component.hpp" + +GVAR(keyDown) = false; +if(GVAR(actionSelected)) then { + this = GVAR(selectedTarget); + _player = ACE_Player; + _target = GVAR(selectedTarget); + [GVAR(selectedTarget), player] call GVAR(selectedAction); +}; +GVAR(expanded) = false; +GVAR(lastPath) = []; +GVAR(menuDepthPath) = []; +GVAR(vecLineMap) = []; +true diff --git a/addons/interact_menu/functions/fnc_probe.sqf b/addons/interact_menu/functions/fnc_probe.sqf new file mode 100644 index 0000000000..ef4c5787bb --- /dev/null +++ b/addons/interact_menu/functions/fnc_probe.sqf @@ -0,0 +1,42 @@ +//fnc_probe.sqf +#include "script_component.hpp" + +private ["_nearestObjects", "_actionObject", "_x", "_actionData", "_renderData", "_actionItem", "_active", "_renderItem", "_object", "_forEachIndex"]; +if(!GVAR(keyDown)) then { + _nearestObjects = nearestObjects [(getPos player), ["All"], 100]; + + GVAR(toRender) = []; + { + _actionObject = _x; + _actionData = _actionObject getVariable [QUOTE(GVAR(actionData)), []]; + + if((count _actionData) > 0) then { + _renderData = []; + { + _actionItem = _x; + this = _actionObject; + _target = _actionObject; + _player = ACE_player; + _active = [_target, ACE_player] call (_actionItem select 4); + player sideChat format["_active: %1 %2", _actionItem select 0, _active]; + if(_active) then { + _renderItem = +_actionItem; + _renderItem set[4, true]; + _renderData set[(count _renderData), _renderItem]; + }; + } forEach _actionData; + if((count _renderData) > 0) then { + GVAR(toRender) set[(count GVAR(toRender)), [_actionObject, _renderData]]; + }; + }; + } forEach _nearestObjects; + // player sideChat format["p: %1", count GVAR(toRender)]; +} else { + GVAR(filter) = []; + { + _object = _x select 0; + if(_object distance player > 100) then { + GVAR(filter) set[(count GVAR(filter)), _forEachIndex]; + }; + } forEach GVAR(toRender); +}; diff --git a/addons/interact_menu/functions/fnc_render.sqf b/addons/interact_menu/functions/fnc_render.sqf new file mode 100644 index 0000000000..9a0990e861 --- /dev/null +++ b/addons/interact_menu/functions/fnc_render.sqf @@ -0,0 +1,104 @@ +//fnc_render.sqf +#include "script_component.hpp" + +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]; +GVAR(currentOptions) = []; +if((count GVAR(toRender)) > 0 && GVAR(keyDown)) 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; + + GVAR(vecLineMap) = [_cp, _p1, _p2] call FUNC(rotateVectLineGetMap); + }; + { + if(!(_forEachIndex in GVAR(filter))) then { + GVAR(renderDepth) = 0; + _renderTargets = _x; + { + [_renderTargets select 0, _x, 0] call FUNC(renderMenu); + } forEach (_renderTargets select 1); + }; + } forEach GVAR(toRender); + // player sideChat format["c: %1", count GVAR(toRender)]; +}; + +if(GVAR(keyDown)) 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); + + if(_closestSelection != -1) then { + + _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); + }; + + if(_misMatch) then { + GVAR(lastPath) = _hoverPath; + GVAR(startHoverTime) = diag_tickTime; + GVAR(expanded) = false; + } else { + if(!GVAR(expanded) && diag_tickTime-GVAR(startHoverTime) > 0.5) 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) = []; + }; +}; +for "_i" from GVAR(iconCount) to (count GVAR(iconCtrls))-1 do { + ctrlDelete (GVAR(iconCtrls) select _i); +}; +GVAR(iconCtrls) resize GVAR(iconCount); +GVAR(iconCount) = 0; diff --git a/addons/interact_menu/functions/fnc_renderIcon.sqf b/addons/interact_menu/functions/fnc_renderIcon.sqf new file mode 100644 index 0000000000..91e142c95c --- /dev/null +++ b/addons/interact_menu/functions/fnc_renderIcon.sqf @@ -0,0 +1,28 @@ +//fnc_renderIcon.sqf +#include "script_component.hpp" +#define DEFAULT_ICON QUOTE(\z\ace\addons\interaction\ui\dot_ca.paa) +private ["_color", "_pos", "_sPos", "_ctrl", "_icon"]; +_text = _this select 0; +_color = _this select 1; +_pos = _this select 2; +_icon = _this select 6; +_sPos = worldToScreen _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; + if(_icon == "") then { + _icon = DEFAULT_ICON; + }; + _text = "" + _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 ctrlSetForegroundColor _color; + _opacity = _color select 3; + _control ctrlSetTextColor _color; + // _ctrl ctrlSetBackgroundColor [1,0,0,1]; + _ctrl ctrlCommit 0; +}; diff --git a/addons/interact_menu/functions/fnc_renderMenu.sqf b/addons/interact_menu/functions/fnc_renderMenu.sqf new file mode 100644 index 0000000000..2ab17e0140 --- /dev/null +++ b/addons/interact_menu/functions/fnc_renderMenu.sqf @@ -0,0 +1,63 @@ +//fnc_renderMenu.sqf +#include "script_component.hpp" + +private ["_object", "_actionData", "_distance", "_index", "_pos", "_cursorScreenPos", "_path", "_menuDepth", "_opacity", "_currentRenderDepth", "_radialOffset", "_active", "_x", "_offset", "_newPos", "_forEachIndex"]; + +_object = _this select 0; +_actionData = _this select 1; +_distance = _actionData select 5; +_index = _this select 2; + +if((count _this) > 3) then { + _pos = _this select 3; +} else { + 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) > 4) then { + _path = +(_this select 4); + }; + _menuDepth = (count GVAR(menuDepthPath)); + + _opacity = 1; + if(_menuDepth > 0 && _index != (GVAR(menuDepthPath) select (GVAR(renderDepth)))) then { + _opacity = ((GVAR(renderDepth)/_menuDepth)) max 0.25; + }; + _path set[(count _path), _index]; + // player sideChat format["r: %1", _actionData select 2]; + [_actionData select 0, [1,1,1,_opacity], _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 { + _radialOffset = 0; + { + // 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 { + _offset = [GVAR(vecLineMap), (270*(GVAR(renderDepth)%2))-(_radialOffset*45)] call FUNC(rotateVectLine); + _newPos = [ + (_pos select 0) + ((_offset select 0)*0.08*_distance), + (_pos select 1) + ((_offset select 1)*0.08*_distance), + (_pos select 2) + ((_offset select 2)*0.08*_distance) + ]; + // drawLine3D [_pos, _newPos, [1,0,0,1]]; + [_object, _x, _forEachIndex, _newPos, _path] call FUNC(renderMenu); + _radialOffset = _radialOffset + 1; + }; + // }; + } forEach (_actionData select 6); + }; + GVAR(renderDepth) = GVAR(renderDepth) - 1; +}; diff --git a/addons/interact_menu/functions/fnc_rotateVectLine.sqf b/addons/interact_menu/functions/fnc_rotateVectLine.sqf new file mode 100644 index 0000000000..d411ffbf84 --- /dev/null +++ b/addons/interact_menu/functions/fnc_rotateVectLine.sqf @@ -0,0 +1,40 @@ +//fnc_rotateVectLine.sqf +#include "script_component.hpp" + +private ["_theta", "_p", "_map", "_p1", "_p2", "_q1", "_q2", "_u", "_d"]; +_map = _this select 0; +_theta = _this select 1; + +_p = _map select 0; +_p1 = _map select 1; +_p2 = _map select 2; + +_q1 = +(_map select 3); +_q2 = +(_map select 4); +_u = _map select 5; +_d = _map select 6; + +/* Step 4 */ +_q2 set[0, (_q1 select 0) * cos(_theta) - (_q1 select 1) * sin(_theta)]; +_q2 set[1, (_q1 select 0) * sin(_theta) + (_q1 select 1) * cos(_theta)]; +_q2 set[2, (_q1 select 2)]; + +/* Inverse of step 3 */ +_q1 set[0, (_q2 select 0) * _d + (_q2 select 2) * (_u select 0)]; +_q1 set[1, (_q2 select 1)]; +_q1 set[2, - (_q2 select 0) * (_u select 0) + (_q2 select 2) * _d]; + +/* Inverse of step 2 */ +if (_d != 0) then { + _q2 set[0, (_q1 select 0)]; + _q2 set[1, (_q1 select 1) * (_u select 2) / _d + (_q1 select 2) * (_u select 1) / _d]; + _q2 set[2, - (_q1 select 1) * (_u select 1) / _d + (_q1 select 2) * (_u select 2) / _d]; +} else { + _q2 = _q1; +}; + +/* Inverse of step 1 */ +_q1 set[0, (_q2 select 0) + (_p1 select 0)]; +_q1 set[1, (_q2 select 1) + (_p1 select 1)]; +_q1 set[2, (_q2 select 2) + (_p1 select 2)]; +_q1; diff --git a/addons/interact_menu/functions/fnc_rotateVectLineGetMap.sqf b/addons/interact_menu/functions/fnc_rotateVectLineGetMap.sqf new file mode 100644 index 0000000000..40a1d0ca0c --- /dev/null +++ b/addons/interact_menu/functions/fnc_rotateVectLineGetMap.sqf @@ -0,0 +1,39 @@ +//fnc_rotateVectLineGetMap.sqf +#include "script_component.hpp" + +private ["_p", "_p1", "_p2", "_q1", "_q2", "_u", "_d"]; + +_p = _this select 0; +_p1 = _this select 1; +_p2 = _this select 2; + +_q1 = []; +_q2 = []; +_u = []; + +/* Step 1 */ +_q1 set[0, (_p select 0) - (_p1 select 0)]; +_q1 set[1, (_p select 1) - (_p1 select 1)]; +_q1 set[2, (_p select 2) - (_p1 select 2)]; + +_u set[0, (_p2 select 0) - (_p1 select 0)]; +_u set[1, (_p2 select 1) - (_p1 select 1)]; +_u set[2, (_p2 select 2) - (_p1 select 2)]; +_u = _u call BIS_fnc_unitVector; +_d = sqrt((_u select 1)*(_u select 1) + (_u select 2)*(_u select 2)); + +/* Step 2 */ +if (_d != 0) then { + _q2 set[0, (_q1 select 0)]; + _q2 set[1, (_q1 select 1) * (_u select 2) / _d - (_q1 select 2) * (_u select 1) / _d]; + _q2 set[2, (_q1 select 1) * (_u select 1) / _d + (_q1 select 2) * (_u select 2) / _d]; +} else { + _q2 = _q1; +}; + +/* Step 3 */ +_q1 set[0, (_q2 select 0) * _d - (_q2 select 2) * (_u select 0)]; +_q1 set[1, (_q2 select 1)]; +_q1 set[2, (_q2 select 0) * (_u select 0) + (_q2 select 2) * _d]; + +[_p, _p1, _p2, _q1, _q2, _u, _d] diff --git a/addons/interact_menu/functions/fnc_setToRender.sqf b/addons/interact_menu/functions/fnc_setToRender.sqf new file mode 100644 index 0000000000..7b37a1fc80 --- /dev/null +++ b/addons/interact_menu/functions/fnc_setToRender.sqf @@ -0,0 +1,6 @@ +//fnc_setToRender.sqf +#include "script_component.hpp" + +private ["_options"]; +_object = _this select 0; +_options = _this select 1; diff --git a/addons/interact_menu/functions/script_component.hpp b/addons/interact_menu/functions/script_component.hpp new file mode 100644 index 0000000000..723a7735f1 --- /dev/null +++ b/addons/interact_menu/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\ace\addons\interact_menu\script_component.hpp" \ No newline at end of file diff --git a/addons/interact_menu/script_component.hpp b/addons/interact_menu/script_component.hpp new file mode 100644 index 0000000000..958d1c802d --- /dev/null +++ b/addons/interact_menu/script_component.hpp @@ -0,0 +1,12 @@ +#define COMPONENT interact_menu +#include "\z\ace\addons\main\script_mod.hpp" + +#ifdef DEBUG_ENABLED_INTERACT_MENU + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_INTERACT_MENU + #define DEBUG_SETTINGS DEBUG_SETTINGS_INTERACT_MENU +#endif + +#include "\z\ace\addons\main\script_macros.hpp" \ No newline at end of file diff --git a/addons/interaction/XEH_preInit.sqf b/addons/interaction/XEH_preInit.sqf index e455223783..b09bcee71c 100644 --- a/addons/interaction/XEH_preInit.sqf +++ b/addons/interaction/XEH_preInit.sqf @@ -44,3 +44,7 @@ PREP(showMouseHint); PREP(sortOptionsByPriority); PREP(tapShoulder); PREP(updateTooltipPosition); + + + +