From a67e2bc7f350df53c47ba8688adee1f2ce647f1b Mon Sep 17 00:00:00 2001 From: terencehill Date: Wed, 5 Oct 2022 16:09:28 +0200 Subject: [PATCH] Compact timelimit / leadlimit display code --- qcsrc/client/hud/panel/scoreboard.qc | 40 ++++++++-------------------- 1 file changed, 11 insertions(+), 29 deletions(-) diff --git a/qcsrc/client/hud/panel/scoreboard.qc b/qcsrc/client/hud/panel/scoreboard.qc index 727fc411b..f0661d6d7 100644 --- a/qcsrc/client/hud/panel/scoreboard.qc +++ b/qcsrc/client/hud/panel/scoreboard.qc @@ -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 -- 2.39.2