From: terencehill Date: Tue, 6 Sep 2016 14:07:37 +0000 (+0200) Subject: Rankings panel: further reduce name column if displayed player names don't exceed... X-Git-Tag: xonotic-v0.8.2~600^2~5 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=0f170a89615b5e979834cdbd07ed66c9049b8d91;p=xonotic%2Fxonotic-data.pk3dir.git Rankings panel: further reduce name column if displayed player names don't exceed name size limit --- diff --git a/qcsrc/client/hud/panel/scoreboard.qc b/qcsrc/client/hud/panel/scoreboard.qc index 7fc4db065..500e73358 100644 --- a/qcsrc/client/hud/panel/scoreboard.qc +++ b/qcsrc/client/hud/panel/scoreboard.qc @@ -1307,9 +1307,22 @@ vector Scoreboard_Rankings_Draw(vector pos, entity pl, vector rgb, vector bg_siz panel_pos = pos; + float namesize = 0; + for(i = 0; i < RANKINGS_RECEIVED_CNT; ++i) + { + float f = stringwidth(grecordholder[i], true, hud_fontsize); + if(f > namesize) + namesize = f; + } + bool cut = false; + if(namesize > autocvar_hud_panel_scoreboard_namesize * hud_fontsize.x) + { + namesize = autocvar_hud_panel_scoreboard_namesize * hud_fontsize.x; + cut = true; + } + float ranksize = 3 * hud_fontsize.x; float timesize = 5.5 * hud_fontsize.x; - float namesize = autocvar_hud_panel_scoreboard_namesize * hud_fontsize.x; vector columnsize = eX * (ranksize + timesize + namesize) + eY * 1.25 * hud_fontsize.y; int columns = max(1, floor((panel_size.x - 2 * panel_bg_padding) / columnsize.x)); columns = min(columns, RANKINGS_RECEIVED_CNT); @@ -1356,7 +1369,9 @@ vector Scoreboard_Rankings_Draw(vector pos, entity pl, vector rgb, vector bg_siz str = count_ordinal(i+1); drawstring(pos, str, hud_fontsize, '1 1 1', sbt_fg_alpha, DRAWFLAG_NORMAL); drawstring(pos + eX * ranksize, TIME_ENCODED_TOSTRING(t), hud_fontsize, '1 1 1', sbt_fg_alpha, DRAWFLAG_NORMAL); - str = textShortenToWidth(grecordholder[i], namesize, hud_fontsize, stringwidth_colors); + str = grecordholder[i]; + if(cut) + str = textShortenToWidth(str, namesize, hud_fontsize, stringwidth_colors); drawcolorcodedstring(pos + eX * (ranksize + timesize), str, hud_fontsize, sbt_fg_alpha, DRAWFLAG_NORMAL); pos.y += 1.25 * hud_fontsize.y;