]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix Item Stats panel not respecting hud_fontsize; make item icons proportional to...
authorterencehill <piuntn@gmail.com>
Sat, 4 Sep 2021 12:52:30 +0000 (14:52 +0200)
committerterencehill <piuntn@gmail.com>
Sat, 4 Sep 2021 12:52:30 +0000 (14:52 +0200)
qcsrc/client/hud/panel/scoreboard.qc

index 938316bb1caa1421395a2f0d9b47f3d7babd7683..6dadc75ed0be8da95fe54346b700d4e28b36b79f 100644 (file)
@@ -1243,8 +1243,8 @@ vector Scoreboard_AccuracyStats_Draw(vector pos, vector rgb, vector bg_size)
                rows = 2;
        int columnns = ceil(weapon_cnt / rows);
 
-       float weapon_height = 29;
-       float height = hud_fontsize.y + weapon_height;
+       float weapon_height = hud_fontsize.y * 2.3;
+       float height = weapon_height + hud_fontsize.y;
 
        drawstring(pos + eX * panel_bg_padding, sprintf(_("Accuracy stats (average %d%%)"), average_accuracy), hud_fontsize, '1 1 1', panel_fg_alpha * scoreboard_acc_fade_alpha, DRAWFLAG_NORMAL);
        pos.y += 1.25 * hud_fontsize.y;
@@ -1403,9 +1403,8 @@ vector Scoreboard_ItemStats_Draw(vector pos, vector rgb, vector bg_size)
        int rows = (autocvar_hud_panel_scoreboard_itemstats_doublerows && n >= floor(REGISTRY_COUNT(Items) / 2)) ? 2 : 1;
        int columnns = max(6, ceil(n / rows));
 
-       float height = 40;
-       float fontsize = height * 1/3;
-       float item_height = height * 2/3;
+       float item_height = hud_fontsize.y * 2.3;
+       float height = item_height + hud_fontsize.y;
 
        drawstring(pos + eX * panel_bg_padding, _("Item stats"), hud_fontsize, '1 1 1', panel_fg_alpha * scoreboard_itemstats_fade_alpha, DRAWFLAG_NORMAL);
        pos.y += 1.25 * hud_fontsize.y;
@@ -1444,11 +1443,11 @@ vector Scoreboard_ItemStats_Draw(vector pos, vector rgb, vector bg_size)
                // column highlighting
                for (int i = 0; i < columnns; ++i)
                        if ((i % 2) == 0)
-                               drawfill(pos + '1 0 0' * item_width * rows * i, '0 1 0' * height * rows + '1 0 0' * item_width * rows, '0 0 0', sbt_highlight_alpha * scoreboard_itemstats_fade_alpha, DRAWFLAG_NORMAL);
+                               drawfill(pos + eX * item_width * rows * i, vec2(item_width * rows, height * rows), '0 0 0', sbt_highlight_alpha * scoreboard_itemstats_fade_alpha, DRAWFLAG_NORMAL);
 
                // row highlighting
                for (int i = 0; i < rows; ++i)
-                       drawfill(pos + '0 1 0' * item_height + '0 1 0' * height * i, '1 0 0' * panel_size.x + '0 1 0' * fontsize, rgb, sbt_highlight_alpha * scoreboard_itemstats_fade_alpha, DRAWFLAG_NORMAL);
+                       drawfill(pos + eY * (item_height + height * i), vec2(panel_size.x, hud_fontsize.y), rgb, sbt_highlight_alpha * scoreboard_itemstats_fade_alpha, DRAWFLAG_NORMAL);
        }
 
        if (rows == 2)
@@ -1462,10 +1461,10 @@ vector Scoreboard_ItemStats_Draw(vector pos, vector rgb, vector bg_size)
                int n = g_inventory.inv_items[it.m_id];
                //n = 1 + floor(i * 3 + 4.8) % 7; // debug: display a value for each item
                if (n <= 0) continue;
-               drawpic_aspect_skin(tmpos, it.m_icon, '1 0 0' * item_width + '0 1 0' * item_height, '1 1 1', panel_fg_alpha * scoreboard_itemstats_fade_alpha, DRAWFLAG_NORMAL);
+               drawpic_aspect_skin(tmpos, it.m_icon, eX * item_width + eY * item_height, '1 1 1', panel_fg_alpha * scoreboard_itemstats_fade_alpha, DRAWFLAG_NORMAL);
                string s = ftos(n);
-               float padding = (item_width - stringwidth(s, false, '1 0 0' * fontsize)) / 2; // center
-               drawstring(tmpos + '1 0 0' * padding + '0 1 0' * item_height, s, '1 1 0' * fontsize, '1 1 1', panel_fg_alpha * scoreboard_itemstats_fade_alpha, DRAWFLAG_NORMAL);
+               float padding = (item_width - stringwidth(s, false, hud_fontsize)) / 2;
+               drawstring(tmpos + vec2(padding, item_height), s, hud_fontsize, '1 1 1', panel_fg_alpha * scoreboard_itemstats_fade_alpha, DRAWFLAG_NORMAL);
                tmpos.x += item_width * rows;
                pos.x += item_width * rows;
                if (rows == 2 && column == columnns - 1) {