]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/scoreboard.qc
Merge branch 'master' into terencehill/quickmenu
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / scoreboard.qc
index 61594518717358841395d3618d877d55e8795ed4..59dd4b50d142f33ead56a8f7940be410cd7387d5 100644 (file)
@@ -7,6 +7,7 @@
 #include "../common/constants.qh"
 #include "../common/counting.qh"
 #include "../common/mapinfo.qh"
 #include "../common/constants.qh"
 #include "../common/counting.qh"
 #include "../common/mapinfo.qh"
+#include "../common/minigames/cl_minigames.qh"
 #include "../common/stats.qh"
 #include "../common/teams.qh"
 #include "../common/util.qh"
 #include "../common/stats.qh"
 #include "../common/teams.qh"
 #include "../common/util.qh"
@@ -302,7 +303,7 @@ void Cmd_HUD_Help()
 #define HUD_DefaultColumnLayout() \
 "ping pl name | " \
 "-teams,race,lms/kills +ft,tdm/kills -teams,lms/deaths +ft,tdm/deaths -teams,lms,race,ka/suicides +ft,tdm/suicides -race,dm,tdm,ka,ft/frags " /* tdm already has this in "score" */ \
 #define HUD_DefaultColumnLayout() \
 "ping pl name | " \
 "-teams,race,lms/kills +ft,tdm/kills -teams,lms/deaths +ft,tdm/deaths -teams,lms,race,ka/suicides +ft,tdm/suicides -race,dm,tdm,ka,ft/frags " /* tdm already has this in "score" */ \
-"+ctf/caps +ctf/pickups +ctf/fckills +ctf/returns " \
+"+ctf/caps +ctf/pickups +ctf/fckills +ctf/returns +ons/caps +ons/takes " \
 "+lms/lives +lms/rank " \
 "+kh/caps +kh/pushes +kh/destroyed " \
 "?+race/laps ?+race/time ?+race/fastest " \
 "+lms/lives +lms/rank " \
 "+kh/caps +kh/pushes +kh/destroyed " \
 "?+race/laps ?+race/time ?+race/fastest " \
@@ -360,7 +361,6 @@ void Cmd_HUD_SetFields(float argc)
 
        hud_fontsize = HUD_GetFontsize("hud_fontsize");
 
 
        hud_fontsize = HUD_GetFontsize("hud_fontsize");
 
-       draw_beginBoldFont();
        for(i = 1; i < argc - 1; ++i)
        {
                float nocomplain;
        for(i = 1; i < argc - 1; ++i)
        {
                float nocomplain;
@@ -499,7 +499,6 @@ void Cmd_HUD_SetFields(float argc)
        }
 
        hud_field[hud_num_fields] = SP_END;
        }
 
        hud_field[hud_num_fields] = SP_END;
-       draw_endBoldFont();
 }
 
 // MOVEUP::
 }
 
 // MOVEUP::
@@ -879,7 +878,6 @@ vector HUD_Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_siz
        }
 
        // print the strings of the columns headers and draw the columns
        }
 
        // print the strings of the columns headers and draw the columns
-       draw_beginBoldFont();
        int i;
        for(i = 0; i < hud_num_fields; ++i)
        {
        int i;
        for(i = 0; i < hud_num_fields; ++i)
        {
@@ -923,7 +921,6 @@ vector HUD_Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_siz
                        pos.x -= hud_fontsize.x;
                }
        }
                        pos.x -= hud_fontsize.x;
                }
        }
-       draw_endBoldFont();
 
        pos.x = xmin;
        pos.y += 1.25 * hud_fontsize.y; // skip the header
 
        pos.x = xmin;
        pos.y += 1.25 * hud_fontsize.y; // skip the header
