Make interac_menu work in real 2D:

- Children positions are calculated directly on screen space
- Saves a lot of worldToScreen, ATLtoASL, etc calls
- Selector is now a control instead of a 3D icon
This commit is contained in:
Nicolás Badano
2015-03-23 18:08:31 -03:00
parent 20362e8dc9
commit eb557bf777
36 changed files with 113 additions and 53 deletions

View File

@ -5,7 +5,7 @@
* Argument:
* 0: Object <OBJECT>
* 1: Action node <ARRAY>
* 2: 3D position <ARRAY> (Optional)
* 2: 3D position or 2D position <ARRAY> (Optional)
*
* Return value:
* Was the menu rendered <BOOL>
@ -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