From b6b88bff14c74ebda576a302ad928cbb0ccdd9bb Mon Sep 17 00:00:00 2001 From: Juhu <5894800-Juhu_@users.noreply.gitlab.com> Date: Fri, 7 Aug 2020 19:41:32 +0200 Subject: [PATCH] strafehud: use a hook to determine whether the strafehud is shown --- qcsrc/client/hud/panel/strafehud.qc | 2 +- qcsrc/client/mutators/events.qh | 3 +++ qcsrc/common/gamemodes/gamemode/cts/cl_cts.qc | 5 +++++ qcsrc/common/gamemodes/gamemode/race/cl_race.qc | 5 +++++ 4 files changed, 14 insertions(+), 1 deletion(-) diff --git a/qcsrc/client/hud/panel/strafehud.qc b/qcsrc/client/hud/panel/strafehud.qc index 379cc7150..63311dd11 100644 --- a/qcsrc/client/hud/panel/strafehud.qc +++ b/qcsrc/client/hud/panel/strafehud.qc @@ -64,7 +64,7 @@ void HUD_StrafeHUD() { if(!autocvar_hud_panel_strafehud || (spectatee_status == -1 && (autocvar_hud_panel_strafehud == 1 || autocvar_hud_panel_strafehud == 3)) || - (autocvar_hud_panel_strafehud == 3 && !(ISGAMETYPE(RACE) || ISGAMETYPE(CTS)))) return; + (autocvar_hud_panel_strafehud == 3 && !MUTATOR_CALLHOOK(HUD_StrafeHUD_showoptional))) return; } HUD_Panel_LoadCvars(); diff --git a/qcsrc/client/mutators/events.qh b/qcsrc/client/mutators/events.qh index 23bbe00d8..c606906ab 100644 --- a/qcsrc/client/mutators/events.qh +++ b/qcsrc/client/mutators/events.qh @@ -121,6 +121,9 @@ MUTATOR_HOOKABLE(HUD_Powerups_add, EV_NO_ARGS); /** return true to show the physics HUD panel when optional mode is enabled */ MUTATOR_HOOKABLE(HUD_Physics_showoptional, EV_NO_ARGS); +/** return true to show the strafehud when optional mode is enabled */ +MUTATOR_HOOKABLE(HUD_StrafeHUD_showoptional, EV_NO_ARGS); + /** return true to hide the score HUD panel */ MUTATOR_HOOKABLE(HUD_Score_show, EV_NO_ARGS); diff --git a/qcsrc/common/gamemodes/gamemode/cts/cl_cts.qc b/qcsrc/common/gamemodes/gamemode/cts/cl_cts.qc index 27d6b868e..b0cfc15db 100644 --- a/qcsrc/common/gamemodes/gamemode/cts/cl_cts.qc +++ b/qcsrc/common/gamemodes/gamemode/cts/cl_cts.qc @@ -7,6 +7,11 @@ MUTATOR_HOOKFUNCTION(cl_cts, HUD_Physics_showoptional) return ISGAMETYPE(CTS); // show the optional physics panel } +MUTATOR_HOOKFUNCTION(cl_cts, HUD_StrafeHUD_showoptional) +{ + return ISGAMETYPE(CTS); // show the optional strafehud +} + MUTATOR_HOOKFUNCTION(cl_cts, HUD_Score_show) { return spectatee_status == -1 && ISGAMETYPE(CTS); // hide the score panel while observing diff --git a/qcsrc/common/gamemodes/gamemode/race/cl_race.qc b/qcsrc/common/gamemodes/gamemode/race/cl_race.qc index c2346a4f2..84d88064c 100644 --- a/qcsrc/common/gamemodes/gamemode/race/cl_race.qc +++ b/qcsrc/common/gamemodes/gamemode/race/cl_race.qc @@ -153,6 +153,11 @@ MUTATOR_HOOKFUNCTION(cl_race, HUD_Physics_showoptional) return ISGAMETYPE(RACE); // show the optional physics panel } +MUTATOR_HOOKFUNCTION(cl_race, HUD_StrafeHUD_showoptional) +{ + return ISGAMETYPE(RACE); // show the optional strafehud +} + MUTATOR_HOOKFUNCTION(cl_race, HUD_Score_show) { return spectatee_status == -1 && ISGAMETYPE(RACE); // hide the score panel while observing -- 2.39.2