]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Rankings panel: further reduce name column if displayed player names don't exceed...
authorterencehill <piuntn@gmail.com>
Tue, 6 Sep 2016 14:07:37 +0000 (16:07 +0200)
committerterencehill <piuntn@gmail.com>
Tue, 6 Sep 2016 14:07:37 +0000 (16:07 +0200)
qcsrc/client/hud/panel/scoreboard.qc

index 7fc4db065e92359da855d61369f1430783d0958f..500e73358b08965c02b50307693087735acb20be 100644 (file)
@@ -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;