ACE3/addons/ui_units/functions/fnc_onSpeedLoad.sqf

33 lines
1.2 KiB
Plaintext
Raw Normal View History

2019-06-08 20:17:24 +00:00
#include "script_component.hpp"
params ["_ctrl"];
private _speed = (ctrlParent _ctrl) ctrlCreate [QGVAR(speed), -1];
2019-06-09 08:19:54 +00:00
private _units = (vehicle ACE_player) call FUNC(speedUnits);
2019-06-12 05:11:02 +00:00
_units call FUNC(speedInfo) params ["_unitText", "_ratio"];
2019-06-08 20:17:24 +00:00
2019-06-12 05:11:02 +00:00
((ctrlParent _speed) displayCtrl 1004) ctrlSetText _unitText;
GVAR(speedRatio) = _ratio;
2019-06-08 20:17:24 +00:00
private _settingEH = ["CBA_SettingChanged", {
params ["_setting", "_value"];
_thisArgs params ["_settingName", "_speed"];
if (_setting isEqualTo _settingName) then {
2019-06-12 05:11:02 +00:00
[_value] call FUNC(speedInfo) params ["_unitText", "_ratio"];
((ctrlParent _speed) displayCtrl 1004) ctrlSetText _unitText;
GVAR(speedRatio) = _ratio;
2019-06-08 20:17:24 +00:00
};
}, [_units select 1, _speed]] call CBA_fnc_addEventHandlerArgs;
[{
(_this select 0) params ["_ctrl", "_speed", "_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
_speed ctrlSetText ((speed vehicle ACE_player / GVAR(speedRatio)) toFixed 0);
2019-06-08 20:17:24 +00:00
}, 0, [_ctrl, _speed, _settingEH]] call CBA_fnc_addPerFrameHandler;