Skip to content

Commit

Permalink
Parachute - Fix "hide altimeter" setting (#6721)
Browse files Browse the repository at this point in the history
* Fix hide altimeter setting not working

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

* Clean up altimeter PFH

* Put ! back inside
  • Loading branch information
alganthe authored and PabstMirror committed Dec 6, 2018
1 parent a3b1996 commit 1273cca
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 16 deletions.
4 changes: 2 additions & 2 deletions addons/common/RscInfoType.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
45 changes: 32 additions & 13 deletions addons/parachute/functions/fnc_showAltimeter.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,47 @@ if (isNull (uiNamespace getVariable ["ACE_Altimeter", displayNull])) exitWith {}

GVAR(AltimeterActive) = true;

private _display = uiNamespace getVariable ["ACE_Altimeter", displayNull];
private _HeightText = _display displayCtrl 1100;
private _DecendRate = _display displayCtrl 1000;
private _TimeText = _display displayCtrl 1001;

[{
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)};
_this params ["_args", "_pfhID"];
_args params ["_unit", "_oldHeight", "_prevTime", "_HeightText", "_DecendRate", "_TimeText"];

if !(GVAR(AltimeterActive)) exitWith {
_pfhID call CBA_fnc_removePerFrameEventHandler;
};

private _HeightText = _display displayCtrl 1100;
private _DecendRate = _display displayCtrl 1000;
private _TimeText = _display displayCtrl 1001;
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;

0 comments on commit 1273cca

Please sign in to comment.