UI - Add keybind to hide all hud elements (#10227)

* 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>
This commit is contained in:
PabstMirror 2024-08-22 12:13:54 -05:00 committed by GitHub
parent 82f5019488
commit afde7264ba
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 69 additions and 17 deletions

View File

@ -10,3 +10,4 @@ PREP(mainLoop);
PREP(moduleSettings);
PREP(removeDutyFactor);
PREP(renderDebugLines);
PREP(updateStaminaBar);

View File

@ -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 {

View File

@ -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);
};

View File

@ -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;

View File

@ -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
@ -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;
[

View File

@ -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
@ -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>

View File

@ -1,4 +1,5 @@
#include "script_component.hpp"
#include "\a3\ui_f\hpp\defineDIKCodes.inc"
// Exit on Headless
if (!hasInterface) exitWith {};
@ -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

View File

@ -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>

View File

@ -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