mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Rewrite fnc_getRange to work with specified minimum and maximum ranges
Also cleaning up fnc_keyUp a bit
This commit is contained in:
parent
ca5f6df3d0
commit
05ce4f824c
@ -3,7 +3,9 @@
|
||||
* Read laser distance measurement from engine.
|
||||
*
|
||||
* Argument:
|
||||
* None
|
||||
* 0: Measurement Accuracy (default: 1) <NUMBER>
|
||||
* 1: Maximum measure distance (default: 5000) <NUMBER>
|
||||
* 2: Minimum measure distance (default: 0) <NUMBER>
|
||||
*
|
||||
* Return value:
|
||||
* Measured distance <NUMBER>
|
||||
@ -12,7 +14,26 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
params [["_accuracy",1], ["_maxDistance",5000], ["_minDistance",0]];
|
||||
|
||||
disableSerialization;
|
||||
private _dlgRangefinder = uiNamespace getVariable ["ACE_dlgRangefinder", displayNull];
|
||||
|
||||
parseNumber ctrlText (_dlgRangefinder displayCtrl 151);
|
||||
private _distance = parseNumber ctrlText (_dlgRangefinder displayCtrl 151);
|
||||
|
||||
if (isNil "_distance" || _distance == 0) then {
|
||||
_distance = _this call EFUNC(common,getTargetDistance);
|
||||
} else {
|
||||
if (_distance > _maxDistance) then {
|
||||
_distance = _maxDistance;
|
||||
};
|
||||
|
||||
if (_distance < _minDistance) then {
|
||||
_distance = _minDistance;
|
||||
};
|
||||
|
||||
_accuracy = if(_accuracy < 1) then {1} else {_accuracy};
|
||||
_distance = (round (_distance/_accuracy)) * _accuracy;
|
||||
};
|
||||
|
||||
_distance
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
params ["_vehicle", "_turret"];
|
||||
|
||||
private _distance = call FUNC(getRange);
|
||||
private _distance = [] call FUNC(getRange);
|
||||
call FUNC(updateRangeHUD);
|
||||
|
||||
if !(!GVAR(enabled) && FUNC(canUseFCS)) exitWith {};
|
||||
@ -23,9 +23,6 @@ if !(!GVAR(enabled) && FUNC(canUseFCS)) exitWith {};
|
||||
GVAR(Enabled) = true;
|
||||
GVAR(time) = ACE_time;
|
||||
|
||||
if (_distance == 0) then {
|
||||
_distance = [5, 5000, 0] call EFUNC(common,getTargetDistance); // maximum distance: 5000m, 5m precision
|
||||
};
|
||||
|
||||
private _weaponDirection = _vehicle weaponDirection (_vehicle currentWeaponTurret _turret); // @todo doesn't work for sub turrets
|
||||
|
||||
|
@ -20,15 +20,11 @@ private _turretConfig = [configFile >> "CfgVehicles" >> typeOf _vehicle, _turret
|
||||
call FUNC(updateRangeHUD);
|
||||
|
||||
if (isNil "_distance") then {
|
||||
_distance = call FUNC(getRange);
|
||||
|
||||
if (_distance == 0) then {
|
||||
_distance = [
|
||||
getNumber (_turretConfig >> QGVAR(DistanceInterval)),
|
||||
getNumber (_turretConfig >> QGVAR(MaxDistance)),
|
||||
getNumber (_turretConfig >> QGVAR(MinDistance))
|
||||
] call EFUNC(common,getTargetDistance); // maximum distance: 5000m, 5m precision
|
||||
};
|
||||
_distance = [
|
||||
getNumber (_turretConfig >> QGVAR(DistanceInterval)),
|
||||
getNumber (_turretConfig >> QGVAR(MaxDistance)),
|
||||
getNumber (_turretConfig >> QGVAR(MinDistance))
|
||||
] call FUNC(getRange);
|
||||
};
|
||||
|
||||
private _weapon = _vehicle currentWeaponTurret _turret;
|
||||
@ -172,10 +168,9 @@ if (_showHint) then {
|
||||
[format ["%1: %2", localize LSTRING(ZeroedTo), _distance]] call EFUNC(common,displayTextStructured);
|
||||
};
|
||||
|
||||
//Update the hud's distance display to the new value or "----" if out of range
|
||||
//(10m fudge because of EFUNC(common,getTargetDistance))
|
||||
if (_distance + 10 >= getNumber (_turretConfig >> QGVAR(MaxDistance))) then {
|
||||
((uiNamespace getVariable ["ACE_dlgRangefinder", displayNull]) displayCtrl 1713151) ctrlSetText "----";
|
||||
// Display the minimum or maximum distance with an * if out of bounds
|
||||
if (_distance >= getNumber (_turretConfig >> QGVAR(MaxDistance)) || _distance <= getNumber (_turretConfig >> QGVAR(MinDistance))) then {
|
||||
((uiNamespace getVariable ["ACE_dlgRangefinder", displayNull]) displayCtrl 1713151) ctrlSetText ([_distance, 4, 0] call CBA_fnc_formatNumber) + "*";
|
||||
} else {
|
||||
((uiNamespace getVariable ["ACE_dlgRangefinder", displayNull]) displayCtrl 1713151) ctrlSetText ([_distance, 4, 0] call CBA_fnc_formatNumber);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user