2018-09-17 19:19:29 +00:00
|
|
|
#include "script_component.hpp"
|
2015-02-10 04:22:10 +00:00
|
|
|
/*
|
2015-08-07 14:43:06 +00:00
|
|
|
* Author: KoffeinFlummi, esteldunedain
|
2015-02-10 04:22:10 +00:00
|
|
|
* Display the adjustment knobs, update their value and fade them out later
|
|
|
|
*
|
|
|
|
* Arguments:
|
|
|
|
* None
|
|
|
|
*
|
|
|
|
* Return Value:
|
|
|
|
* None
|
|
|
|
*
|
2015-08-07 14:43:06 +00:00
|
|
|
* Example:
|
|
|
|
* [] call ace_scopes_fnc_showZeroing
|
|
|
|
*
|
2015-02-10 04:22:10 +00:00
|
|
|
* Public: No
|
|
|
|
*/
|
2015-02-10 02:00:40 +00:00
|
|
|
|
2015-08-07 14:43:06 +00:00
|
|
|
disableSerialization;
|
2015-02-10 02:00:40 +00:00
|
|
|
|
2016-09-04 14:44:22 +00:00
|
|
|
private _weaponIndex = [ACE_player, currentWeapon ACE_player] call EFUNC(common,getWeaponIndex);
|
2015-02-10 04:22:10 +00:00
|
|
|
if (_weaponIndex < 0) exitWith {};
|
2015-02-10 02:00:40 +00:00
|
|
|
|
2016-11-12 10:23:14 +00:00
|
|
|
private _adjustment = ACE_player getVariable [QGVAR(Adjustment), [[0, 0, 0], [0, 0, 0], [0, 0, 0]]];
|
2015-02-10 02:00:40 +00:00
|
|
|
|
2015-02-10 04:22:10 +00:00
|
|
|
// Display the adjustment knobs
|
2016-09-04 14:44:22 +00:00
|
|
|
private _layer = [QGVAR(Zeroing)] call BIS_fnc_rscLayer;
|
2015-02-10 04:22:10 +00:00
|
|
|
_layer cutRsc [QGVAR(Zeroing), "PLAIN", 0, false];
|
|
|
|
|
|
|
|
// Find the display
|
2016-09-04 14:44:22 +00:00
|
|
|
private _display = uiNamespace getVariable [QGVAR(ZeroingDisplay), displayNull];
|
2015-02-10 04:22:10 +00:00
|
|
|
if (isNull _display) exitWith {};
|
|
|
|
|
|
|
|
// Update values
|
2016-09-04 14:44:22 +00:00
|
|
|
private _zeroing = _adjustment select _weaponIndex;
|
2015-08-07 14:43:06 +00:00
|
|
|
_zeroing params ["_elevation", "_windage"];
|
2016-09-04 14:44:22 +00:00
|
|
|
private _vertical = _display displayCtrl 12;
|
|
|
|
private _horizontal = _display displayCtrl 13;
|
2017-11-29 10:38:19 +00:00
|
|
|
if (GVAR(simplifiedZeroing)) then {
|
|
|
|
_vertical ctrlSetText format["%1 m", round(_elevation)];
|
|
|
|
_horizontal ctrlSetText "";
|
2017-11-08 13:04:09 +00:00
|
|
|
} else {
|
2017-11-29 10:38:19 +00:00
|
|
|
if (GVAR(useLegacyUI)) then {
|
|
|
|
_vertical ctrlSetText (str _elevation);
|
|
|
|
_horizontal ctrlSetText (str _windage);
|
2017-11-08 13:04:09 +00:00
|
|
|
} else {
|
2017-11-29 10:38:19 +00:00
|
|
|
if (_elevation == 0) then {
|
|
|
|
_vertical ctrlSetText "0";
|
2017-11-08 13:04:09 +00:00
|
|
|
} else {
|
2017-11-29 10:38:19 +00:00
|
|
|
if (_elevation > 0) then {
|
|
|
|
_vertical ctrlSetText (str _elevation);
|
|
|
|
} else {
|
|
|
|
_vertical ctrlSetText format[localize LSTRING(DisplayAdjustmentDown), abs(_elevation)];
|
|
|
|
};
|
2017-11-08 13:04:09 +00:00
|
|
|
};
|
2017-11-29 10:38:19 +00:00
|
|
|
if (_windage == 0) then {
|
|
|
|
_horizontal ctrlSetText "0";
|
2017-11-08 13:04:09 +00:00
|
|
|
} else {
|
2017-11-29 10:38:19 +00:00
|
|
|
if (_windage > 0) then {
|
|
|
|
_horizontal ctrlSetText format[localize LSTRING(DisplayAdjustmentRight), abs(_windage)];
|
|
|
|
} else {
|
|
|
|
_horizontal ctrlSetText format[localize LSTRING(DisplayAdjustmentLeft), abs(_windage)];
|
|
|
|
};
|
2017-11-08 13:04:09 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2015-02-10 04:22:10 +00:00
|
|
|
|
2015-10-21 20:52:21 +00:00
|
|
|
// Set the time when to hide the knobs
|
2016-03-02 10:01:39 +00:00
|
|
|
GVAR(timeToHide) = diag_tickTime + 3.0;
|
2015-02-10 04:22:10 +00:00
|
|
|
|
|
|
|
if !(isNil QGVAR(fadePFH)) exitWith {};
|
|
|
|
|
|
|
|
// Launch a PFH to wait and fade out the knobs
|
|
|
|
GVAR(fadePFH) = [{
|
2016-03-02 10:01:39 +00:00
|
|
|
if (diag_tickTime >= GVAR(timeToHide)) exitWith {
|
2016-09-04 14:44:22 +00:00
|
|
|
private _pfhId = _this select 1;
|
|
|
|
private _layer = [QGVAR(Zeroing)] call BIS_fnc_rscLayer;
|
2015-02-10 04:22:10 +00:00
|
|
|
_layer cutFadeOut 2;
|
|
|
|
|
|
|
|
GVAR(fadePFH) = nil;
|
2015-11-30 15:45:20 +00:00
|
|
|
[_pfhId] call CBA_fnc_removePerFrameHandler;
|
2015-02-10 04:22:10 +00:00
|
|
|
};
|
|
|
|
}, 0.1, []] call CBA_fnc_addPerFrameHandler
|