From 5be2c6f1762b829c880f607c6de65a79f9b525de Mon Sep 17 00:00:00 2001
From: Mario <mario.mario@y7mail.com>
Date: Mon, 13 Jul 2020 17:50:12 +1000
Subject: [PATCH] Add a mutator hook to hide the score HUD panel

---
 qcsrc/client/hud/panel/score.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/score.qc b/qcsrc/client/hud/panel/score.qc
index 70a47a812..32db0a29f 100644
--- a/qcsrc/client/hud/panel/score.qc
+++ b/qcsrc/client/hud/panel/score.qc
@@ -147,7 +147,7 @@ void HUD_Score()
 	if(!autocvar__hud_configure)
 	{
 		if(!autocvar_hud_panel_score) return;
-		if(spectatee_status == -1 && (ISGAMETYPE(RACE) || ISGAMETYPE(CTS))) return;
+		if(MUTATOR_CALLHOOK(HUD_Score_show)) return;
 	}
 
 	HUD_Panel_LoadCvars();
diff --git a/qcsrc/client/mutators/events.qh b/qcsrc/client/mutators/events.qh
index 7ddcb204a..cafd6075a 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 hide the score HUD panel */
+MUTATOR_HOOKABLE(HUD_Score_show, 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/cl_cts.qc b/qcsrc/common/gamemodes/gamemode/cts/cl_cts.qc
index ded220d9c..3f0c26fde 100644
--- a/qcsrc/common/gamemodes/gamemode/cts/cl_cts.qc
+++ b/qcsrc/common/gamemodes/gamemode/cts/cl_cts.qc
@@ -6,3 +6,8 @@ MUTATOR_HOOKFUNCTION(cl_cts, HUD_Physics_showoptional)
 {
 	return ISGAMETYPE(CTS); // show the optional physics panel
 }
+
+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 cb5e647b2..92d75dc4d 100644
--- a/qcsrc/common/gamemodes/gamemode/race/cl_race.qc
+++ b/qcsrc/common/gamemodes/gamemode/race/cl_race.qc
@@ -152,3 +152,8 @@ MUTATOR_HOOKFUNCTION(cl_race, HUD_Physics_showoptional)
 {
 	return ISGAMETYPE(RACE); // show the optional physics panel
 }
+
+MUTATOR_HOOKFUNCTION(cl_race, HUD_Score_show)
+{
+	return spectatee_status == -1 && ISGAMETYPE(RACE); // hide the score panel while observing
+}
-- 
2.39.5