diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index ff06c1c3e3..ef29315dd7 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -165,6 +165,7 @@ PREP(setVariableJIP); PREP(setVariablePublic); PREP(setVolume); PREP(sortAlphabeticallyBy); +PREP(showHud); PREP(stringCompare); PREP(stringToColoredText); PREP(stringRemoveWhiteSpace); @@ -288,6 +289,7 @@ PREP(hashListSet); PREP(hashListPush); GVAR(syncedEvents) = HASH_CREATE; +GVAR(showHudHash) = [] call FUNC(hashCreate); //GVARS for execNextFrame and waitAndExec and waitUntilAndExecute GVAR(waitAndExecArray) = []; diff --git a/addons/common/functions/fnc_showHud.sqf b/addons/common/functions/fnc_showHud.sqf new file mode 100644 index 0000000000..1ae36ca089 --- /dev/null +++ b/addons/common/functions/fnc_showHud.sqf @@ -0,0 +1,58 @@ +/* + * Author: PabstMirror + * Allows multiple sources to not overwrite showHud command + * Bitwise AND Logic (a single false in a mask will make it false) + * + * Arguments: + * 0: Source ID + * 1: Show Hud Bool Array (8 to set, empty to remove) + * + * Return Value: + * Resulting ShowHud Array + * + * Example: + * ["hideHud", [false, true, true, true, true, true, true, false]] call ace_common_fnc_showHud; //This is equivalent to the old showHud false + * [] call ace_common_fnc_showHud + * + * Public: Yes + */ +#define DEBUG_MODE_FULL +#include "script_component.hpp" + +if (!hasInterface) exitWith {[-1]}; + +params [["_reason", "", [""]], ["_mask", [], [[]], [0,8]]]; + +if (isArray (missionConfigFile >> "showHUD")) then { + //(showHud = 0;) is fine - the array is the problem + ACE_LOGWARNING("showHUD[] in Description.ext breaks the showHud command"); +}; + +if (_reason != "") then { + _reason = toLower _reason; + if (_mask isEqualTo []) then { + TRACE_2("Setting", _reason, _mask); + [GVAR(showHudHash), _reason] call FUNC(hashRem); + } else { + TRACE_2("Removing", _reason, _mask); + [GVAR(showHudHash), _reason, _mask] call FUNC(hashSet); + }; +}; + +GVAR(showHudHash) params ["_reasons", "_masks"]; +local _resultMask = []; + +for "_index" from 0 to 7 do { + local _set = true; //Default to true + { + if (!(_x select _index)) exitWith { + _set = false; //Any false will make it false + }; + } forEach _masks; + _resultMask pushBack _set; +}; + +TRACE_2("showHud", _resultMask, _reasons); +showHud _resultMask; + +_resultMask