]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add a mutator hook to indicate whether rankings should be shown
authorMario <mario.mario@y7mail.com>
Mon, 13 Jul 2020 08:34:19 +0000 (18:34 +1000)
committerMario <mario.mario@y7mail.com>
Mon, 13 Jul 2020 08:34:19 +0000 (18:34 +1000)
qcsrc/client/hud/panel/scoreboard.qc
qcsrc/client/mutators/events.qh
qcsrc/common/gamemodes/gamemode/ctf/cl_ctf.qc
qcsrc/common/gamemodes/gamemode/cts/cl_cts.qc
qcsrc/common/gamemodes/gamemode/race/cl_race.qc

index 53476a6fe42779f57ed8934ea1c807815e2aece2..c863d11153fd43ba03a91011c5c0f3b59eff93f3 100644 (file)
@@ -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);
index 7ecf2798cccce95e034bd8630cd798e2d4ae500e..e8c374ee40e87e030c49f24623eb913f21aa966f 100644 (file)
@@ -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);
index cbbe9afb7efd5545b4967b16c96ce445df078d02..85f8e22ae66238441cfec0d6e24667f3b954082c 100644 (file)
@@ -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;
+    }
+}
index cb51c85beed2de76ed59f0dd49f065bfb3673f25..f85035d81d0e02928921eac008e072d411cf7e9c 100644 (file)
@@ -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;
+       }
+}
index 92d75dc4d6a7eef8ffc34c67585704680bc7adb8..820d7cc3fc93d1ac4d5acd519f0bb59faac2afa8 100644 (file)
@@ -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;
+       }
+}