@@ -966,13 +963,15 @@ float HUD_WouldDrawScoreboard() {
                return 0;
        else if (QuickMenu_IsOpened())
                return 0;
                return 0;
        else if (QuickMenu_IsOpened())
                return 0;
+       else if (HUD_Radar_Clickable())
+               return 0;
        else if (scoreboard_showscores)
                return 1;
        else if (intermission == 1)
                return 1;
        else if (intermission == 2)
                return 0;
        else if (scoreboard_showscores)
                return 1;
        else if (intermission == 1)
                return 1;
        else if (intermission == 2)
                return 0;
-       else if (spectatee_status != -1 && getstati(STAT_HEALTH) <= 0 && autocvar_cl_deathscoreboard && gametype != MAPINFO_TYPE_CTS)
+       else if (spectatee_status != -1 && getstati(STAT_HEALTH) <= 0 && autocvar_cl_deathscoreboard && gametype != MAPINFO_TYPE_CTS && !active_minigame)
                return 1;
        else if (scoreboard_showscores_force)
                return 1;
                return 1;
        else if (scoreboard_showscores_force)
                return 1;
@@ -982,18 +981,40 @@ float HUD_WouldDrawScoreboard() {
 float average_accuracy;
 vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
 {
 float average_accuracy;
 vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
 {
+       WepSet weapons_stat = WepSet_GetFromStat();
+       WepSet weapons_inmap = WepSet_GetFromStat_InMap();
+       float initial_posx = pos.x;
        int i;
        int i;
-       int weapon_cnt = WEP_COUNT - 3; // either vaporizer/vortex are hidden, no port-o-launch, no tuba
-       float rows;
-       if(autocvar_scoreboard_accuracy_doublerows)
+       float weapon_stats;
+       int disownedcnt = 0;
+       for(i = WEP_FIRST; i <= WEP_LAST; ++i)
+       {
+               self = get_weaponinfo(i);
+               if(!self.weapon)
+                       continue;
+
+               weapon_stats = weapon_accuracy[i-WEP_FIRST];
+
+               if(weapon_stats < 0 && !(weapons_stat & WepSet_FromWeapon(i) || weapons_inmap & WepSet_FromWeapon(i)))
+                       ++disownedcnt;
+       }
+
+       int weapon_cnt = WEP_COUNT - disownedcnt;
+
+       if(weapon_cnt <= 0)
+               return pos;
+
+       int rows;
+       if(autocvar_scoreboard_accuracy_doublerows && weapon_cnt >= floor(WEP_COUNT * 0.5))
                rows = 2;
        else
                rows = 1;
                rows = 2;
        else
                rows = 1;
+       int columnns = ceil(weapon_cnt / rows);
+
        float height = 40;
        float fontsize = height * 1/3;
        float weapon_height = height * 2/3;
        float height = 40;
        float fontsize = height * 1/3;
        float weapon_height = height * 2/3;
-       float weapon_width = sbwidth / weapon_cnt;
-       float g_instagib = 0;
+       float weapon_width = sbwidth / columnns / rows;
 
        drawstring(pos, sprintf(_("Accuracy stats (average %d%%)"), average_accuracy), hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
        pos.y += 1.25 * hud_fontsize.y + autocvar_scoreboard_border_thickness;
 
        drawstring(pos, sprintf(_("Accuracy stats (average %d%%)"), average_accuracy), hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
        pos.y += 1.25 * hud_fontsize.y + autocvar_scoreboard_border_thickness;
@@ -1008,7 +1029,7 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
        drawborderlines(autocvar_scoreboard_border_thickness, pos, tmp, '0 0 0', scoreboard_alpha_bg * 0.75, DRAWFLAG_NORMAL);
 
        // column highlighting
        drawborderlines(autocvar_scoreboard_border_thickness, pos, tmp, '0 0 0', scoreboard_alpha_bg * 0.75, DRAWFLAG_NORMAL);
 
        // column highlighting
-       for(i = 0; i < weapon_cnt/rows; ++i)
+       for(i = 0; i < columnns; ++i)
        {
                if(!(i % 2))
                        drawfill(pos + '1 0 0' * weapon_width * rows * i, '0 1 0' * height * rows + '1 0 0' * weapon_width * rows, '0 0 0', scoreboard_alpha_bg * 0.2, DRAWFLAG_NORMAL);
        {
                if(!(i % 2))
                        drawfill(pos + '1 0 0' * weapon_width * rows * i, '0 1 0' * height * rows + '1 0 0' * weapon_width * rows, '0 0 0', scoreboard_alpha_bg * 0.2, DRAWFLAG_NORMAL);
@@ -1021,29 +1042,29 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
        }
 
        average_accuracy = 0;
        }
 
        average_accuracy = 0;
-       float weapons_with_stats;
-       weapons_with_stats = 0;
+       int weapons_with_stats = 0;
        if(rows == 2)
                pos.x += weapon_width / 2;
 
        if(rows == 2)
                pos.x += weapon_width / 2;
 
-       if(switchweapon == WEP_VAPORIZER)
-               g_instagib = 1; // TODO: real detection for instagib?
-
-       float weapon_stats;
        if(autocvar_scoreboard_accuracy_nocolors)
                rgb = '1 1 1';
        else
                Accuracy_LoadColors();
 
        if(autocvar_scoreboard_accuracy_nocolors)
                rgb = '1 1 1';
        else
                Accuracy_LoadColors();
 
-       for(i = WEP_FIRST; i <= WEP_LAST; ++i)
+       float oldposx = pos.x;
+       vector tmpos = pos;
+
+       int column;
+       for(i = WEP_FIRST, column = 0; i <= WEP_LAST; ++i)
        {
                self = get_weaponinfo(i);
                if (!self.weapon)
                        continue;
        {
                self = get_weaponinfo(i);
                if (!self.weapon)
                        continue;
-               if ((i == WEP_VORTEX && g_instagib) || i == WEP_PORTO || (i == WEP_VAPORIZER && !g_instagib) || i == WEP_TUBA) // skip port-o-launch, vortex || vaporizer and tuba
-                       continue;
                weapon_stats = weapon_accuracy[i-WEP_FIRST];
 
                weapon_stats = weapon_accuracy[i-WEP_FIRST];
 
+               if(weapon_stats < 0 && !(weapons_stat & WepSet_FromWeapon(i) || weapons_inmap & WepSet_FromWeapon(i)))
+                       continue;
+
                float weapon_alpha;
                if(weapon_stats >= 0)
                        weapon_alpha = scoreboard_alpha_fg;
                float weapon_alpha;
                if(weapon_stats >= 0)
                        weapon_alpha = scoreboard_alpha_fg;
@@ -1051,7 +1072,7 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
                        weapon_alpha = 0.2 * scoreboard_alpha_fg;
 
                // weapon icon
                        weapon_alpha = 0.2 * scoreboard_alpha_fg;
 
                // weapon icon
-               drawpic_aspect_skin(pos, self.model2, '1 0 0' * weapon_width + '0 1 0' * weapon_height, '1 1 1', weapon_alpha, DRAWFLAG_NORMAL);
+               drawpic_aspect_skin(tmpos, self.model2, '1 0 0' * weapon_width + '0 1 0' * weapon_height, '1 1 1', weapon_alpha, DRAWFLAG_NORMAL);
                // the accuracy
                if(weapon_stats >= 0) {
                        weapons_with_stats += 1;
                // the accuracy
                if(weapon_stats >= 0) {
                        weapons_with_stats += 1;
@@ -1066,24 +1087,24 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size)
                        if(!autocvar_scoreboard_accuracy_nocolors)
                                rgb = Accuracy_GetColor(weapon_stats);
 
                        if(!autocvar_scoreboard_accuracy_nocolors)
                                rgb = Accuracy_GetColor(weapon_stats);
 
-                       drawstring(pos + '1 0 0' * padding + '0 1 0' * weapon_height, s, '1 1 0' * fontsize, rgb, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
+                       drawstring(tmpos + '1 0 0' * padding + '0 1 0' * weapon_height, s, '1 1 0' * fontsize, rgb, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
                }
                }
+               tmpos.x += weapon_width * rows;
                pos.x += weapon_width * rows;
                pos.x += weapon_width * rows;
-               if(rows == 2 && i == 6) {
-                       pos.x -= sbwidth;
+               if(rows == 2 && column == columnns - 1) {
+                       tmpos.x = oldposx;
+                       tmpos.y += height;
                        pos.y += height;
                }
                        pos.y += height;
                }
+               ++column;
        }
 
        if(weapons_with_stats)
                average_accuracy = floor((average_accuracy * 100 / weapons_with_stats) + 0.5);
 
        }
 
        if(weapons_with_stats)
                average_accuracy = floor((average_accuracy * 100 / weapons_with_stats) + 0.5);
 
-       if(rows == 2)
-               pos.x -= weapon_width / 2;
-       pos.x -= sbwidth;
        pos.y += height;
        pos.y += height;
-
-       pos.y +=  1.25 * hud_fontsize.y;
+       pos.y += 1.25 * hud_fontsize.y;
+       pos.x = initial_posx;
        return pos;
 }
 
        return pos;
 }