]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/scoreboard.qc
Merge commit 'aa4c896acf8088d26fcbd5ff4e3f6e7a0acb0600' into terencehill/misc_bugfixes
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / scoreboard.qc
index 36168ea2e772ce05fce447b024d1abcbcf8d815d..29fb20642a90fbb514f7a1244c0d79b4541b1dcb 100644 (file)
@@ -297,6 +297,7 @@ void Cmd_HUD_SetFields(float argc)
        hud_num_fields = 0;
 
        drawfont = hud_font;
+       hud_fontsize = HUD_GetFontsize("hud_fontsize"); 
 
        for(i = 0; i < argc - 1; ++i)
        {
@@ -759,7 +760,7 @@ vector HUD_Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_siz
        tmp_y = 1.25 * hud_fontsize_y;
 
        // rounded header
-       drawpic(pos, "gfx/scoreboard/scoreboard_tableheader", tmp, (rgb * hud_color_bg_team) + '0.5 0.5 0.5', scoreboard_alpha_bg, DRAWFLAG_NORMAL);
+       drawpic(pos, "gfx/scoreboard/scoreboard_tableheader", tmp, (rgb * autocvar_hud_color_bg_team) + '0.5 0.5 0.5', scoreboard_alpha_bg, DRAWFLAG_NORMAL);
 
        // table border
        tmp_y += hud_border_thickness;
@@ -775,7 +776,7 @@ vector HUD_Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_siz
 
        // table background
        tmp_y = body_table_height;
-       drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb * hud_color_bg_team, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
+       drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb * autocvar_hud_color_bg_team, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
 
        // anyway, apply some color
        //drawfill(pos, tmp + '2 0 0', rgb, 0.1, DRAWFLAG_NORMAL);
@@ -831,7 +832,7 @@ vector HUD_Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_siz
                        }
 
                        tmp_x = stringwidth(hud_title[i], FALSE, hud_fontsize);
-                       tmp_x = (hud_size[i] - tmp_x) * hud_fontsize_x;
+                       tmp_x = (hud_size[i] - tmp_x);
                        drawstring(pos + tmp, hud_title[i], hud_fontsize, rgb * 1.5, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
                        pos_x -= hud_fontsize_x;
                }
