Skip to content

Commit

Permalink
UI - Add keybind to hide all hud elements (#10227)
Browse files Browse the repository at this point in the history
* UI - Add keybind to hide all hud elements

* Handle advFatigue stamina bar

* Update stringtable.xml

* Update docs/wiki/framework/ui-framework.md

Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>

---------

Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
  • Loading branch information
PabstMirror and LinkIsGrim authored Aug 22, 2024
1 parent 82f5019 commit afde726
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 17 deletions.
1 change: 1 addition & 0 deletions addons/advanced_fatigue/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ PREP(mainLoop);
PREP(moduleSettings);
PREP(removeDutyFactor);
PREP(renderDebugLines);
PREP(updateStaminaBar);
2 changes: 2 additions & 0 deletions addons/advanced_fatigue/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ call FUNC(renderDebugLines);
["CBA_settingsInitialized", {
if (!GVAR(enabled)) exitWith {};

[QEGVAR(ui,hideHud), LINKFUNC(updateStaminaBar)] call CBA_fnc_addEventHandler;

["baseline", {
private _fatigue = ACE_player getVariable [QGVAR(aimFatigue), 0];
switch (stance ACE_player) do {
Expand Down
2 changes: 1 addition & 1 deletion addons/advanced_fatigue/functions/fnc_mainLoop.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ systemChat format ["---- velocity %1 - respiratoryRate: %2 ----", (vectorMagnitu

[ACE_player, _perceivedFatigue, GVAR(anReserve) == 0, _fwdAngle, _sideAngle] call FUNC(handleEffects);

if (GVAR(enableStaminaBar)) then {
if (GVAR(enableStaminaBarRealized)) then {
[GVAR(anReserve) / AN_MAXRESERVE] call FUNC(handleStaminaBar);
};

Expand Down
25 changes: 25 additions & 0 deletions addons/advanced_fatigue/functions/fnc_updateStaminaBar.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "..\script_component.hpp"
/*
* Author: PabstMirror
* Updates the stamina bar state
*
* Arguments:
* None
*
* Return Value:
* None
*
* Example:
* [] call ace_advanced_fatigue_fnc_updateStaminaBar
*
* Public: No
*/

GVAR(enableStaminaBarRealized) = GVAR(enabled) && GVAR(enableStaminaBar) && {!(missionNamespace getVariable [QEGVAR(ui,hideHud), false])};
TRACE_1("updateStaminaBar",GVAR(enableStaminaBarRealized));

private _staminaBarContainer = uiNamespace getVariable [QGVAR(staminaBarContainer), controlNull];
if (isNull _staminaBarContainer) exitWith {};

_staminaBarContainer ctrlSetFade ([1, 0] select GVAR(enableStaminaBarRealized));
_staminaBarContainer ctrlCommit 0;
15 changes: 2 additions & 13 deletions addons/advanced_fatigue/initSettings.inc.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@
true,
1,
{
if (!_this) then {
private _staminaBarContainer = uiNamespace getVariable [QGVAR(staminaBarContainer), controlNull];
_staminaBarContainer ctrlSetFade 1;
_staminaBarContainer ctrlCommit 0;
};

call FUNC(updateStaminaBar);
[QGVAR(enabled), _this] call EFUNC(common,cbaSettings_settingChanged)
},
true // Needs mission restart
Expand All @@ -24,13 +19,7 @@
LSTRING(DisplayName),
true,
1,
{
if (!_this) then {
private _staminaBarContainer = uiNamespace getVariable [QGVAR(staminaBarContainer), controlNull];
_staminaBarContainer ctrlSetFade 1;
_staminaBarContainer ctrlCommit 0;
};
}
{call FUNC(updateStaminaBar)}
] call CBA_fnc_addSetting;

[
Expand Down
7 changes: 4 additions & 3 deletions addons/common/functions/fnc_showHud.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
*
* Arguments:
* 0: Source ID <STRING> (default: "")
* 1: Show Hud Bool Array (8 to set, empty to remove) <ARRAY> (default: [])
* - [hud, info, radar, compass, direction, menu, group, cursors]
* 1: Show Hud Bool Array (10 to set, empty to remove) <ARRAY> (default: [])
* - [hud, info, radar, compass, direction, menu, group, cursors, panels, kills]
* - 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
Expand All @@ -17,7 +17,8 @@
* - group: Boolean - show group info bar (hides squad leader info bar)
* - cursors: Boolean - show HUD weapon cursors (connected with scripted HUD)
* - panels: Boolean - show vehicle panels / GPS
* - ???: Boolean - Possibly related to changelog entry `Added: A new showKillConfirmations parameter for the showHud command`
* - kills: Boolean - show "x killed by y" systemChat messages
* - showIcon3D: is unsupported as it has inverted logic
*
* Return Value:
* Resulting ShowHud Array <ARRAY>
Expand Down
22 changes: 22 additions & 0 deletions addons/ui/XEH_clientInit.sqf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "script_component.hpp"
#include "\a3\ui_f\hpp\defineDIKCodes.inc"

// Exit on Headless
if (!hasInterface) exitWith {};
Expand Down Expand Up @@ -48,3 +49,24 @@ GVAR(elementsSet) = createHashMap;
}] call CBA_fnc_addEventHandler;

[QUOTE(ADDON), "AnimChanged", LINKFUNC(onAnimChanged), true] call EFUNC(common,addPlayerEH);


["ACE3 Common", QGVAR(hideHud), localize LSTRING(hideHud), {
GVAR(hideHud) = !(missionNamespace getVariable [QGVAR(hideHud), false]);
[QGVAR(hideHud), [GVAR(hideHud)]] call CBA_fnc_localEvent;

private _mask = [];
if (GVAR(hideHud)) then { _mask resize [10, false] };
[QGVAR(hideHud), _mask] call EFUNC(common,showHud);

if (missionNamespace getVariable [QGVAR(hideHud_hideChat), true]) then {
showChat !GVAR(hideHud);
};

if (!isNil "diwako_dui_main_toggled_off") then {
diwako_dui_main_toggled_off = GVAR(hideHud); // ref https://github.com/diwako/diwako_dui/wiki/Hiding-DUI-for-cutscenes
};
true
},
{false},
[DIK_F12, [false, true, false]], false] call CBA_fnc_addKeybind; // ctrl+f12
3 changes: 3 additions & 0 deletions addons/ui/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -722,5 +722,8 @@
<Italian>Nasconde l'icona mostrata in automatico quando qualcosa è davanti al cursore. La modifica richiede un riavvio del gioco.\nAttenzione: Non rimuovere l'azione stessa! È consigliato rimuovere solo il tasto dall'assegnazione 'Usa Azione Standard' per impedire interazioni non volute.</Italian>
<Portuguese>Esconde o ícone mostrado automaticamente quando algo está a frente do cursor. É preciso reiniciar o jogo.\nAviso: Não remove a ação em si! É recomendado desvincular a tecla de "Usar ação padrão" para previnir interações indesejadas.</Portuguese>
</Key>
<Key ID="STR_ACE_UI_hideHud">
<English>Hide all UI</English>
</Key>
</Package>
</Project>
9 changes: 9 additions & 0 deletions docs/wiki/framework/ui-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,12 @@ Adding new elements through scripting is currently not possible.
| 1 | `true` | Set element, preventing others to change it (except config, which always has priority) |
| 2 | `"ammoCount"` | Element name to modify |
| 3 | `false` | Hide the element |

### 2.2 Hide UI Keybind

There is a keybind that will hide most UI elements (<kbd>Ctrl</kbd>-<kbd>F12</kbd> by default).
It triggers an event that is listenable allowing other mods to hide their displays.

| Event Key | Parameters | Locality | Type | Description |
|---------- |------------|----------|------|-------------|
| `ace_ui_hideHud` | `[_set]` | Local | Listen | _set=true means things should be hidden

0 comments on commit afde726

Please sign in to comment.