From 72ce35d89c75def8e67e3e653ce85aaca331664d Mon Sep 17 00:00:00 2001 From: Josuan Albin Date: Thu, 6 Dec 2018 23:14:48 +0100 Subject: [PATCH 1/3] Fix hide altimeter setting not working Signed-off-by: Josuan Albin --- addons/common/RscInfoType.hpp | 4 ++-- addons/parachute/functions/fnc_handleInfoDisplayChanged.sqf | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/addons/common/RscInfoType.hpp b/addons/common/RscInfoType.hpp index 9da45d0ec20..0eadb83617f 100644 --- a/addons/common/RscInfoType.hpp +++ b/addons/common/RscInfoType.hpp @@ -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 { diff --git a/addons/parachute/functions/fnc_handleInfoDisplayChanged.sqf b/addons/parachute/functions/fnc_handleInfoDisplayChanged.sqf index 280765d8a29..935c1315fba 100644 --- a/addons/parachute/functions/fnc_handleInfoDisplayChanged.sqf +++ b/addons/parachute/functions/fnc_handleInfoDisplayChanged.sqf @@ -18,7 +18,7 @@ params ["_dialog", "_type"]; // don't do anything in noob mode -if (!GVAR(hideAltimeter)) exitWith {}; +if !(GVAR(hideAltimeter)) exitWith {}; switch (_type) do { case ("Parachute"): { @@ -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 From 941034a377a67952c38ef7c6729e381df3d9a4d2 Mon Sep 17 00:00:00 2001 From: Josuan Albin Date: Thu, 6 Dec 2018 23:16:54 +0100 Subject: [PATCH 2/3] Clean up altimeter PFH --- .../parachute/functions/fnc_showAltimeter.sqf | 45 +++++++++++++------ 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/addons/parachute/functions/fnc_showAltimeter.sqf b/addons/parachute/functions/fnc_showAltimeter.sqf index d4aa11f8838..e31d2863ebd 100644 --- a/addons/parachute/functions/fnc_showAltimeter.sqf +++ b/addons/parachute/functions/fnc_showAltimeter.sqf @@ -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; From 507888b59b2a6654f603d15c06ef14439f5c94f4 Mon Sep 17 00:00:00 2001 From: Josuan Albin Date: Thu, 6 Dec 2018 23:28:12 +0100 Subject: [PATCH 3/3] Put ! back inside --- addons/parachute/functions/fnc_handleInfoDisplayChanged.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/parachute/functions/fnc_handleInfoDisplayChanged.sqf b/addons/parachute/functions/fnc_handleInfoDisplayChanged.sqf index 935c1315fba..f1589e1e04c 100644 --- a/addons/parachute/functions/fnc_handleInfoDisplayChanged.sqf +++ b/addons/parachute/functions/fnc_handleInfoDisplayChanged.sqf @@ -18,7 +18,7 @@ params ["_dialog", "_type"]; // don't do anything in noob mode -if !(GVAR(hideAltimeter)) exitWith {}; +if (!GVAR(hideAltimeter)) exitWith {}; switch (_type) do { case ("Parachute"): {