]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Compact timelimit / leadlimit display code
authorterencehill <piuntn@gmail.com>
Wed, 5 Oct 2022 14:09:28 +0000 (16:09 +0200)
committerterencehill <piuntn@gmail.com>
Wed, 5 Oct 2022 14:09:28 +0000 (16:09 +0200)
qcsrc/client/hud/panel/scoreboard.qc

index 727fc411be32e111647544076b574e410d2baf2b..f0661d6d7581856d6b3fdd9fde5383a88fc5bf8f 100644 (file)
@@ -2166,6 +2166,15 @@ vector Scoreboard_Spectators_Draw(vector pos) {
        return pos;
 }
 
+string Scoreboard_Fraglimit_Draw(float limit, bool is_leadlimit)
+{
+       string s_label = (teamplay) ? teamscores_label(ts_primary) : scores_label(ps_primary);
+       int s_flags = (teamplay) ? teamscores_flags(ts_primary) : scores_flags(ps_primary);
+       return sprintf((is_leadlimit ? _("^2+%s %s") : _("^5%s %s")), ScoreString(s_flags, limit),
+               (s_label == "score") ? CTX(_("SCO^points")) :
+               (s_label == "fastest") ? "" : TranslateScoresLabel(s_label));
+}
+
 void Scoreboard_Draw()
 {
        if(!autocvar__hud_configure)
@@ -2289,20 +2298,7 @@ void Scoreboard_Draw()
                        {
                                if(tl > 0)
                                        str = strcat(str, "^7 / "); // delimiter
-                               if(teamplay)
-                               {
-                                       str = strcat(str, sprintf(_("^5%s %s"), ScoreString(teamscores_flags(ts_primary), fl),
-                                               (teamscores_label(ts_primary) == "score")   ? CTX(_("SCO^points")) :
-                                               (teamscores_label(ts_primary) == "fastest") ? "" :
-                                               TranslateScoresLabel(teamscores_label(ts_primary))));
-                               }
-                               else
-                               {
-                                       str = strcat(str, sprintf(_("^5%s %s"), ScoreString(scores_flags(ps_primary), fl),
-                                               (scores_label(ps_primary) == "score")   ? CTX(_("SCO^points")) :
-                                               (scores_label(ps_primary) == "fastest") ? "" :
-                                               TranslateScoresLabel(scores_label(ps_primary))));
-                               }
+                               str = strcat(str, Scoreboard_Fraglimit_Draw(fl, false));
                        }
                        if(ll > 0)
                        {
@@ -2314,21 +2310,7 @@ void Scoreboard_Draw()
                                        else
                                                str = strcat(str, "^7 / ");
                                }
-
-                               if(teamplay)
-                               {
-                                       str = strcat(str, sprintf(_("^2+%s %s"), ScoreString(teamscores_flags(ts_primary), ll),
-                                               (teamscores_label(ts_primary) == "score")   ? CTX(_("SCO^points")) :
-                                               (teamscores_label(ts_primary) == "fastest") ? "" :
-                                               TranslateScoresLabel(teamscores_label(ts_primary))));
-                               }
-                               else
-                               {
-                                       str = strcat(str, sprintf(_("^2+%s %s"), ScoreString(scores_flags(ps_primary), ll),
-                                               (scores_label(ps_primary) == "score")   ? CTX(_("SCO^points")) :
-                                               (scores_label(ps_primary) == "fastest") ? "" :
-                                               TranslateScoresLabel(scores_label(ps_primary))));
-                               }
+                               str = strcat(str, Scoreboard_Fraglimit_Draw(ll, true));
                        }
                }
                drawcolorcodedstring(pos + '1 0 0' * (panel_size.x - stringwidth(str, true, sb_gameinfo_detail_fontsize)), str, sb_gameinfo_detail_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL); // align right