2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-04-07 19:46:43 +00:00
|
|
|
/*
|
|
|
|
* Author: Ruthberg
|
|
|
|
* Displays a wind info (colored arrow) in the top left corner of the screen
|
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Arguments:
|
2015-04-07 19:46:43 +00:00
|
|
|
* None
|
|
|
|
*
|
2016-06-18 09:50:41 +00:00
|
|
|
* Return Value:
|
2015-04-07 19:46:43 +00:00
|
|
|
* None
|
2016-01-05 07:39:29 +00:00
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [] call ace_weather_fnc_displayWindInfo
|
|
|
|
*
|
|
|
|
* Public: No
|
2015-04-07 19:46:43 +00:00
|
|
|
*/
|
2015-04-05 19:08:55 +00:00
|
|
|
|
|
|
|
#define __dsp (uiNamespace getVariable "RscWindIntuitive")
|
|
|
|
#define __ctrl (__dsp displayCtrl 132948)
|
|
|
|
|
|
|
|
if (GVAR(WindInfo)) exitWith {
|
2015-04-06 03:13:43 +00:00
|
|
|
GVAR(WindInfo) = false;
|
2016-01-06 22:26:16 +00:00
|
|
|
(["RscWindIntuitive"] call BIS_fnc_rscLayer) cutText ["", "PLAIN"];
|
2015-04-06 03:13:43 +00:00
|
|
|
true
|
2015-04-05 19:08:55 +00:00
|
|
|
};
|
|
|
|
|
2015-04-11 16:39:15 +00:00
|
|
|
EGVAR(advanced_ballistics,Protractor) = false;
|
|
|
|
1 cutText ["", "PLAIN"];
|
|
|
|
GVAR(WindInfo) = true;
|
2015-04-06 03:12:50 +00:00
|
|
|
|
2016-01-06 22:26:16 +00:00
|
|
|
|
|
|
|
TRACE_1("Starting Wind Info PFEH", GVAR(WindInfo));
|
|
|
|
|
2015-04-11 16:39:15 +00:00
|
|
|
[{
|
2016-01-06 22:26:16 +00:00
|
|
|
disableSerialization;
|
|
|
|
params ["", "_pfID"];
|
|
|
|
|
|
|
|
if ((!GVAR(WindInfo)) || {!([ACE_player, ACE_player, []] call EFUNC(common,canInteractWith))}) exitWith {
|
|
|
|
TRACE_1("Ending Wind Info PFEH", GVAR(WindInfo));
|
2015-04-11 16:39:15 +00:00
|
|
|
GVAR(WindInfo) = false;
|
2016-01-06 22:26:16 +00:00
|
|
|
(["RscWindIntuitive"] call BIS_fnc_rscLayer) cutText ["", "PLAIN"];
|
|
|
|
[_pfID] call CBA_fnc_removePerFrameHandler;
|
2015-04-11 16:39:15 +00:00
|
|
|
};
|
2015-04-17 04:44:38 +00:00
|
|
|
|
2016-01-06 22:26:16 +00:00
|
|
|
//Keeps the display open:
|
|
|
|
(["RscWindIntuitive"] call BIS_fnc_rscLayer) cutRsc ["RscWindIntuitive", "PLAIN", 1, false];
|
|
|
|
|
2016-01-05 07:39:29 +00:00
|
|
|
private _windSpeed = if (missionNamespace getVariable [QEGVAR(advanced_ballistics,enabled), false]) then {
|
2015-05-11 08:59:07 +00:00
|
|
|
// With wind gradient
|
|
|
|
[eyePos ACE_player, true, true, true] call FUNC(calculateWindSpeed);
|
2015-04-11 16:39:15 +00:00
|
|
|
} else {
|
2015-05-11 08:59:07 +00:00
|
|
|
// Without wind gradient
|
|
|
|
[eyePos ACE_player, false, true, true] call FUNC(calculateWindSpeed);
|
2015-04-11 16:39:15 +00:00
|
|
|
};
|
2016-01-06 22:26:16 +00:00
|
|
|
|
|
|
|
|
|
|
|
private _playerDir = (ACE_player call CBA_fnc_headDir) select 0;
|
2017-11-10 14:44:15 +00:00
|
|
|
private _windDir = (wind select 0) atan2 (wind select 1);
|
2016-01-23 02:43:22 +00:00
|
|
|
_windDir = 30 * (round(((_windDir - _playerDir + 360) % 360) / 30));
|
2015-04-06 03:12:50 +00:00
|
|
|
|
2015-04-11 16:39:15 +00:00
|
|
|
// Color Codes from https://en.wikipedia.org/wiki/Beaufort_scale#Modern_scale
|
2016-01-06 22:26:16 +00:00
|
|
|
private _beaufortNumber = 0;
|
|
|
|
private _windColor = [1, 1, 1, 1];
|
|
|
|
if (_windSpeed > 0.3) then { _windColor = [0.796, 1, 1, 1]; _beaufortNumber = 1; };
|
|
|
|
if (_windSpeed > 1.5) then { _windColor = [0.596, 0.996, 0.796, 1]; _beaufortNumber = 2; };
|
|
|
|
if (_windSpeed > 3.3) then { _windColor = [0.596, 0.996, 0.596, 1]; _beaufortNumber = 3; };
|
|
|
|
if (_windSpeed > 5.4) then { _windColor = [0.6, 0.996, 0.4, 1]; _beaufortNumber = 4; };
|
|
|
|
if (_windSpeed > 7.9) then { _windColor = [0.6, 0.996, 0.047, 1]; _beaufortNumber = 5; };
|
|
|
|
if (_windSpeed > 10.7) then { _windColor = [0.8, 0.996, 0.059, 1]; _beaufortNumber = 6; };
|
|
|
|
if (_windSpeed > 13.8) then { _windColor = [1, 0.996, 0.067, 1]; _beaufortNumber = 7; };
|
|
|
|
if (_windSpeed > 17.1) then { _windColor = [1, 0.796, 0.051, 1]; _beaufortNumber = 8; };
|
|
|
|
if (_windSpeed > 20.7) then { _windColor = [1, 0.596, 0.039, 1]; _beaufortNumber = 9; };
|
|
|
|
if (_windSpeed > 24.4) then { _windColor = [1, 0.404, 0.031, 1]; _beaufortNumber = 10; };
|
|
|
|
if (_windSpeed > 28.4) then { _windColor = [1, 0.22, 0.027, 1]; _beaufortNumber = 11; };
|
|
|
|
if (_windSpeed > 32.6) then { _windColor = [1, 0.078, 0.027, 1]; _beaufortNumber = 12; };
|
|
|
|
|
2015-04-06 03:12:50 +00:00
|
|
|
|
2016-01-06 22:26:16 +00:00
|
|
|
TRACE_3("update display",_beaufortNumber,_windDir,_windSpeed);
|
2015-04-11 16:39:15 +00:00
|
|
|
__ctrl ctrlSetTextColor _windColor;
|
2016-01-06 22:26:16 +00:00
|
|
|
if (_beaufortNumber > 0) then {
|
2016-04-08 18:34:50 +00:00
|
|
|
__ctrl ctrlSetText QPATHTOF(UI\wind_arrow_ca.paa);
|
2016-01-06 22:26:16 +00:00
|
|
|
__ctrl ctrlSetAngle [_windDir, 0.5, 0.5];
|
|
|
|
} else {
|
2016-04-08 18:34:50 +00:00
|
|
|
__ctrl ctrlSetText QPATHTOF(UI\wind_noneCircle_ca.paa);
|
2016-01-06 22:26:16 +00:00
|
|
|
};
|
|
|
|
__ctrl ctrlCommit 0;
|
|
|
|
|
|
|
|
//Update the beaufort balls:
|
|
|
|
(ctrlPosition __ctrl) params ["_ctrlX", "_ctrlY", "_ctrlWidth", "_ctrlHeight"];
|
|
|
|
private _centerX = _ctrlX + _ctrlWidth / 2;
|
|
|
|
private _centerY = _ctrlY + _ctrlHeight / 2;
|
|
|
|
private _ballHeight = _ctrlHeight / 17;
|
|
|
|
private _ballWidth = _ballHeight * 3/4;
|
|
|
|
|
|
|
|
for "_index" from 0 to (_beaufortNumber - 1) do {
|
|
|
|
private _ball = __dsp ctrlCreate ["RscPicture", _index];
|
2016-04-08 18:34:50 +00:00
|
|
|
_ball ctrlSetText QPATHTOF(UI\wind_dot_ca.paa);
|
2016-01-06 22:26:16 +00:00
|
|
|
_ball ctrlSetTextColor [1,1,1,1];
|
|
|
|
private _ballCenterX = _centerX - (_ballWidth / 2) + ((sin _windDir) * 0.013333) * (_index - 4.9) + ((cos _windDir) * 0.0125);
|
|
|
|
private _ballCenterY = _centerY - (_ballHeight / 2) - ((1 * cos _windDir) * 4/3*0.013333) * (_index - 4.9) + ((sin _windDir) * 0.0125);
|
|
|
|
_ball ctrlSetPosition [_ballCenterX, _ballCenterY, _ballWidth, _ballHeight];
|
|
|
|
_ball ctrlCommit 0;
|
|
|
|
};
|
2015-04-06 03:12:50 +00:00
|
|
|
|
2015-04-11 16:39:15 +00:00
|
|
|
}, 0.5, []] call CBA_fnc_addPerFrameHandler;
|
2015-04-05 19:08:55 +00:00
|
|
|
|
|
|
|
true
|