hud_num_fields = 0;
drawfont = hud_font;
+ hud_fontsize = HUD_GetFontsize("hud_fontsize");
for(i = 0; i < argc - 1; ++i)
{
for(j = 0; j < hud_num_fields; ++j)
if(j != i)
if (hud_field[i] != SP_SEPARATOR)
- namesize -= hud_size[j] + 1;
- namesize += 1;
+ namesize -= hud_size[j] + hud_fontsize_x;
+ namesize += hud_fontsize_x;
hud_size[i] = namesize;
if (hud_fixscoreboardcolumnwidth_iconlen != 0)
tmp_y = 1.25 * hud_fontsize_y;
// rounded header
- drawpic(pos, "gfx/scoreboard/scoreboard_tableheader", tmp, (rgb * hud_color_bg_team) + '0.5 0.5 0.5', scoreboard_alpha_bg, DRAWFLAG_NORMAL);
+ if (teamplay)
+ drawpic(pos, "gfx/scoreboard/scoreboard_tableheader", tmp, (rgb * autocvar_scoreboard_color_bg_team) + '0.5 0.5 0.5', scoreboard_alpha_bg, DRAWFLAG_NORMAL);
+ else
+ drawpic(pos, "gfx/scoreboard/scoreboard_tableheader", tmp, rgb + '0.5 0.5 0.5', scoreboard_alpha_bg, DRAWFLAG_NORMAL);
// table border
- tmp_y += hud_border_thickness;
+ tmp_y += autocvar_scoreboard_border_thickness;
tmp_y += body_table_height;
- drawborderlines(hud_border_thickness, pos, tmp, '0 0 0', scoreboard_alpha_bg, DRAWFLAG_NORMAL); // more transparency for the scoreboard
+ drawborderlines(autocvar_scoreboard_border_thickness, pos, tmp, '0 0 0', scoreboard_alpha_bg, DRAWFLAG_NORMAL); // more transparency for the scoreboard
// separator header/table
pos_y += 1.25 * hud_fontsize_y;
- tmp_y = hud_border_thickness;
+ tmp_y = autocvar_scoreboard_border_thickness;
drawfill(pos, tmp, '0 0 0', scoreboard_alpha_bg, DRAWFLAG_NORMAL);
- pos_y += hud_border_thickness;
+ pos_y += autocvar_scoreboard_border_thickness;
// table background
tmp_y = body_table_height;
- drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb * hud_color_bg_team, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
+ if (teamplay)
+ drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb * autocvar_scoreboard_color_bg_team, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
+ else
+ drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
// anyway, apply some color
//drawfill(pos, tmp + '2 0 0', rgb, 0.1, DRAWFLAG_NORMAL);
// go back to the top to make alternated columns highlighting and to print the strings
pos_y -= 1.25 * hud_fontsize_y;
- pos_y -= hud_border_thickness;
+ pos_y -= autocvar_scoreboard_border_thickness;
pos += '1 1 0';
if (scoreboard_highlight)
{
column_dim_y = 1.25 * hud_fontsize_y; // header
- column_dim_y += hud_border_thickness;
+ column_dim_y += autocvar_scoreboard_border_thickness;
column_dim_y += body_table_height;
}
}
tmp_x = stringwidth(hud_title[i], FALSE, hud_fontsize);
- tmp_x = (hud_size[i] - tmp_x) * hud_fontsize_x;
+ tmp_x = (hud_size[i] - tmp_x);
drawstring(pos + tmp, hud_title[i], hud_fontsize, rgb * 1.5, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
pos_x -= hud_fontsize_x;
}
pos_x = xmin;
pos_y += 1.25 * hud_fontsize_y; // skip the header
- pos_y += hud_border_thickness;
+ pos_y += autocvar_scoreboard_border_thickness;
// fill the table and draw the rows
i = 0;
}
float HUD_WouldDrawScoreboard() {
- if (hud_configure)
+ if (autocvar__hud_configure)
return 0;
else if (scoreboard_showscores)
return 1;
else if (intermission == 1)
return 1;
- else if (intermission == 2)
- return 1;
else if (getstati(STAT_HEALTH) <= 0 && cvar("cl_deathscoreboard"))
return 1;
- else if(scoreboard_showscores_force)
+ else if (scoreboard_showscores_force)
return 1;
return 0;
}
{
float i;
float weapon_hit, weapon_damage, weapon_stats;
- float fontsize = 40 * 1/3;
- float weapon_cnt = 12;
+ float weapon_cnt = WEP_COUNT - 3; // either minstanex/nex are hidden, no port-o-launch, no tuba
float rows;
if(cvar("scoreboard_accuracy_doublerows"))
rows = 2;
else
rows = 1;
float height = 40;
-
- if(warmup_stage)
- {
- return pos;
- }
+ float fontsize = height * 1/3;
+ float weapon_height = height * 2/3;
+ float weapon_width = sbwidth / weapon_cnt;
drawstring(pos, strcat("Accuracy stats (average ", ftos(average_accuracy), "%)"), hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
- pos_y += 18;
+ pos_y += 1.25 * hud_fontsize_y;
vector tmp;
tmp_x = sbwidth;
tmp_y = height * rows;
- drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb * hud_color_bg_team, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
- drawborderlines(hud_accuracy_border_thickness, pos, tmp, '0 0 0', scoreboard_alpha_bg * 0.75, DRAWFLAG_NORMAL);
+ if (teamplay)
+ drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb * autocvar_scoreboard_color_bg_team, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
+ else
+ drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
+ 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)
{
if(!mod(i, 2))
- drawfill(pos + '1 0 0' * (sbwidth/weapon_cnt) * rows * i, '0 1 0' * height * rows + '1 0 0' * (sbwidth/weapon_cnt) * rows, '0 0 0', scoreboard_alpha_bg * 0.2, DRAWFLAG_NORMAL);
+ 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);
}
// row highlighting
for(i = 0; i < rows; ++i)
{
- drawfill(pos + '0 1 0' * height * (2/3) + '0 1 0' * height * i, '1 0 0' * sbwidth + '0 1 0' * fontsize, '1 1 1', scoreboard_highlight_alpha, DRAWFLAG_NORMAL);
+ drawfill(pos + '0 1 0' * weapon_height + '0 1 0' * height * i, '1 0 0' * sbwidth + '0 1 0' * fontsize, '1 1 1', scoreboard_highlight_alpha, DRAWFLAG_NORMAL);
}
drawfont = hud_bigfont;
float weapons_with_stats;
weapons_with_stats = 0;
if(rows == 2)
- pos_x += sbwidth/weapon_cnt / 2;
+ pos_x += weapon_width / 2;
if(getstati(STAT_SWITCHWEAPON) == WEP_MINSTANEX)
g_minstagib = 1; // TODO: real detection for minstagib?
+ if (!acc_levels)
+ rgb = '1 1 1';
+
for(i = WEP_FIRST; i <= WEP_LAST; ++i)
{
self = get_weaponinfo(i);
if not(self.weapons)
continue;
- if ((i == WEP_NEX && g_minstagib) || i == WEP_PORTO || (i == WEP_MINSTANEX && !g_minstagib) || i == WEP_TUBA || i == WEP_FIREBALL) // skip port-o-launch, nex || minstanex, tuba and fireball
+ if ((i == WEP_NEX && g_minstagib) || i == WEP_PORTO || (i == WEP_MINSTANEX && !g_minstagib) || i == WEP_TUBA) // skip port-o-launch, nex || minstanex and tuba
continue;
weapon_hit = weapon_hits[i-WEP_FIRST];
weapon_damage = weapon_fired[i-WEP_FIRST];
weapon_alpha = 0.2 * scoreboard_alpha_fg;
// weapon icon
- drawpic(pos, strcat("gfx/hud/", cvar_string("hud_skin"), "/weapon", self.netname), '1 0 0' * sbwidth * (1/weapon_cnt) + '0 1 0' * height * (2/3), '1 1 1', weapon_alpha, DRAWFLAG_NORMAL);
+ drawpic_aspect_skin(pos, strcat("weapon", self.netname), '1 0 0' * weapon_width + '0 1 0' * weapon_height, '1 1 1', weapon_alpha, DRAWFLAG_NORMAL);
// the accuracy
if(weapon_damage) {
weapons_with_stats += 1;
s = strcat(ftos(weapon_stats),"%");
float padding;
- padding = ((sbwidth/weapon_cnt) - stringwidth(s, FALSE, '1 0 0' * fontsize)) / 2; // center the accuracy value
+ padding = (weapon_width - stringwidth(s, FALSE, '1 0 0' * fontsize)) / 2; // center the accuracy value
- rgb = HUD_AccuracyColor(weapon_stats);
- drawstring(pos + '1 0 0' * padding + '0 1 0' * height * (2/3), s, '1 1 0' * fontsize, rgb, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
+ weapon_damage = weapon_fired[self.weapon-WEP_FIRST];
+ if(weapon_damage)
+ {
+ weapon_hit = weapon_hits[self.weapon-WEP_FIRST];
+ weapon_stats = floor(100 * weapon_hit / weapon_damage);
+ }
+
+ if (acc_levels)
+ {
+ // find the max level lower than weapon_stats
+ float j;
+ j = acc_levels-1;
+ while ( j && weapon_stats < acc_lev[j] )
+ --j;
+
+ // inject color j+1 in color j, how much depending on how much weapon_stats is higher than level j
+ float factor;
+ factor = (weapon_stats - acc_lev[j]) / (acc_lev[j+1] - acc_lev[j]);
+ rgb = acc_color(j);
+ rgb = rgb + factor * (acc_color(j+1) - rgb);
+ }
+
+ drawstring(pos + '1 0 0' * padding + '0 1 0' * weapon_height, s, '1 1 0' * fontsize, rgb, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
}
- pos_x += sbwidth/weapon_cnt * rows;
+ pos_x += weapon_width * rows;
if(rows == 2 && i == 6) {
pos_x -= sbwidth;
pos_y += height;
average_accuracy = floor(average_accuracy / weapons_with_stats);
if(rows == 2)
- pos_x -= sbwidth/weapon_cnt / 2;
+ pos_x -= weapon_width / 2;
pos_x -= sbwidth;
pos_y += height;
+
+ pos_y += 1.25 * hud_fontsize_y;
return pos;
}
{
float i;
RANKINGS_RECEIVED_CNT = 0;
- for (i=RANKINGS_CNT-1; i>=0; --i)
- if (grecordtime[i])
- RANKINGS_RECEIVED_CNT = RANKINGS_RECEIVED_CNT + 1;
+ for (i=RANKINGS_CNT-1; i>=0; --i)
+ if (grecordtime[i])
+ ++RANKINGS_RECEIVED_CNT;
if (RANKINGS_RECEIVED_CNT == 0)
return pos;
float is_spec;
is_spec = (GetPlayerColor(pl.sv_entnum) == COLOR_SPECTATOR);
vector hl_rgb;
- hl_rgb_x = cvar("scoreboard_color_bg_r") + 0.5;
- hl_rgb_y = cvar("scoreboard_color_bg_g") + 0.5;
- hl_rgb_z = cvar("scoreboard_color_bg_b") + 0.5;
+ hl_rgb_x = cvar("scoreboard_color_bg_r") + 0.5;
+ hl_rgb_y = cvar("scoreboard_color_bg_g") + 0.5;
+ hl_rgb_z = cvar("scoreboard_color_bg_b") + 0.5;
pos_y += hud_fontsize_y;
drawstring(pos, strcat("Rankings"), hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
tmp_x = sbwidth;
tmp_y = hud_fontsize_y * RANKINGS_RECEIVED_CNT;
- drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb * hud_color_bg_team, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
- drawborderlines(hud_border_thickness, pos, tmp, '0 0 0', scoreboard_alpha_bg * 0.75, DRAWFLAG_NORMAL);
+ if (teamplay)
+ drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb * autocvar_scoreboard_color_bg_team, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
+ else
+ drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
+ drawborderlines(autocvar_scoreboard_border_thickness, pos, tmp, '0 0 0', scoreboard_alpha_bg * 0.75, DRAWFLAG_NORMAL);
// row highlighting
for(i = 0; i<RANKINGS_RECEIVED_CNT; ++i)
drawstring(pos, p, hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
drawstring(pos + '3 0 0' * hud_fontsize_x, TIME_ENCODED_TOSTRING(t), hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
drawcolorcodedstring(pos + '8 0 0' * hud_fontsize_x, n, hud_fontsize, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
- pos += '0 1 0' * hud_fontsize_y;
+ pos_y += 1.25 * hud_fontsize_y;
}
return pos;
}
-float scoreboard_fade_alpha;
float hud_woulddrawscoreboard_prev;
float hud_woulddrawscoreboard_change; // "time" at which HUD_WouldDrawScoreboard() changed
void HUD_DrawScoreboard()
{
- HUD_UpdatePlayerTeams();
-
float hud_woulddrawscoreboard;
- hud_woulddrawscoreboard = HUD_WouldDrawScoreboard();
+ hud_woulddrawscoreboard = scoreboard_active;
if(hud_woulddrawscoreboard != hud_woulddrawscoreboard_prev) {
hud_woulddrawscoreboard_change = time;
hud_woulddrawscoreboard_prev = hud_woulddrawscoreboard;
}
- float scoreboard_fadeinspeed = cvar_or("scoreboard_fadeinspeed", 10);
- float scoreboard_fadeoutspeed = cvar_or("scoreboard_fadeoutspeed", 5);
if(hud_woulddrawscoreboard) {
+ float scoreboard_fadeinspeed = cvar_or("scoreboard_fadeinspeed", 10);
if (scoreboard_fadeinspeed)
scoreboard_fade_alpha = bound (0, (time - hud_woulddrawscoreboard_change) * scoreboard_fadeinspeed, 1);
else
scoreboard_fade_alpha = 1;
}
- else
+ else {
+ float scoreboard_fadeoutspeed = cvar_or("scoreboard_fadeoutspeed", 5);
if (scoreboard_fadeoutspeed)
scoreboard_fade_alpha = bound (0, (1/scoreboard_fadeoutspeed - (time - hud_woulddrawscoreboard_change)) * scoreboard_fadeoutspeed, 1);
else
scoreboard_fade_alpha = 0;
+ }
if not(scoreboard_fade_alpha)
return;
+ HUD_UpdatePlayerTeams();
+
scoreboard_alpha_bg = cvar("scoreboard_alpha_bg") * scoreboard_fade_alpha * (1 - cvar("_menu_alpha"));
scoreboard_alpha_fg = cvar_or("scoreboard_alpha_fg", 1.0) * scoreboard_fade_alpha * (1 - cvar("_menu_alpha"));
scoreboard_highlight = cvar("scoreboard_highlight");
vector rgb, pos, tmp;
entity pl, tm;
- sbwidth = HUD_GetWidth(6.5 * hud_fontsize_y);
+ xmin = cvar("scoreboard_offset_left") * vid_conwidth;
+ ymin = cvar("con_notify") * cvar("con_notifysize");
- xmin = 0.5 * (vid_conwidth - sbwidth);
- ymin = SCOREBOARD_OFFSET;
+ xmax = (1 - cvar("scoreboard_offset_right")) * vid_conwidth;
+ ymax = vid_conheight - ymin;
- xmax = vid_conwidth - xmin;
- ymax = vid_conheight - 0.2*vid_conheight;
+ sbwidth = xmax - xmin;
// Initializes position
pos_x = xmin;
// Heading
drawfont = hud_bigfont;
- drawstringcenter('0 1 0' * ymin, "Scoreboard", '24 24 0', '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
+ drawstring(pos, "Scoreboard", '24 24 0', '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
+
+ centerprint_start_x = vid_conwidth - 0.5 * (pos_x + stringwidth("Scoreboard", FALSE, '24 24 0'));
+ centerprint_start_y = pos_y;
- pos_y += 24 + 4;
- pos_y += hud_fontsize_y;
+ pos_y += 24;
drawfont = hud_font;
// Draw the scoreboard
- vector bg_size;
- bg_size = drawgetimagesize("gfx/hud/scoreboard_scoreboard_bg");
+ vector bg_size = drawgetimagesize("gfx/scoreboard/scoreboard_bg") * cvar("scoreboard_bg_scale");
if(teamplay)
{
continue;
rgb = GetTeamRGB(tm.team);
- drawstring(pos - '9.5 0 0' * hud_fontsize_y + '0 1 0' * hud_fontsize_y, ftos(tm.(teamscores[ts_primary])), '1 1 0' * hud_fontsize_y * 1.5, rgb, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
+ drawstring(pos - '2 0 0' * hud_fontsize_x + '0 1 0' * hud_fontsize_y, ftos(tm.(teamscores[ts_primary])), '1 1 0' * hud_fontsize_y * 1.5, rgb, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
if(ts_primary != ts_secondary)
- drawstring(pos - '7.5 0 0' * hud_fontsize_y + '0 2.5 0' * hud_fontsize_y, ftos(tm.(teamscores[ts_secondary])), '1 1 0' * hud_fontsize_y * 1, rgb, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
+ drawstring(pos - '2 0 0' * hud_fontsize_x + '0 2.5 0' * hud_fontsize_y, ftos(tm.(teamscores[ts_secondary])), '1 1 0' * hud_fontsize_y * 1, rgb, scoreboard_alpha_fg, DRAWFLAG_NORMAL);
pos = HUD_Scoreboard_MakeTable(pos, tm, rgb, bg_size);
}
}
pos = HUD_DrawScoreboardRankings(pos, pl, rgb, bg_size);
}
- else if(cvar("scoreboard_accuracy") && spectatee_status != -1) {
+ else if(cvar("scoreboard_accuracy") && spectatee_status != -1 && !warmup_stage) {
if(teamplay)
pos = HUD_DrawScoreboardAccuracyStats(pos, GetTeamRGB(myteam), bg_size);
else
pos = HUD_DrawScoreboardAccuracyStats(pos, rgb, bg_size);
}
- tmp = pos + '0 1.5 0' * hud_fontsize_y;
- pos_y += 3 * hud_fontsize_y;
-
// List spectators
float specs;
specs = 0;
+ tmp = pos;
for(pl = players.sort_next; pl; pl = pl.sort_next)
{
if(pl.team != COLOR_SPECTATOR)
continue;
- HUD_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1), specs);
pos_y += 1.25 * hud_fontsize_y;
+ HUD_PrintScoreboardItem(pos, pl, (pl.sv_entnum == player_localentnum - 1), specs);
++specs;
}
if(specs)
+ {
drawstring(tmp, "Spectators", hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
+ pos_y += 1.25 * hud_fontsize_y;
+ }
// Print info string
string str;
// background
drawpic(pos, "gfx/scoreboard/accuracy_bg", fill_size , fill_colour, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
- drawborderlines(hud_border_thickness, pos, fill_size, border_colour, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
+ drawborderlines(autocvar_scoreboard_border_thickness, pos, fill_size, border_colour, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
// the weapon
drawpic(pos, strcat("gfx/weapons/weapon", self.netname), '1 0.5 0' * fill_size_x , '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);
// background
drawpic(pos, "gfx/scoreboard/accuracy_bg", fill_size , fill_colour, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
- drawborderlines(hud_border_thickness, pos, fill_size, border_colour, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
+ drawborderlines(autocvar_scoreboard_border_thickness, pos, fill_size, border_colour, scoreboard_alpha_bg, DRAWFLAG_NORMAL);
// the weapon
drawpic(pos, strcat("gfx/weapons/weapon", self.netname), '1 0.5 0' * fill_size_x , '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL);