Merge pull request #2753 from acemod/showHudSetter

Showhud setter
This commit is contained in:
PabstMirror 2015-11-25 11:16:21 -06:00
commit 0b9044e3c7
8 changed files with 78 additions and 10 deletions

View File

@ -21,10 +21,10 @@ params ["_newUnit","_oldUnit"];
//set showHUD based on new unit status:
if ((_newUnit getVariable [QGVAR(isHandcuffed), false]) || {_newUnit getVariable [QGVAR(isSurrendering), false]}) then {
TRACE_1("Player Change (showHUD false)",_newUnit);
showHUD false;
["captive", [false, false, false, false, false, false, false, false]] call EFUNC(common,showHud);
} else {
TRACE_1("Player Change (showHUD true)",_newUnit);
showHUD true;
["captive", []] call EFUNC(common,showHud); //same as showHud true;
};
//If old player was escorting, stop

View File

@ -23,9 +23,9 @@ params ["_unit","_zeusIsOpen"];
if (!_zeusIsOpen) then {
if ((_unit getVariable [QGVAR(isHandcuffed), false]) || {_unit getVariable [QGVAR(isSurrendering), false]}) then {
TRACE_1("Player Change (showHUD false)",_unit);
showHUD false;
["captive", [false, false, false, false, false, false, false, false]] call EFUNC(common,showHud);
} else {
TRACE_1("Player Change (showHUD true)",_unit);
showHUD true;
["captive", []] call EFUNC(common,showHud); //same as showHud true;
};
};

View File

@ -38,7 +38,7 @@ if (_state) then {
_unit setVariable [QGVAR(CargoIndex), ((vehicle _unit) getCargoIndex _unit), true];
if (_unit == ACE_player) then {
showHUD false;
["captive", [false, false, false, false, false, false, false, false]] call EFUNC(common,showHud);
};
// fix anim on mission start (should work on dedicated servers)
@ -107,7 +107,7 @@ if (_state) then {
};
if (_unit == ACE_player) then {
showHUD true;
["captive", []] call EFUNC(common,showHud); //same as showHud true;
};
};

View File

@ -36,7 +36,7 @@ if (_state) then {
[_unit, QGVAR(Surrendered), true] call EFUNC(common,setCaptivityStatus);
if (_unit == ACE_player) then {
showHUD false;
["captive", [false, false, false, false, false, false, false, false]] call EFUNC(common,showHud);
};
[_unit] call EFUNC(common,fixLoweredRifleAnimation);
@ -75,7 +75,7 @@ if (_state) then {
if (_unit == ACE_player) then {
//only re-enable HUD if not handcuffed
if (!(_unit getVariable [QGVAR(isHandcuffed), false])) then {
showHUD true;
["captive", []] call EFUNC(common,showHud); //same as showHud true;
};
};

View File

@ -168,6 +168,7 @@ PREP(setVariableJIP);
PREP(setVariablePublic);
PREP(setVolume);
PREP(sortAlphabeticallyBy);
PREP(showHud);
PREP(stringCompare);
PREP(stringToColoredText);
PREP(stringRemoveWhiteSpace);
@ -292,6 +293,7 @@ PREP(hashListSet);
PREP(hashListPush);
GVAR(syncedEvents) = HASH_CREATE;
GVAR(showHudHash) = [] call FUNC(hashCreate);
//GVARS for execNextFrame and waitAndExec and waitUntilAndExecute
GVAR(waitAndExecArray) = [];

View File

@ -0,0 +1,66 @@
/*
* 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 <STRING><OPTIONAL>
* 1: Show Hud Bool Array (8 to set, empty to remove) <ARRAY><OPTIONAL>
* - [hud, info, radar, compass, direction, menu, group, cursors]
* - hud: Boolean - show scripted HUD (same as normal showHUD true/false)
* - info: Boolean - show vehicle + soldier info (hides weapon info from the HUD as well)
* - radar: Boolean - show vehicle radar
* - compass: Boolean - show vehicle compass
* - direction: Boolean - show tank direction indicator (not present in vanilla Arma 3)
* - menu: Boolean - show commanding menu (hides HC related menus)
* - group: Boolean - show group info bar (hides squad leader info bar)
* - cursors: Boolean - show HUD weapon cursors (connected with scripted HUD)
*
* Return Value:
* Resulting ShowHud Array <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; //sets `showHud` and returns the result array used
*
* Public: Yes
*/
#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"];
private _resultMask = [];
for "_index" from 0 to 7 do {
private _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

View File

@ -19,4 +19,4 @@ if (isNull (uiNamespace getVariable ["ACE_Helper_Display", objNull])) exitWith {
(QGVAR(InteractionHelper) call BIS_fnc_rscLayer) cutText ["", "PLAIN"];
showHUD true;
["mouseHint", []] call EFUNC(common,showHud); //This is equivalent to the old showHud true

View File

@ -50,4 +50,4 @@ if (_scroll == "") exitWith {
(_display displayCtrl 1002) ctrlSetText _scroll;
showHUD false;
["mouseHint", [false, true, true, true, true, true, true, false]] call EFUNC(common,showHud); //This is equivalent to the old showHud false