From 20565e8b026a89789721feb49bad1f4bf0457ce5 Mon Sep 17 00:00:00 2001 From: commy2 Date: Fri, 17 Apr 2015 11:02:01 +0200 Subject: [PATCH] hide height / velocity while parachuting, freefallig in expert mode, fix 692 --- addons/parachute/XEH_postInit.sqf | 3 +- addons/parachute/XEH_preInit.sqf | 1 + .../fnc_handleInfoDisplayChanged.sqf | 41 +++++++++++++++++++ 3 files changed, 43 insertions(+), 2 deletions(-) create mode 100644 addons/parachute/functions/fnc_handleInfoDisplayChanged.sqf diff --git a/addons/parachute/XEH_postInit.sqf b/addons/parachute/XEH_postInit.sqf index ead4b33943..2b449d9674 100644 --- a/addons/parachute/XEH_postInit.sqf +++ b/addons/parachute/XEH_postInit.sqf @@ -40,5 +40,4 @@ GVAR(PFH) = false; }] call EFUNC(common,addEventHandler); // don't show speed and height when in expert mode -["Parachute", {if (!cadetMode) then {_dlg = _this select 0; {(_dlg displayCtrl _x) ctrlShow false} forEach [121, 122, 1004, 1005, 1006, 1014];};}] call EFUNC(common,addInfoDisplayEventHandler); //@todo addEventHandler infoDisplayChanged with select 1 == "Parachute" -["Soldier", {if (!cadetMode) then {_dlg = _this select 0; {_ctrl = (_dlg displayCtrl _x); _ctrl ctrlSetPosition [0,0,0,0]; _ctrl ctrlCommit 0;} forEach [380, 382]};}] call EFUNC(common,addInfoDisplayEventHandler); //@todo addEventHandler infoDisplayChanged with select 1 == "Soldier" +["infoDisplayChanged", {_this call FUNC(handleInfoDisplayChanged)}] call EFUNC(common,addEventHandler); diff --git a/addons/parachute/XEH_preInit.sqf b/addons/parachute/XEH_preInit.sqf index 91c24606c6..f446d955b8 100644 --- a/addons/parachute/XEH_preInit.sqf +++ b/addons/parachute/XEH_preInit.sqf @@ -18,6 +18,7 @@ ADDON = false; PREP(doLanding); +PREP(handleInfoDisplayChanged); PREP(hideAltimeter); PREP(onEachFrame); PREP(showAltimeter); diff --git a/addons/parachute/functions/fnc_handleInfoDisplayChanged.sqf b/addons/parachute/functions/fnc_handleInfoDisplayChanged.sqf new file mode 100644 index 0000000000..9b076256dd --- /dev/null +++ b/addons/parachute/functions/fnc_handleInfoDisplayChanged.sqf @@ -0,0 +1,41 @@ +/* + * Author: commy2 + * Hides the height and velocity display while freefalling or parachuting on higher difficulties. + * + * Arguments: + * Stuff from infoDisplayChanged eventhandler. + * + * Return Value: + * None + * + * Public: No + */ +#include "script_component.hpp" + +private ["_dialog", "_type"]; + +_dialog = _this select 0; +_type = _this select 1; + +// don't do anything in noob mode +if (cadetMode) exitWith {}; + +switch (_type) do { + case ("Parachute"): { + { + (_dialog displayCtrl _x) ctrlShow false; + } forEach [121, 122, 1004, 1005, 1006, 1014]; + }; + + case ("Soldier"): { + { + private "_control"; + _control = (_dialog displayCtrl _x); + + // these reset ctrlShow every frame by the engine. Set height/width to 0 as work around. + _control ctrlSetPosition [0,0,0,0]; + _control ctrlCommit 0; + } forEach [380, 382]; + }; +}; +nil // switch might return true if no case was found. Just to make sure the return value matches