]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/scoreboard.qc
Merge remote branch 'origin/fruitiex/fruitbalance'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / scoreboard.qc
index 36168ea2e772ce05fce447b024d1abcbcf8d815d..76b19a54c50c99a94d7942951edf430ab380d626 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)
        {
@@ -594,8 +595,8 @@ string HUD_FixScoreboardColumnWidth(float i, string str)
                for(j = 0; j < hud_num_fields; ++j)
                        if(j != i)
                                if (hud_field[i] != SP_SEPARATOR)
-                                       namesize -= hud_size[j] + 1;
-               namesize += 1;
+                                       namesize -= hud_size[j] + hud_fontsize_x;
+               namesize += hud_fontsize_x;
                hud_size[i] = namesize;
 
                if (hud_fixscoreboardcolumnwidth_iconlen != 0)
@@ -759,7 +760,10 @@ 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);
+       if (teamplay)
+               drawpic(pos, "gfx/scoreboard/scoreboard_tableheader", tmp, (rgb * autocvar_scoreboard_color_bg_team) + '0.5 0.5 0.5', scoreboard_alpha_bg, DRAWFLAG_NORMAL);
+       else
+               drawpic(pos, "gfx/scoreboard/scoreboard_tableheader", tmp, rgb + '0.5 0.5 0.5', scoreboard_alpha_bg, DRAWFLAG_NORMAL);
 
        // table border
        tmp_y += hud_border_thickness;
@@ -775,7 +779,10 @@ 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);
+       if (teamplay)
+               drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb * autocvar_scoreboard_color_bg_team, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
+       else
+               drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
 
        // anyway, apply some color
        //drawfill(pos, tmp + '2 0 0', rgb, 0.1, DRAWFLAG_NORMAL);
@@ -831,7 +838,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,11 +877,13 @@ 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;
-       else if (intermission == 2)
+       else if (intermission == 2 && scoreboard_showscores)
                return 1;
        else if (getstati(STAT_HEALTH) <= 0 && cvar("cl_deathscoreboard"))
                return 1;
@@ -890,7 +899,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;
@@ -904,12 +913,15 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
        }
 
        drawstring(pos, strcat("Accuracy stats (average ", ftos(average_accuracy), "%)"), hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
-       pos_y += 18;
+       pos_y += 1.25 * hud_fontsize_y;
        vector tmp;
        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);
+       if (teamplay)
+               drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb * autocvar_scoreboard_color_bg_team, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
+       else
+               drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb, 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 +952,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 +966,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 +978,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;
@@ -984,6 +1015,8 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
                pos_x -= sbwidth/weapon_cnt / 2;
        pos_x -= sbwidth;
        pos_y += height;
+
+       pos_y +=  1.25 * hud_fontsize_y;
        return pos;
 }
 
