Parachute - Fix "hide altimeter" setting (#6721)

* Fix hide altimeter setting not working

Signed-off-by: Josuan Albin <josuanalbin@outlook.fr>

* Clean up altimeter PFH

* Put ! back inside
This commit is contained in:
Josuan Albin 2018-12-06 23:36:35 +01:00 committed by PabstMirror
parent fddc6c2f4d
commit de828a2997
3 changed files with 35 additions and 17 deletions

View File

@ -6,7 +6,7 @@ class RscInGameUI {
};
class RscUnitInfoSoldier: RscUnitInfo {
onLoad = QUOTE([ARR_4(""onLoad"",_this,""RscUnitInfo"",'IGUI')] call (uinamespace getvariable 'BIS_fnc_initDisplay'); uiNamespace setVariable [ARR_2('ACE_dlgSoldier', _this select 0)];);
onLoad = QUOTE([ARR_4(""onLoad"",_this,""RscUnitInfo"",'IGUI')] call (uinamespace getvariable 'BIS_fnc_initDisplay'); uiNamespace setVariable [ARR_2('ACE_dlgSoldier', _this select 0)]; [ARR_2('ace_infoDisplayChanged', [ARR_2(_this select 0, 'Soldier')])] call CBA_fnc_localEvent;);
};
class RscUnitInfoTank: RscUnitInfo {
@ -94,7 +94,7 @@ class RscInGameUI {
};
class RscUnitInfoParachute: RscUnitInfo {
onLoad = QUOTE([ARR_4(""onLoad"",_this,""RscUnitInfo"",'IGUI')] call (uinamespace getvariable 'BIS_fnc_initDisplay'); uiNamespace setVariable [ARR_2('ACE_dlgParachute', _this select 0)];);
onLoad = QUOTE([ARR_4(""onLoad"",_this,""RscUnitInfo"",'IGUI')] call (uinamespace getvariable 'BIS_fnc_initDisplay'); uiNamespace setVariable [ARR_2('ACE_dlgParachute', _this select 0)]; [ARR_2('ace_infoDisplayChanged', [ARR_2(_this select 0, 'Parachute')])] call CBA_fnc_localEvent;);
};
class RscUnitVehicle {

View File

@ -37,4 +37,3 @@ switch (_type) do {
} forEach [380, 382];
};
};
nil // switch might return true if no case was found. Just to make sure the return value matches

View File

@ -22,28 +22,47 @@ if (isNull (uiNamespace getVariable ["ACE_Altimeter", displayNull])) exitWith {}
GVAR(AltimeterActive) = true;
[{
if (!GVAR(AltimeterActive)) exitWith {[_this select 1] call CBA_fnc_removePerFrameEventHandler};
disableSerialization;
(_this select 0) params ["_display", "_unit", "_oldHeight", "_prevTime"];
if !("ACE_Altimeter" in assignedItems _unit) exitWith {[_this select 1] call CBA_fnc_removePerFrameEventHandler; call FUNC(hideAltimeter)};
private _display = uiNamespace getVariable ["ACE_Altimeter", displayNull];
private _HeightText = _display displayCtrl 1100;
private _DecendRate = _display displayCtrl 1000;
private _TimeText = _display displayCtrl 1001;
private _HeightText = _display displayCtrl 1100;
private _DecendRate = _display displayCtrl 1000;
private _TimeText = _display displayCtrl 1001;
[{
_this params ["_args", "_pfhID"];
_args params ["_unit", "_oldHeight", "_prevTime", "_HeightText", "_DecendRate", "_TimeText"];
if !(GVAR(AltimeterActive)) exitWith {
_pfhID call CBA_fnc_removePerFrameEventHandler;
};
if !("ACE_Altimeter" in assignedItems _unit) exitWith {
call FUNC(hideAltimeter);
_pfhID call CBA_fnc_removePerFrameEventHandler;
};
private _hour = floor daytime;
private _minute = floor ((daytime - _hour) * 60);
private _height = ((getPosASL _unit) select 2) + EGVAR(common,mapAltitude);
private _curTime = CBA_missionTime;
private _timeDiff = _curTime - _prevTime;
private _descentRate = if (_timeDiff > 0) then {floor((_oldHeight - _height) / _timeDiff)} else {0};
private _height = ((getPosASL _unit) select 2) + EGVAR(common,mapAltitude);
private _descentRate = if (_timeDiff > 0) then {
floor((_oldHeight - _height) / _timeDiff)
} else {
0
};
_TimeText ctrlSetText (format ["%1:%2", [_hour, 2] call CBA_fnc_formatNumber, [_minute, 2] call CBA_fnc_formatNumber]);
_HeightText ctrlSetText (format ["%1", floor _height]);
_DecendRate ctrlSetText (format ["%1", _descentRate max 0]);
(_this select 0) set [2, _height];
(_this select 0) set [3, _curTime];
}, 0.2, [uiNamespace getVariable ["ACE_Altimeter", displayNull], _unit, floor ((getPosASL _unit) select 2), CBA_missionTime]] call CBA_fnc_addPerFrameHandler;
(_this select 0) set [1, _height];
(_this select 0) set [2, _curTime];
}, 0.2, [
_unit,
floor ((getPosASL _unit) select 2),
CBA_missionTime,
_HeightText,
_DecendRate,
_TimeText
]] call CBA_fnc_addPerFrameHandler;