Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parachute - Fix "hide altimeter" setting #6721

Merged
merged 3 commits into from
Dec 6, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;