From e860f4fc6e3c8cb1ef89eb47fa205c6ff4018c47 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 13 Jul 2020 17:44:10 +1000 Subject: [PATCH] Add a mutator hook to indicate whether the physics HUD panel should be shown when set to optional --- qcsrc/client/hud/panel/physics.qc | 2 +- qcsrc/client/mutators/events.qh | 3 +++ qcsrc/common/gamemodes/gamemode/cts/_mod.inc | 3 +++ qcsrc/common/gamemodes/gamemode/cts/_mod.qh | 3 +++ qcsrc/common/gamemodes/gamemode/cts/cl_cts.qc | 8 ++++++++ qcsrc/common/gamemodes/gamemode/cts/cl_cts.qh | 1 + qcsrc/common/gamemodes/gamemode/race/cl_race.qc | 7 +++++++ 7 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 qcsrc/common/gamemodes/gamemode/cts/cl_cts.qc create mode 100644 qcsrc/common/gamemodes/gamemode/cts/cl_cts.qh diff --git a/qcsrc/client/hud/panel/physics.qc b/qcsrc/client/hud/panel/physics.qc index e49ea3a48c..d45aea2c11 100644 --- a/qcsrc/client/hud/panel/physics.qc +++ b/qcsrc/client/hud/panel/physics.qc @@ -39,7 +39,7 @@ void HUD_Physics() { if(!autocvar_hud_panel_physics) return; if(spectatee_status == -1 && (autocvar_hud_panel_physics == 1 || autocvar_hud_panel_physics == 3)) return; - if(autocvar_hud_panel_physics == 3 && !(ISGAMETYPE(RACE) || ISGAMETYPE(CTS))) return; + if(autocvar_hud_panel_physics == 3 && !MUTATOR_CALLHOOK(HUD_Physics_showoptional)) return; } HUD_Panel_LoadCvars(); diff --git a/qcsrc/client/mutators/events.qh b/qcsrc/client/mutators/events.qh index d08b020e35..7ddcb204aa 100644 --- a/qcsrc/client/mutators/events.qh +++ b/qcsrc/client/mutators/events.qh @@ -118,6 +118,9 @@ MUTATOR_HOOKABLE(HUD_Draw_overlay, EV_HUD_Draw_overlay); 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 not draw any vortex beam */ #define EV_Particles_VortexBeam(i, o) \ /** beam shot origin */ i(vector, MUTATOR_ARGV_0_vector) \ diff --git a/qcsrc/common/gamemodes/gamemode/cts/_mod.inc b/qcsrc/common/gamemodes/gamemode/cts/_mod.inc index 5978c8bac1..f60b8de4cf 100644 --- a/qcsrc/common/gamemodes/gamemode/cts/_mod.inc +++ b/qcsrc/common/gamemodes/gamemode/cts/_mod.inc @@ -1,5 +1,8 @@ // generated file; do not modify #include +#ifdef CSQC + #include +#endif #ifdef SVQC #include #endif diff --git a/qcsrc/common/gamemodes/gamemode/cts/_mod.qh b/qcsrc/common/gamemodes/gamemode/cts/_mod.qh index e062122407..5e9ba6326d 100644 --- a/qcsrc/common/gamemodes/gamemode/cts/_mod.qh +++ b/qcsrc/common/gamemodes/gamemode/cts/_mod.qh @@ -1,5 +1,8 @@ // generated file; do not modify #include +#ifdef CSQC + #include +#endif #ifdef SVQC #include #endif diff --git a/qcsrc/common/gamemodes/gamemode/cts/cl_cts.qc b/qcsrc/common/gamemodes/gamemode/cts/cl_cts.qc new file mode 100644 index 0000000000..ded220d9cc --- /dev/null +++ b/qcsrc/common/gamemodes/gamemode/cts/cl_cts.qc @@ -0,0 +1,8 @@ +#include "cl_cts.qh" + +REGISTER_MUTATOR(cl_cts, true); + +MUTATOR_HOOKFUNCTION(cl_cts, HUD_Physics_showoptional) +{ + return ISGAMETYPE(CTS); // show the optional physics panel +} diff --git a/qcsrc/common/gamemodes/gamemode/cts/cl_cts.qh b/qcsrc/common/gamemodes/gamemode/cts/cl_cts.qh new file mode 100644 index 0000000000..6f70f09bee --- /dev/null +++ b/qcsrc/common/gamemodes/gamemode/cts/cl_cts.qh @@ -0,0 +1 @@ +#pragma once diff --git a/qcsrc/common/gamemodes/gamemode/race/cl_race.qc b/qcsrc/common/gamemodes/gamemode/race/cl_race.qc index ee90914a3d..cb5e647b27 100644 --- a/qcsrc/common/gamemodes/gamemode/race/cl_race.qc +++ b/qcsrc/common/gamemodes/gamemode/race/cl_race.qc @@ -145,3 +145,10 @@ void HUD_Mod_Race(vector pos, vector mySize) strfree(race_status_name_prev); } } + +REGISTER_MUTATOR(cl_race, true); + +MUTATOR_HOOKFUNCTION(cl_race, HUD_Physics_showoptional) +{ + return ISGAMETYPE(RACE); // show the optional physics panel +} -- 2.39.2