3 void HUD_UpdatePlayerTeams();
4 void HUD_Score_Rankings(vector pos, vector mySize, entity me)
8 int SCOREPANEL_MAX_ENTRIES = 6;
9 float SCOREPANEL_ASPECTRATIO = 2;
10 int entries = bound(1, floor(SCOREPANEL_MAX_ENTRIES * mySize.y/mySize.x * SCOREPANEL_ASPECTRATIO), SCOREPANEL_MAX_ENTRIES);
11 vector fontsize = '1 1 0' * (mySize.y/entries);
13 vector rgb, score_color;
15 score_color = '1 1 1';
17 float name_size = mySize.x*0.75;
18 float spacing_size = mySize.x*0.04;
19 const float highlight_alpha = 0.2;
20 int i = 0, first_pl = 0;
21 bool me_printed = false;
23 if (autocvar__hud_configure)
25 float players_per_team = 0;
28 // show team scores in the first line
29 float score_size = mySize.x / team_count;
30 players_per_team = max(2, ceil((entries - 1) / team_count));
31 for(i=0; i<team_count; ++i) {
32 if (i == floor((entries - 2) / players_per_team) || (entries == 1 && i == 0))
33 HUD_Panel_DrawHighlight(pos + eX * score_size * i, eX * score_size + eY * fontsize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
34 drawstring_aspect(pos + eX * score_size * i, ftos(175 - 23*i), eX * score_size + eY * fontsize.y, Team_ColorRGB(ColorByTeam(i)) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
39 score = 10 + SCOREPANEL_MAX_ENTRIES * 3;
40 for (i=first_pl; i<entries; ++i)
42 //simulate my score is lower than all displayed players,
43 //so that I don't appear at all showing pure rankings.
44 //This is to better show the difference between the 2 ranking views
45 if (i == entries-1 && autocvar_hud_panel_score_rankings == 1)
48 drawfill(pos, eX * mySize.x + eY * fontsize.y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
49 s = GetPlayerName(player_localnum);
54 s = sprintf(_("Player %d"), i + 1 - first_pl);
59 score_color = Team_ColorRGB(ColorByTeam(floor((i - first_pl) / players_per_team))) * 0.8;
60 s = textShortenToWidth(s, name_size, fontsize, stringwidth_colors);
61 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, true, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
62 drawstring(pos + eX * (name_size + spacing_size), ftos(score), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL);
68 if (!scoreboard_fade_alpha) // the scoreboard too calls HUD_UpdatePlayerTeams
69 HUD_UpdatePlayerTeams();
72 // show team scores in the first line
73 float score_size = mySize.x / team_count;
74 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
75 if(tm.team == NUM_SPECTATOR)
77 if (tm.team == myteam)
78 drawfill(pos + eX * score_size * i, eX * score_size + eY * fontsize.y, '1 1 1', highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
79 drawstring_aspect(pos + eX * score_size * i, ftos(tm.(teamscores[ts_primary])), eX * score_size + eY * fontsize.y, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
89 for (pl = players.sort_next; pl && i<entries; pl = pl.sort_next)
91 if ((team_count && pl.team != tm.team) || pl.team == NUM_SPECTATOR)
94 if (i == entries-1 && !me_printed && pl != me)
95 if (autocvar_hud_panel_score_rankings == 1 && spectatee_status != -1)
97 for (pl = me.sort_next; pl; pl = pl.sort_next)
98 if (pl.team != NUM_SPECTATOR)
102 rgb = '1 1 0'; //not last but not among the leading players: yellow
104 rgb = '1 0 0'; //last: red
111 rgb = '0 1 0'; //first: green
113 drawfill(pos, eX * mySize.x + eY * fontsize.y, rgb, highlight_alpha * panel_fg_alpha, DRAWFLAG_NORMAL);
116 score_color = Team_ColorRGB(pl.team) * 0.8;
117 s = textShortenToWidth(GetPlayerName(pl.sv_entnum), name_size, fontsize, stringwidth_colors);
118 drawcolorcodedstring(pos + eX * (name_size - stringwidth(s, true, fontsize)), s, fontsize, panel_fg_alpha, DRAWFLAG_NORMAL);
119 drawstring(pos + eX * (name_size + spacing_size), ftos(pl.(scores[ps_primary])), fontsize, score_color, panel_fg_alpha, DRAWFLAG_NORMAL);
123 while (i<entries && team_count && (tm = tm.sort_next) && (tm.team != NUM_SPECTATOR || (tm = tm.sort_next)));
128 if(!autocvar__hud_configure)
130 if(!autocvar_hud_panel_score) return;
131 if(spectatee_status == -1 && (gametype == MAPINFO_TYPE_RACE || gametype == MAPINFO_TYPE_CTS)) return;
134 HUD_Panel_UpdateCvars();
142 pos += '1 1 0' * panel_bg_padding;
143 mySize -= '2 2 0' * panel_bg_padding;
146 float score, distribution = 0;
148 vector distribution_color;
151 me = playerslots[current_player];
153 if((scores_flags[ps_primary] & SFL_TIME) && !teamplay) { // race/cts record display on HUD
154 string timer, distrtimer;
156 pl = players.sort_next;
159 if(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)
160 if(pl.scores[ps_primary] == 0)
163 score = me.(scores[ps_primary]);
164 timer = TIME_ENCODED_TOSTRING(score);
166 draw_beginBoldFont();
167 if (pl && ((!(scores_flags[ps_primary] & SFL_ZERO_IS_WORST)) || score)) {
168 // distribution display
169 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
171 distrtimer = ftos_decimals(fabs(distribution/pow(10, TIME_DECIMALS)), TIME_DECIMALS);
173 if (distribution <= 0) {
174 distribution_color = '0 1 0';
178 distribution_color = '1 0 0';
181 drawstring_aspect(pos + eX * 0.75 * mySize.x, strcat(sign, distrtimer), eX * 0.25 * mySize.x + eY * (1/3) * mySize.y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
183 // race record display
184 if (distribution <= 0)
185 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
186 drawstring_aspect(pos, timer, eX * 0.75 * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
188 } else if (!teamplay) { // non-teamgames
189 if ((spectatee_status == -1 && !autocvar__hud_configure) || autocvar_hud_panel_score_rankings)
191 HUD_Score_Rankings(pos, mySize, me);
194 // me vector := [team/connected frags id]
195 pl = players.sort_next;
199 if(autocvar__hud_configure)
202 distribution = me.(scores[ps_primary]) - pl.(scores[ps_primary]);
206 score = me.(scores[ps_primary]);
207 if(autocvar__hud_configure)
210 if(distribution >= 5)
211 distribution_color = eY;
212 else if(distribution >= 0)
213 distribution_color = '1 1 1';
214 else if(distribution >= -5)
215 distribution_color = '1 1 0';
217 distribution_color = eX;
219 string distribution_str;
220 distribution_str = ftos(distribution);
221 draw_beginBoldFont();
222 if (distribution >= 0)
224 if (distribution > 0)
225 distribution_str = strcat("+", distribution_str);
226 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
228 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize.x + eY * mySize.y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
229 drawstring_aspect(pos + eX * 0.75 * mySize.x, distribution_str, eX * 0.25 * mySize.x + eY * (1/3) * mySize.y, distribution_color, panel_fg_alpha, DRAWFLAG_NORMAL);
231 } else { // teamgames
232 float row, column, rows = 0, columns = 0;
233 vector offset = '0 0 0';
234 vector score_pos, score_size; //for scores other than myteam
235 if(autocvar_hud_panel_score_rankings)
237 HUD_Score_Rankings(pos, mySize, me);
240 if(spectatee_status == -1)
242 rows = HUD_GetRowCount(team_count, mySize, 3);
243 columns = ceil(team_count/rows);
244 score_size = eX * mySize.x*(1/columns) + eY * mySize.y*(1/rows);
247 if(score_size.x/score_size.y > 3)
249 newSize = 3 * score_size.y;
250 offset.x = score_size.x - newSize;
252 score_size.x = newSize;
256 newSize = 1/3 * score_size.x;
257 offset.y = score_size.y - newSize;
259 score_size.y = newSize;
263 score_size = eX * mySize.x*(1/4) + eY * mySize.y*(1/3);
267 draw_beginBoldFont();
269 for(tm = teams.sort_next; tm; tm = tm.sort_next) {
270 if(tm.team == NUM_SPECTATOR)
272 score = tm.(teamscores[ts_primary]);
273 if(autocvar__hud_configure)
276 if (score > max_fragcount)
277 max_fragcount = score;
279 if (spectatee_status == -1)
281 score_pos = pos + eX * column * (score_size.x + offset.x) + eY * row * (score_size.y + offset.y);
282 if (max_fragcount == score)
283 HUD_Panel_DrawHighlight(score_pos, score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
284 drawstring_aspect(score_pos, ftos(score), score_size, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
292 else if(tm.team == myteam) {
293 if (max_fragcount == score)
294 HUD_Panel_DrawHighlight(pos, eX * 0.75 * mySize.x + eY * mySize.y, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
295 drawstring_aspect(pos, ftos(score), eX * 0.75 * mySize.x + eY * mySize.y, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);
297 if (max_fragcount == score)
298 HUD_Panel_DrawHighlight(pos + eX * 0.75 * mySize.x + eY * (1/3) * rows * mySize.y, score_size, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL);
299 drawstring_aspect(pos + eX * 0.75 * mySize.x + eY * (1/3) * rows * mySize.y, ftos(score), score_size, Team_ColorRGB(tm.team) * 0.8, panel_fg_alpha, DRAWFLAG_NORMAL);