@@ -991,9 +1024,9 @@ vector HUD_DrawScoreboardRankings(vector pos, entity pl,  vector rgb, vector bg_
 {
        float i;
        RANKINGS_RECEIVED_CNT = 0;
-               for (i=RANKINGS_CNT-1; i>=0; --i)
-                       if (grecordtime[i])
-                               RANKINGS_RECEIVED_CNT = RANKINGS_RECEIVED_CNT + 1;
+       for (i=RANKINGS_CNT-1; i>=0; --i)
+               if (grecordtime[i])
+                       ++RANKINGS_RECEIVED_CNT;
 
        if (RANKINGS_RECEIVED_CNT == 0)
                return pos;
@@ -1001,9 +1034,9 @@ vector HUD_DrawScoreboardRankings(vector pos, entity pl,  vector rgb, vector bg_
        float is_spec;
        is_spec = (GetPlayerColor(pl.sv_entnum) == COLOR_SPECTATOR);
        vector hl_rgb;
-               hl_rgb_x = cvar("scoreboard_color_bg_r") + 0.5;
-               hl_rgb_y = cvar("scoreboard_color_bg_g") + 0.5;
-               hl_rgb_z = cvar("scoreboard_color_bg_b") + 0.5;
+       hl_rgb_x = cvar("scoreboard_color_bg_r") + 0.5;
+       hl_rgb_y = cvar("scoreboard_color_bg_g") + 0.5;
+       hl_rgb_z = cvar("scoreboard_color_bg_b") + 0.5;
 
        pos_y += hud_fontsize_y;
        drawstring(pos, strcat("Rankings"), hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
@@ -1012,7 +1045,10 @@ 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);
+       if (teamplay)
+               drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb * autocvar_scoreboard_color_bg_team, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
+       else
+               drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
        drawborderlines(hud_border_thickness, pos, tmp, '0 0 0', scoreboard_alpha_bg * 0.75, DRAWFLAG_NORMAL);
 
        // row highlighting
@@ -1032,13 +1068,12 @@ vector HUD_DrawScoreboardRankings(vector pos, entity pl,  vector rgb, vector bg_
                drawstring(pos, p, hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
                drawstring(pos + '3 0 0' * hud_fontsize_x, TIME_ENCODED_TOSTRING(t), hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
                drawcolorcodedstring(pos + '8 0 0' * hud_fontsize_x, n, hud_fontsize, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
-               pos += '0 1 0' * hud_fontsize_y;
+               pos_y += 1.25 * hud_fontsize_y;
        }
 
        return pos;
 }
 
-float scoreboard_fade_alpha;
 float hud_woulddrawscoreboard_prev;
 float hud_woulddrawscoreboard_change; // "time" at which HUD_WouldDrawScoreboard() changed
 void HUD_DrawScoreboard()
@@ -1080,13 +1115,11 @@ void HUD_DrawScoreboard()
        vector rgb, pos, tmp;
        entity pl, tm;
 
-       sbwidth = HUD_GetWidth(6.5 * hud_fontsize_y);
-
-       xmin = 0.5 * (vid_conwidth - sbwidth);
-       ymin = SCOREBOARD_OFFSET;
+       xmin = cvar("scoreboard_offset_left") * vid_conwidth;
+       ymin = cvar("con_notify") * cvar("con_notifysize");
 
-       xmax = vid_conwidth - xmin;
-       ymax = vid_conheight - 0.2*vid_conheight;
+       sbwidth = xmax = vid_conwidth - xmin - cvar("scoreboard_offset_right") * vid_conwidth;
+       ymax = vid_conheight - ymin;
 
        // Initializes position
        pos_x = xmin;
@@ -1095,10 +1128,12 @@ void HUD_DrawScoreboard()
 
        // Heading
        drawfont = hud_bigfont;
-       drawstringcenter('0 1 0' * ymin, "Scoreboard", '24 24 0', '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
+       drawstring(pos, "Scoreboard", '24 24 0', '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
+       
+       centerprint_start_x = vid_conwidth - 0.5 * (pos_x + stringwidth("Scoreboard", FALSE, '24 24 0'));
+       centerprint_start_y = pos_y;
 
-       pos_y += 24 + 4;
-       pos_y += hud_fontsize_y;
+       pos_y += 24;
 
        drawfont = hud_font;
 
@@ -1114,10 +1149,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 - '2 0 0' * hud_fontsize_x + '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 - '2 0 0' * hud_fontsize_x + '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);
                }
@@ -1155,23 +1190,24 @@ void HUD_DrawScoreboard()
                        pos = HUD_DrawScoreboardAccuracyStats(pos, rgb, bg_size);
        }
 
-       tmp = pos + '0 1.5 0' * hud_fontsize_y;
-       pos_y += 3 * hud_fontsize_y;
-
        // List spectators
        float specs;
        specs = 0;
+       tmp = pos;
        for(pl = players.sort_next; pl; pl = pl.sort_next)
        {
                if(pl.team != COLOR_SPECTATOR)
                        continue;
-               HUD_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1), specs);
                pos_y += 1.25 * hud_fontsize_y;
+               HUD_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1), specs);
                ++specs;
        }
 
        if(specs)
+       {
                drawstring(tmp, "Spectators", hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
+               pos_y += 1.25 * hud_fontsize_y;
+       }
 
        // Print info string
        string str;