From: Mario Date: Mon, 13 Jul 2020 08:34:19 +0000 (+1000) Subject: Add a mutator hook to indicate whether rankings should be shown X-Git-Tag: xonotic-v0.8.5~855^2~12 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=2a8059012ee0ca9b6c4c28f8213743b2bb4b2b6f;p=xonotic%2Fxonotic-data.pk3dir.git Add a mutator hook to indicate whether rankings should be shown --- diff --git a/qcsrc/client/hud/panel/scoreboard.qc b/qcsrc/client/hud/panel/scoreboard.qc index 53476a6fe..c863d1115 100644 --- a/qcsrc/client/hud/panel/scoreboard.qc +++ b/qcsrc/client/hud/panel/scoreboard.qc @@ -84,8 +84,6 @@ bool autocvar_hud_panel_scoreboard_accuracy_nocolors = false; float autocvar_hud_panel_scoreboard_accuracy_showdelay = 2; float autocvar_hud_panel_scoreboard_accuracy_showdelay_minpos = 0.75; -bool autocvar_hud_panel_scoreboard_ctf_leaderboard = true; - bool autocvar_hud_panel_scoreboard_dynamichud = false; float autocvar_hud_panel_scoreboard_maxheight = 0.6; @@ -1397,7 +1395,7 @@ vector Scoreboard_MapStats_Draw(vector pos, vector rgb, vector bg_size) { } -vector Scoreboard_Rankings_Draw(vector pos, entity pl, vector rgb, vector bg_size) +vector Scoreboard_Rankings_Draw(vector pos, string ranktitle, entity pl, vector rgb, vector bg_size) { int i; RANKINGS_RECEIVED_CNT = 0; @@ -1411,7 +1409,7 @@ vector Scoreboard_Rankings_Draw(vector pos, entity pl, vector rgb, vector bg_siz vector hl_rgb = rgb + '0.5 0.5 0.5'; pos.y += hud_fontsize.y; - drawstring(pos + eX * panel_bg_padding, ((ISGAMETYPE(CTF)) ? _("Capture time rankings") : _("Rankings")), hud_fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring(pos + eX * panel_bg_padding, ranktitle, hud_fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); pos.y += 1.25 * hud_fontsize.y; if(panel.current_panel_bg != "0") pos.y += panel_bg_border; @@ -1819,7 +1817,8 @@ void Scoreboard_Draw() if (Scoreboard_AccuracyStats_WouldDraw(pos.y)) pos = Scoreboard_AccuracyStats_Draw(pos, panel_bg_color, bg_size); - if(ISGAMETYPE(CTS) || ISGAMETYPE(RACE) || (autocvar_hud_panel_scoreboard_ctf_leaderboard && ISGAMETYPE(CTF) && STAT(CTF_SHOWLEADERBOARD))) { + if(MUTATOR_CALLHOOK(ShowRankings)) { + string ranktitle = M_ARGV(0, string); if(race_speedaward) { drawcolorcodedstring(pos, sprintf(_("Speed award: %d%s ^7(%s^7)"), race_speedaward, race_speedaward_unit, ColorTranslateRGB(race_speedaward_holder)), hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL); pos.y += 1.25 * hud_fontsize.y; @@ -1828,7 +1827,7 @@ void Scoreboard_Draw() drawcolorcodedstring(pos, sprintf(_("All-time fastest: %d%s ^7(%s^7)"), race_speedaward_alltimebest, race_speedaward_alltimebest_unit, ColorTranslateRGB(race_speedaward_alltimebest_holder)), hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL); pos.y += 1.25 * hud_fontsize.y; } - pos = Scoreboard_Rankings_Draw(pos, playerslots[player_localnum], panel_bg_color, bg_size); + pos = Scoreboard_Rankings_Draw(pos, ranktitle, playerslots[player_localnum], panel_bg_color, bg_size); } pos = Scoreboard_MapStats_Draw(pos, panel_bg_color, bg_size); diff --git a/qcsrc/client/mutators/events.qh b/qcsrc/client/mutators/events.qh index 7ecf2798c..e8c374ee4 100644 --- a/qcsrc/client/mutators/events.qh +++ b/qcsrc/client/mutators/events.qh @@ -208,3 +208,9 @@ MUTATOR_HOOKABLE(DamageInfo, EV_DamageInfo); /** Return true to not draw zoom reticle */ MUTATOR_HOOKABLE(DrawReticle, EV_NO_ARGS); + +/** Return true to show leaderboard rankings, needs title argument set */ +#define EV_ShowRankings(i, o) \ + /** rankings title */ o(string, MUTATOR_ARGV_0_string) \ + /**/ +MUTATOR_HOOKABLE(ShowRankings, EV_ShowRankings); diff --git a/qcsrc/common/gamemodes/gamemode/ctf/cl_ctf.qc b/qcsrc/common/gamemodes/gamemode/ctf/cl_ctf.qc index cbbe9afb7..85f8e22ae 100644 --- a/qcsrc/common/gamemodes/gamemode/ctf/cl_ctf.qc +++ b/qcsrc/common/gamemodes/gamemode/ctf/cl_ctf.qc @@ -187,3 +187,16 @@ void HUD_Mod_CTF(vector pos, vector mySize) X(neutral); #undef X } + +bool autocvar_hud_panel_scoreboard_ctf_leaderboard = true; + +REGISTER_MUTATOR(cl_ctf, true); + +MUTATOR_HOOKFUNCTION(cl_ctf, ShowRankings) +{ + if(autocvar_hud_panel_scoreboard_ctf_leaderboard && ISGAMETYPE(CTF) && STAT(CTF_SHOWLEADERBOARD)) + { + M_ARGV(0, string) = _("Capture time rankings"); + return true; + } +} diff --git a/qcsrc/common/gamemodes/gamemode/cts/cl_cts.qc b/qcsrc/common/gamemodes/gamemode/cts/cl_cts.qc index cb51c85be..f85035d81 100644 --- a/qcsrc/common/gamemodes/gamemode/cts/cl_cts.qc +++ b/qcsrc/common/gamemodes/gamemode/cts/cl_cts.qc @@ -16,3 +16,12 @@ MUTATOR_HOOKFUNCTION(cl_cts, DrawDeathScoreboard) { return ISGAMETYPE(CTS); // no scoreboard shown while dead } + +MUTATOR_HOOKFUNCTION(cl_cts, ShowRankings) +{ + if(ISGAMETYPE(CTS)) + { + M_ARGV(0, string) = _("Rankings"); + return true; + } +} diff --git a/qcsrc/common/gamemodes/gamemode/race/cl_race.qc b/qcsrc/common/gamemodes/gamemode/race/cl_race.qc index 92d75dc4d..820d7cc3f 100644 --- a/qcsrc/common/gamemodes/gamemode/race/cl_race.qc +++ b/qcsrc/common/gamemodes/gamemode/race/cl_race.qc @@ -157,3 +157,12 @@ MUTATOR_HOOKFUNCTION(cl_race, HUD_Score_show) { return spectatee_status == -1 && ISGAMETYPE(RACE); // hide the score panel while observing } + +MUTATOR_HOOKFUNCTION(cl_race, ShowRankings) +{ + if(ISGAMETYPE(RACE)) + { + M_ARGV(0, string) = _("Rankings"); + return true; + } +}