]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add CVar for moving 'Spectators' list over the scoreboard, based on hardcoded positions
authorAriosJentu <darthpoezd@gmail.com>
Mon, 26 Apr 2021 16:12:23 +0000 (02:12 +1000)
committerAriosJentu <darthpoezd@gmail.com>
Mon, 26 Apr 2021 16:12:23 +0000 (02:12 +1000)
_hud_common.cfg
qcsrc/client/hud/panel/scoreboard.qc

index a62837f5f8b4f0881871938eb9246a8aaa534eb8..179ce4c49a68dbb11400dfa52a02849f4efd99d4 100644 (file)
@@ -120,6 +120,7 @@ seta hud_panel_scoreboard_maxheight 0.6 "max height of the scoreboard; a few pla
 seta hud_panel_scoreboard_others_showscore 1 "show scores of players listed in the last row when the scoreboard reaches the max height"
 seta hud_panel_scoreboard_spectators_showping 1 "show ping of spectators"
 seta hud_panel_scoreboard_spectators_aligned 0 "align spectators in columns"
+seta hud_panel_scoreboard_spectators_position 2 "align spectators panel on scoreboard screen (0 = before accuracy and itemstats, 1 = before rankings, 2 = after rankings, 3 = after map stats)"
 seta hud_panel_scoreboard_minwidth 0.6 "minimum width of the scoreboard"
 seta hud_panel_scoreboard_team_size_position 0 "where to show the team size (0 = do not show, 1 = left of scoreboard, 2 = right of scoreboard), will move team scores to the other side if necessary"
 seta hud_panel_scoreboard_playerid 0 "show player id (server entity number) next to player's name"
index 9857960440fd79f7da6361eb7ccdd1822890cff9..a0da24e39225d62fd8affc8f59175bc4188ef446 100644 (file)
@@ -34,6 +34,7 @@ void Scoreboard_Draw_Export(int fh)
        HUD_Write_Cvar("hud_panel_scoreboard_bg_teams_color_team");
        HUD_Write_Cvar("hud_panel_scoreboard_accuracy_doublerows");
        HUD_Write_Cvar("hud_panel_scoreboard_accuracy_nocolors");
+       HUD_Write_Cvar("hud_panel_scoreboard_spectators_position");
 }
 
 const int MAX_SBT_FIELDS = MAX_SCORE;
@@ -80,6 +81,7 @@ float autocvar_hud_panel_scoreboard_table_highlight_alpha_eliminated = 0.6;
 float autocvar_hud_panel_scoreboard_bg_teams_color_team = 0;
 float autocvar_hud_panel_scoreboard_namesize = 15;
 float autocvar_hud_panel_scoreboard_team_size_position = 0;
+float autocvar_hud_panel_scoreboard_spectators_position = 2;
 
 bool autocvar_hud_panel_scoreboard_accuracy = true;
 bool autocvar_hud_panel_scoreboard_accuracy_doublerows = false;
@@ -1721,6 +1723,33 @@ bool Scoreboard_ItemStats_WouldDraw(float ypos)
        return true;
 }
 
+vector Scoreboard_Spectators_Draw(vector pos, entity tm, string str, vector hud_fontsize) {
+
+       entity pl;
+
+       for(pl = players.sort_next; pl; pl = pl.sort_next)
+       {
+               if(pl.team == NUM_SPECTATOR)
+               {
+                       for(tm = teams.sort_next; tm; tm = tm.sort_next)
+                               if(tm.team == NUM_SPECTATOR)
+                                       break;
+                       str = sprintf("%s (%d)", _("Spectators"), tm.team_size);
+                       draw_beginBoldFont();
+                       drawstring(pos, str, hud_fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+                       draw_endBoldFont();
+                       pos.y += 1.25 * hud_fontsize.y;
+
+                       pos = Scoreboard_DrawOthers(pos, '0 0 0', pl.team, NULL, pl, 0);
+                       pos.y += 1.25 * hud_fontsize.y;
+
+                       break;
+               }
+       }
+
+       return pos;
+}
+
 void Scoreboard_Draw()
 {
        if(!autocvar__hud_configure)
@@ -1794,7 +1823,7 @@ void Scoreboard_Draw()
 
        float initial_pos_y = panel_pos.y;
        vector pos = panel_pos;
-       entity pl, tm;
+       entity tm;
        string str;
        vector str_pos;
 
@@ -2004,11 +2033,22 @@ void Scoreboard_Draw()
                pos = Scoreboard_MakeTable(pos, tm, panel_bg_color, bg_size);
        }
 
+       // draw scoreboard spectators before accuracy and item stats
+       if (autocvar_hud_panel_scoreboard_spectators_position == 0) {
+               pos = Scoreboard_Spectators_Draw(pos, tm, str, hud_fontsize);
+       }
+
+       // draw accuracy and item stats 
        if (Scoreboard_AccuracyStats_WouldDraw(pos.y))
                pos = Scoreboard_AccuracyStats_Draw(pos, panel_bg_color, bg_size);
        if (Scoreboard_ItemStats_WouldDraw(pos.y))
                pos = Scoreboard_ItemStats_Draw(pos, panel_bg_color, bg_size);
 
+       // draw scoreboard spectators after accuracy and item stats and before rankings
+       if (autocvar_hud_panel_scoreboard_spectators_position == 1) {
+               pos = Scoreboard_Spectators_Draw(pos, tm, str, hud_fontsize);
+       }
+
        if(MUTATOR_CALLHOOK(ShowRankings)) {
                string ranktitle = M_ARGV(0, string);
                if(race_speedaward) {
@@ -2022,27 +2062,16 @@ void Scoreboard_Draw()
                pos = Scoreboard_Rankings_Draw(pos, ranktitle, playerslots[player_localnum], panel_bg_color, bg_size);
        }
 
-       pos = Scoreboard_MapStats_Draw(pos, panel_bg_color, bg_size);
-
-       // List spectators
-       for(pl = players.sort_next; pl; pl = pl.sort_next)
-       {
-               if(pl.team == NUM_SPECTATOR)
-               {
-                       for(tm = teams.sort_next; tm; tm = tm.sort_next)
-                               if(tm.team == NUM_SPECTATOR)
-                                       break;
-                       str = sprintf("%s (%d)", _("Spectators"), tm.team_size);
-                       draw_beginBoldFont();
-                       drawstring(pos, str, hud_fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
-                       draw_endBoldFont();
-                       pos.y += 1.25 * hud_fontsize.y;
+       // draw scoreboard spectators after rankings
+       if (autocvar_hud_panel_scoreboard_spectators_position == 2) {
+               pos = Scoreboard_Spectators_Draw(pos, tm, str, hud_fontsize);
+       }
 
-                       pos = Scoreboard_DrawOthers(pos, '0 0 0', pl.team, NULL, pl, 0);
-                       pos.y += 1.25 * hud_fontsize.y;
+       pos = Scoreboard_MapStats_Draw(pos, panel_bg_color, bg_size);
 
-                       break;
-               }
+       // draw scoreboard spectators after mapstats
+       if (autocvar_hud_panel_scoreboard_spectators_position == 3) {
+               pos = Scoreboard_Spectators_Draw(pos, tm, str, hud_fontsize);
        }