mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
34 lines
1.3 KiB
Plaintext
34 lines
1.3 KiB
Plaintext
#include "script_component.hpp"
|
|
|
|
params ["_ctrl"];
|
|
|
|
private _speed = (ctrlParent _ctrl) ctrlCreate [QGVAR(speed), -1];
|
|
|
|
private _units = (vehicle ace_player) call FUNC(speedUnits);
|
|
private _speedInfo = [_units select 0] call FUNC(speedInfo);
|
|
|
|
((ctrlParent _speed) displayCtrl 1004) ctrlSetText (_speedInfo select 0);
|
|
GVAR(speedRatio) = _speedInfo select 1;
|
|
|
|
private _settingEH = ["CBA_SettingChanged", {
|
|
params ["_setting", "_value"];
|
|
_thisArgs params ["_settingName", "_speed"];
|
|
systemChat format ["%1 = %2", _setting, _value];
|
|
if (_setting isEqualTo _settingName) then {
|
|
private _speedInfo = [_value] call FUNC(speedInfo);
|
|
((ctrlParent _speed) displayCtrl 1004) ctrlSetText (_speedInfo select 0);
|
|
GVAR(speedRatio) = _speedInfo select 1;
|
|
};
|
|
}, [_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;
|
|
_speed ctrlSetText str (round (speed vehicle ace_player / GVAR(speedRatio)));
|
|
}, 0, [_ctrl, _speed, _settingEH]] call CBA_fnc_addPerFrameHandler;
|