From 3058015aa0107d3c7b88d43495bfb6ad5e4138c5 Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Wed, 1 Apr 2020 12:24:41 +0200 Subject: [PATCH] Valve: Add cvar cl_centerscores, to center the scoreboard --- src/client/valve/scoreboard.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/client/valve/scoreboard.c b/src/client/valve/scoreboard.c index e1a90d23..90060363 100644 --- a/src/client/valve/scoreboard.c +++ b/src/client/valve/scoreboard.c @@ -17,6 +17,8 @@ #define SCORE_HEADER_C [255/255,156/255,0] #define SCORE_LINE_C [255/255,200/255,0] +var int autocvar_cl_centerscores = FALSE; + void Scores_Init(void) { @@ -28,7 +30,21 @@ void Scores_Draw(void) player pl; pl = (player)pSeat->ePlayer; - pos = video_mins + [(video_res[0] / 2) - 145, 30]; + + if (autocvar_cl_centerscores) { + int c = 10; + + /* calculate all valid entries */ + for (int i = -1; i > -32; i--) { + if (getplayerkeyvalue(i, "name")) { + break; + } + c += 10; + } + pos = video_mins + [(video_res[0] / 2) - 145, (video_res[1] / 2) - c]; + } else { + pos = video_mins + [(video_res[0] / 2) - 145, 30]; + } drawfill(pos, [290, 1], SCORE_LINE_C, 1.0f, DRAWFLAG_ADDITIVE);