+void HUD_Score_Rankings(vector pos, vector mySize, entity me, float team_count)
+{
+ float score;
+ entity tm, pl;
+#define SCOREPANEL_MAX_ENTRIES 6
+#define SCOREPANEL_ASPECTRATIO 2
+ const float entries = bound(1, floor(SCOREPANEL_MAX_ENTRIES * mySize_y/mySize_x * SCOREPANEL_ASPECTRATIO), SCOREPANEL_MAX_ENTRIES);
+ const vector fontsize = '1 1 0' * (mySize_y/entries);
+
+ vector rgb, score_color;
+ rgb = '1 1 1';
+ score_color = '1 1 1';
+
+ const float name_size = mySize_x*0.75;
+ const float spacing_size = mySize_x*0.04;
+ const float highlight_alpha = 0.2;
+ float i, me_printed, first_pl;
+ string s;
+ i, first_pl = 0;
+ if (autocvar__hud_configure)
+ {
+ float players_per_team;
+ if (team_count)
+ {
+ // show team scores in the first line
+ float score_size = mySize_x / team_count;
+ players_per_team = max(2, ceil((entries - 1) / team_count));
+ for(i=0; i<team_count; ++i) {
+ if (i == floor((entries - 2) / players_per_team) || (entries == 1 && i == 0))
+ HUD_Panel_DrawHighlight(pos + eX * score_size * i, eX * score_size + eY * fontsize_y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
+ drawstring_aspect(pos + eX * score_size * i, ftos(175 - 23*i), eX * score_size + eY * fontsize_y, GetTeamRGB(ColorByTeam(i)) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
+ }
+ first_pl = 1;
+ pos_y += fontsize_y;
+ }
+ score = 10 + SCOREPANEL_MAX_ENTRIES * 3;
+ for (i=first_pl; i<entries; ++i)
+ {
+ //simulate my score is lower than all displayed players,
+ //so that I don't appear at all showing pure rankings.
+ //This is to better show the difference between the 2 ranking views
+ if (i == entries-1 && autocvar_hud_panel_score_rankings == 1)
+ {
+ rgb = '1 1 0';
+ drawfill(pos, eX * mySize_x + eY * fontsize_y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+ s = GetPlayerName(pl.sv_entnum);
+ score = 7;
+ }
+ else
+ {
+ s = sprintf(_("Player %d"), i + 1 - first_pl);
+ score -= 3;
+ }
+
+ if (team_count)
+ score_color = GetTeamRGB(ColorByTeam(floor((i - first_pl) / players_per_team))) * 0.8;
+ s = textShortenToWidth(s, name_size, fontsize, stringwidth_colors);
+ drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
+ drawstring(pos + eX * (name_size + spacing_size), ftos(score), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL);
+ pos_y += fontsize_y;
+ }
+ return;
+ }
+
+ if (!scoreboard_fade_alpha) // the scoreboard too calls HUD_UpdatePlayerTeams
+ HUD_UpdatePlayerTeams();
+ if (team_count)
+ {
+ // show team scores in the first line
+ float score_size = mySize_x / team_count;
+ for(tm = teams.sort_next; tm; tm = tm.sort_next) {
+ if(tm.team == COLOR_SPECTATOR)
+ continue;
+ if (tm.team == myteam)
+ drawfill(pos + eX * score_size * i, eX * score_size + eY * fontsize_y, '1 1 1', highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+ drawstring_aspect(pos + eX * score_size * i, ftos(tm.(teamscores[ts_primary])), eX * score_size + eY * fontsize_y, GetTeamRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
+ ++i;
+ }
+ first_pl = 1;
+ pos_y += fontsize_y;
+ tm = teams.sort_next;
+ }
+ i = first_pl;
+
+ do
+ for (pl = players.sort_next; pl && i<entries; pl = pl.sort_next)
+ {
+ if ((team_count && pl.team != tm.team) || pl.team == COLOR_SPECTATOR)
+ continue;
+
+ if (i == entries-1 && !me_printed && pl != me)
+ if (autocvar_hud_panel_score_rankings == 1 && spectatee_status != -1)
+ {
+ for (pl = me.sort_next; pl; pl = pl.sort_next)
+ if (pl.team != COLOR_SPECTATOR)
+ break;
+
+ if (pl)
+ rgb = '1 1 0'; //not last but not among the leading players: yellow
+ else
+ rgb = '1 0 0'; //last: red
+ pl = me;
+ }
+
+ if (pl == me)
+ {
+ if (i == first_pl)
+ rgb = '0 1 0'; //first: green
+ me_printed = 1;
+ drawfill(pos, eX * mySize_x + eY * fontsize_y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
+ }
+ if (team_count)
+ score_color = GetTeamRGB(pl.team) * 0.8;
+ s = textShortenToWidth(GetPlayerName(pl.sv_entnum), name_size, fontsize, stringwidth_colors);
+ drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, TRUE, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
+ drawstring(pos + eX * (name_size + spacing_size), ftos(pl.(scores[ps_primary])), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL);
+ pos_y += fontsize_y;
+ ++i;
+ }
+ while (i<entries && team_count && (tm = tm.sort_next) && (tm.team != COLOR_SPECTATOR || (tm = tm.sort_next)));
+}
+