2015-02-21 20:11:03 +00:00
|
|
|
/*
|
2015-03-24 04:18:00 +00:00
|
|
|
* Author: NouberNou and esteldunedain
|
2015-03-03 02:29:57 +00:00
|
|
|
* Render an interaction menu and it's children recursively
|
2015-02-21 20:11:03 +00:00
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Arguments:
|
2015-03-17 03:37:28 +00:00
|
|
|
* 0: Parent path <ARRAY>
|
2015-02-21 20:11:03 +00:00
|
|
|
* 1: Action data <ARRAY>
|
2015-03-23 21:08:31 +00:00
|
|
|
* 2: 2D position <ARRAY>
|
2015-02-21 20:11:03 +00:00
|
|
|
* 3: Angle range available for rendering <ARRAY>
|
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Return Value:
|
2015-03-03 02:29:57 +00:00
|
|
|
* None
|
2015-02-21 20:11:03 +00:00
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
2015-01-18 18:38:27 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-08-04 22:46:57 +00:00
|
|
|
params ["_parentPath", "_action", "_sPos", "_angles"];
|
|
|
|
_action params ["_actionData", "_activeChildren", "_actionObject"];
|
|
|
|
_angles params ["_centerAngle", "_maxAngleSpan"];
|
2015-02-19 13:38:09 +00:00
|
|
|
|
2016-01-08 04:43:37 +00:00
|
|
|
private _menuDepth = (count GVAR(menuDepthPath));
|
2015-02-27 04:55:16 +00:00
|
|
|
|
2015-03-23 21:08:31 +00:00
|
|
|
//BEGIN_COUNTER(constructing_paths);
|
|
|
|
|
2015-02-27 04:55:16 +00:00
|
|
|
// Store path to action
|
2016-01-08 04:43:37 +00:00
|
|
|
private _path = +_parentPath;
|
2015-03-20 02:32:44 +00:00
|
|
|
_path pushBack [_actionData select 0,_actionObject];
|
2015-02-27 04:55:16 +00:00
|
|
|
|
|
|
|
// Check if the menu is on the selected path
|
2016-01-08 04:43:37 +00:00
|
|
|
private _menuInSelectedPath = true;
|
2015-02-27 04:55:16 +00:00
|
|
|
{
|
|
|
|
if (_forEachIndex >= (count GVAR(menuDepthPath))) exitWith {
|
|
|
|
_menuInSelectedPath = false;
|
|
|
|
};
|
2015-03-17 03:37:28 +00:00
|
|
|
if !(_x isEqualTo (GVAR(menuDepthPath) select _forEachIndex)) exitWith {
|
2015-02-27 04:55:16 +00:00
|
|
|
_menuInSelectedPath = false;
|
2015-02-19 13:49:36 +00:00
|
|
|
};
|
2015-02-27 04:55:16 +00:00
|
|
|
} forEach _path;
|
2015-01-18 18:38:27 +00:00
|
|
|
|
2015-03-23 21:08:31 +00:00
|
|
|
//END_COUNTER(constructing_paths);
|
|
|
|
//BEGIN_COUNTER(constructing_colors);
|
|
|
|
|
2015-04-30 04:37:52 +00:00
|
|
|
//Get text color settings string
|
2016-01-08 04:43:37 +00:00
|
|
|
private _textSettings = GVAR(colorSelectedSettings);
|
2015-03-23 21:08:31 +00:00
|
|
|
if(!_menuInSelectedPath) then {
|
2015-04-30 04:37:52 +00:00
|
|
|
_textSettings = (GVAR(textSettingsMatrix) select (count _path)) select _menuDepth;
|
2015-02-27 04:55:16 +00:00
|
|
|
};
|
2015-03-23 21:08:31 +00:00
|
|
|
|
|
|
|
//END_COUNTER(constructing_colors);
|
|
|
|
//BEGIN_COUNTER(fnc_renderIcons);
|
|
|
|
|
2015-04-30 04:37:52 +00:00
|
|
|
[_actionData select 1, _actionData select 2, _sPos, _textSettings] call FUNC(renderIcon);
|
2015-03-23 21:08:31 +00:00
|
|
|
|
|
|
|
//END_COUNTER(fnc_renderIcons);
|
|
|
|
|
|
|
|
//BEGIN_COUNTER(currentOptions);
|
2015-02-27 04:55:16 +00:00
|
|
|
|
|
|
|
// Add the action to current options
|
2015-03-23 21:08:31 +00:00
|
|
|
GVAR(currentOptions) pushBack [_this, _sPos, _path];
|
|
|
|
|
|
|
|
//END_COUNTER(currentOptions);
|
2015-02-27 04:55:16 +00:00
|
|
|
|
|
|
|
// Exit without rendering children if it isn't
|
2015-02-28 20:48:46 +00:00
|
|
|
if !(_menuInSelectedPath) exitWith {true};
|
2015-02-27 04:55:16 +00:00
|
|
|
|
2015-03-23 21:08:31 +00:00
|
|
|
//BEGIN_COUNTER(children);
|
|
|
|
|
2016-01-08 04:43:37 +00:00
|
|
|
private _numChildren = count _activeChildren;
|
|
|
|
private _angleSpan = _maxAngleSpan min (55 * ((_numChildren) - 1));
|
2015-02-27 04:55:16 +00:00
|
|
|
if (_angleSpan >= 305) then {
|
|
|
|
_angleSpan = 360;
|
2015-01-18 18:38:27 +00:00
|
|
|
};
|
2016-01-08 04:43:37 +00:00
|
|
|
private _angleInterval = 55;
|
2015-03-19 18:04:48 +00:00
|
|
|
if (_angleSpan < 360) then {
|
2015-03-23 17:01:38 +00:00
|
|
|
if (_numChildren > 1) then {
|
|
|
|
_angleInterval = _angleSpan / (_numChildren - 1);
|
2015-03-19 18:04:48 +00:00
|
|
|
};
|
|
|
|
} else {
|
2015-03-24 03:15:22 +00:00
|
|
|
_angleInterval = _angleSpan / (_numChildren);
|
2015-03-19 18:04:48 +00:00
|
|
|
};
|
2015-03-23 17:01:38 +00:00
|
|
|
if (_numChildren == 1) then {
|
2015-03-24 03:15:22 +00:00
|
|
|
_angleInterval = 55;
|
2015-03-19 18:04:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// Scale menu based on the amount of children
|
2016-01-08 04:43:37 +00:00
|
|
|
private _scaleX = 1;
|
|
|
|
private _scaleY = 1;
|
2015-05-01 03:32:16 +00:00
|
|
|
|
|
|
|
if (GVAR(UseListMenu)) then {
|
2016-01-08 04:43:37 +00:00
|
|
|
private _textSize = [0.75, 0.875, 1, 1.2, 1.4] select GVAR(textSize);
|
2015-05-01 03:32:16 +00:00
|
|
|
_scaleX = _textSize * 0.17 * 1.1;
|
|
|
|
_scaleY = 0.17 * 0.30 * 4/3;
|
2015-04-12 04:15:38 +00:00
|
|
|
} else {
|
2016-01-08 04:43:37 +00:00
|
|
|
private _textSize = if (GVAR(textSize) > 2) then {1.3} else {1};
|
2015-05-01 03:32:16 +00:00
|
|
|
_scaleX = _textSize * 0.17 * (((0.8 * (0.46 / sin (0.5 * _angleInterval))) min 1.1) max 0.5);
|
|
|
|
_scaleY = _textSize * 0.17 * 4/3 * (((0.8 * (0.46 / sin (0.5 * _angleInterval))) min 1.1) max 0.5);
|
2015-04-12 04:15:38 +00:00
|
|
|
};
|
|
|
|
|
2015-03-19 18:04:48 +00:00
|
|
|
// Animate menu scale
|
2015-10-20 18:26:42 +00:00
|
|
|
if (_menuInSelectedPath && {_menuDepth == count _path}) then {
|
2016-03-02 10:01:39 +00:00
|
|
|
_scaleX = _scaleX * (0.3 + 0.7 * (((diag_tickTime - GVAR(expandedTime)) * linearConversion [0, 2, GVAR(menuAnimationSpeed), 8, 16]) min 1));
|
|
|
|
_scaleY = _scaleY * (0.3 + 0.7 * (((diag_tickTime - GVAR(expandedTime)) * linearConversion [0, 2, GVAR(menuAnimationSpeed), 8, 16]) min 1));
|
2015-03-19 18:04:48 +00:00
|
|
|
};
|
2015-02-27 04:55:16 +00:00
|
|
|
|
2016-01-08 04:43:37 +00:00
|
|
|
private _target = _actionObject;
|
|
|
|
private _player = ACE_player;
|
2015-03-23 21:08:31 +00:00
|
|
|
|
|
|
|
//END_COUNTER(children);
|
2016-01-08 04:43:37 +00:00
|
|
|
private _angle = _centerAngle - _angleSpan / 2;
|
2015-02-27 04:55:16 +00:00
|
|
|
{
|
2016-01-08 04:43:37 +00:00
|
|
|
private _newPos = if (GVAR(UseListMenu)) then {
|
2015-04-30 19:07:19 +00:00
|
|
|
[(_sPos select 0) + _scaleX,
|
2015-11-30 16:25:16 +00:00
|
|
|
(_sPos select 1) + _scaleY * (_forEachIndex - _numChildren/2 + 0.5)];
|
2015-04-30 19:07:19 +00:00
|
|
|
} else {
|
|
|
|
[(_sPos select 0) - _scaleX * (cos _angle),
|
2015-05-01 03:32:16 +00:00
|
|
|
(_sPos select 1) + _scaleY * (sin _angle)];
|
2015-04-30 19:07:19 +00:00
|
|
|
};
|
2015-02-27 04:55:16 +00:00
|
|
|
|
2015-03-24 03:15:22 +00:00
|
|
|
[_path, _x, _newPos, [_angle, 150]] call FUNC(renderMenu);
|
2015-02-27 04:55:16 +00:00
|
|
|
|
2015-03-23 17:01:38 +00:00
|
|
|
_angle = _angle + _angleInterval;
|
2015-02-27 04:55:16 +00:00
|
|
|
} forEach _activeChildren;
|
2015-02-28 20:48:46 +00:00
|
|
|
|
|
|
|
true
|