]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'AriosJentu/SpectatorsScoreboard' into 'master'
authorterencehill <piuntn@gmail.com>
Sun, 16 May 2021 09:58:17 +0000 (09:58 +0000)
committerterencehill <piuntn@gmail.com>
Sun, 16 May 2021 09:58:17 +0000 (09:58 +0000)
Add feature for moving spectators list in scoreboard

See merge request xonotic/xonotic-data.pk3dir!898

_hud_common.cfg
qcsrc/client/hud/panel/scoreboard.qc

index c622cca34ca126756b3753bb937e32160cbeaea0..7d697464a76097d608c1c316892cbd7e1cb0620b 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 1 "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 2f756e4ae190bbca581d0403001db6c9ac6d46cb..b70513f44b7ae127a9822ef2c125de7a19e22c8b 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 = 1;
 
 bool autocvar_hud_panel_scoreboard_accuracy = true;
 bool autocvar_hud_panel_scoreboard_accuracy_doublerows = false;
@@ -1735,6 +1737,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)
@@ -1808,7 +1837,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;
 
@@ -2018,11 +2047,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) {
@@ -2036,27 +2076,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);
        }