ACE3/addons/ui_units/functions/fnc_onAltLoad.sqf

39 lines
1.3 KiB
Plaintext
Raw Normal View History

2019-06-08 20:17:24 +00:00
#include "script_component.hpp"
params ["_ctrl"];
private _alt = (ctrlParent _ctrl) ctrlCreate [QGVAR(alt), -1];
2019-06-09 08:19:54 +00:00
private _units = (vehicle ACE_player) call FUNC(altUnits);
2019-06-12 05:11:02 +00:00
_units call FUNC(altInfo) params ["_unitText", "_ratio"];
2019-06-08 20:17:24 +00:00
2019-06-12 05:11:02 +00:00
((ctrlParent _alt) displayCtrl 1005) ctrlSetText _unitText;
GVAR(altRatio) = _ratio;
2019-06-08 20:17:24 +00:00
private _settingEH = ["CBA_SettingChanged", {
params ["_setting", "_value"];
_thisArgs params ["_settingName", "_alt"];
if (_setting isEqualTo _settingName) then {
2019-06-12 05:11:02 +00:00
[_value] call FUNC(altInfo) params ["_unitText", "_ratio"];
((ctrlParent _alt) displayCtrl 1005) ctrlSetText _unitText;
GVAR(altRatio) = _ratio;
2019-06-08 20:17:24 +00:00
};
}, [_units select 1, _alt]] call CBA_fnc_addEventHandlerArgs;
[{
(_this select 0) params ["_ctrl", "_alt", "_settingEH"];
if (isNull _ctrl) exitWith {
[_this select 1] call CBA_fnc_removePerFrameHandler;
["CBA_SettingChanged", _settingEH] call CBA_fnc_removeEventHandler;
};
_ctrl ctrlSetFade 1;
_ctrl ctrlCommit 0;
2019-06-09 08:19:54 +00:00
private _altValue = (((getPosATL vehicle ACE_player) select 2) / GVAR(altRatio));
2019-06-08 20:17:24 +00:00
if (_altValue < 10) then {
_altValue = _altValue toFixed 1;
} else {
2019-06-09 08:04:43 +00:00
_altValue = _altValue toFixed 0;
2019-06-08 20:17:24 +00:00
};
_alt ctrlSetText _altValue;
}, 0, [_ctrl, _alt, _settingEH]] call CBA_fnc_addPerFrameHandler;