@@ -870,7 +871,9 @@ vector HUD_Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_siz
 }
 
 float HUD_WouldDrawScoreboard() {
-       if (scoreboard_showscores)
+       if (autocvar__hud_configure)
+               return 0;
+       else if (scoreboard_showscores)
                return 1;
        else if (intermission == 1)
                return 1;
@@ -890,7 +893,7 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
        float i;
        float weapon_hit, weapon_damage, weapon_stats;
        float fontsize = 40 * 1/3;
-       float weapon_cnt = 12;
+       float weapon_cnt = WEP_COUNT - 3; // either minstanex/nex are hidden, no port-o-launch, no tuba
        float rows;
        if(cvar("scoreboard_accuracy_doublerows"))
                rows = 2;
@@ -909,7 +912,7 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
        tmp_x = sbwidth;
        tmp_y = height * rows;
 
-       drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb * hud_color_bg_team, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
+       drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb * autocvar_hud_color_bg_team, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
        drawborderlines(hud_accuracy_border_thickness, pos, tmp, '0 0 0', scoreboard_alpha_bg * 0.75, DRAWFLAG_NORMAL);
 
        // column highlighting
@@ -940,7 +943,7 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
                self = get_weaponinfo(i);
                if not(self.weapons)
                        continue;
-               if ((i == WEP_NEX && g_minstagib) || i == WEP_PORTO || (i == WEP_MINSTANEX && !g_minstagib) || i == WEP_TUBA || i == WEP_FIREBALL) // skip port-o-launch, nex || minstanex, tuba and fireball
+               if ((i == WEP_NEX && g_minstagib) || i == WEP_PORTO || (i == WEP_MINSTANEX && !g_minstagib) || i == WEP_TUBA) // skip port-o-launch, nex || minstanex and tuba
                        continue;
                weapon_hit = weapon_hits[i-WEP_FIRST];
                weapon_damage = weapon_fired[i-WEP_FIRST];
@@ -954,7 +957,7 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
                        weapon_alpha = 0.2 * scoreboard_alpha_fg;
 
                // weapon icon
-               drawpic(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/weapon", self.netname), '1 0 0' * sbwidth * (1/weapon_cnt) + '0 1 0' * height * (2/3), '1 1 1', weapon_alpha, DRAWFLAG_NORMAL);
+               drawpic_aspect_skin(pos, strcat("weapon", self.netname), '1 0 0' * sbwidth * (1/weapon_cnt) + '0 1 0' * height * (2/3), '1 1 1', weapon_alpha, DRAWFLAG_NORMAL);
                // the accuracy
                if(weapon_damage) {
                        weapons_with_stats += 1;
@@ -966,7 +969,26 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
                        float padding;
                        padding = ((sbwidth/weapon_cnt) - stringwidth(s, FALSE, '1 0 0' * fontsize)) / 2; // center the accuracy value
 
-                       rgb = HUD_AccuracyColor(weapon_stats);
+                       float weapon_hit, weapon_damage;
+                       weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
+                       if(weapon_damage)
+                       {
+                               weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
+                               weapon_stats = floor(100 * weapon_hit / weapon_damage);
+                       }
+
+                       // find the max level lower than weapon_stats
+                       float j;
+                       j = acc_levels-1;
+                       while ( j && weapon_stats < acc_lev[j] )
+                               --j;
+
+                       // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
+                       float factor;
+                       factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
+                       rgb = acc_color(j);
+                       rgb = rgb + factor * (acc_color(j+1) - rgb);
+
                        drawstring(pos + '1 0 0' * padding + '0 1 0' * height * (2/3), s, '1 1 0' * fontsize, rgb, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
                }
                pos_x += sbwidth/weapon_cnt * rows;
@@ -1012,7 +1034,7 @@ vector HUD_DrawScoreboardRankings(vector pos, entity pl,  vector rgb, vector bg_
        tmp_x = sbwidth;
        tmp_y = hud_fontsize_y * RANKINGS_RECEIVED_CNT;
 
-       drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb * hud_color_bg_team, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
+       drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb * autocvar_hud_color_bg_team, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
        drawborderlines(hud_border_thickness, pos, tmp, '0 0 0', scoreboard_alpha_bg * 0.75, DRAWFLAG_NORMAL);
 
        // row highlighting
@@ -1114,10 +1136,10 @@ void HUD_DrawScoreboard()
                                continue;
 
                        rgb = GetTeamRGB(tm.team);
-                       HUD_DrawXNum(pos - '9.5 0 0' * hud_fontsize_y + '0 1 0' * hud_fontsize_y, tm.(teamscores[ts_primary]), 6, 0, hud_fontsize_y * 1.5, rgb, 0, 1, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
+                       drawstring(pos - '9.5 0 0' * hud_fontsize_y + '0 1 0' * hud_fontsize_y, ftos(tm.(teamscores[ts_primary])), '1 1 0' * hud_fontsize_y * 1.5, rgb, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
 
                        if(ts_primary != ts_secondary)
-                               HUD_DrawXNum(pos - '7.5 0 0' * hud_fontsize_y + '0 2.5 0' * hud_fontsize_y, tm.(teamscores[ts_secondary]), 6, 0, hud_fontsize_y * 1, rgb, 0, 1, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
+                               drawstring(pos - '7.5 0 0' * hud_fontsize_y + '0 2.5 0' * hud_fontsize_y, ftos(tm.(teamscores[ts_secondary])), '1 1 0' * hud_fontsize_y * 1, rgb, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
 
                        pos = HUD_Scoreboard_MakeTable(pos, tm, rgb, bg_size);
                }