X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fclient%2Fscoreboard.qc;h=d4c2043e6c66fb05c99ab17090b82a702492d7af;hb=09dd8f125cd47599d0afb2ed2b76763ae5113eb6;hp=8e024ead5b0c7fdeb36865a802c9378bf55ba7bf;hpb=f87d67e5a9cfbbf50590ac28016b80d642eec1df;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/client/scoreboard.qc b/qcsrc/client/scoreboard.qc index 8e024ead5..d4c2043e6 100644 --- a/qcsrc/client/scoreboard.qc +++ b/qcsrc/client/scoreboard.qc @@ -240,11 +240,11 @@ void Cmd_HUD_Help(float argc) print(_("^3|---------------------------------------------------------------|\n")); print(_("Usage:\n")); print(_("^2scoreboard_columns_set default\n")); - print(_("^2scoreboard_columns_set ^7filed1 field2 ...\n")); + print(_("^2scoreboard_columns_set ^7field1 field2 ...\n")); print(_("The following field names are recognized (case insensitive):\n")); print(_("You can use a ^3|^7 to start the right-aligned fields.\n\n")); - print(_("^3name^7 or ^3nick^7 Name of a player\n")); + print(_("^3name^7 or ^3nick^7 Name of a player\n")); print(_("^3ping^7 Ping time\n")); print(_("^3pl^7 Packet loss\n")); print(_("^3kills^7 Number of kills\n")); @@ -509,7 +509,7 @@ string HUD_GetField(entity pl, float field) case SP_PING: if not(pl.gotscores) return "\xEE\x82\x8D\xEE\x82\x8D\xEE\x82\x8D"; // >>> sign - //str = getplayerkey(pl.sv_entnum, "ping"); + //str = getplayerkeyvalue(pl.sv_entnum, "ping"); f = pl.ping; if(f == 0) return _("N/A"); @@ -538,7 +538,7 @@ string HUD_GetField(entity pl, float field) } else if(!teamplay) { - f = stof(getplayerkey(pl.sv_entnum, "colors")); + f = stof(getplayerkeyvalue(pl.sv_entnum, "colors")); { hud_field_icon0 = "gfx/scoreboard/playercolor_base"; hud_field_icon1 = "gfx/scoreboard/playercolor_shirt"; @@ -597,7 +597,7 @@ string HUD_FixScoreboardColumnWidth(float i, string str) if(hud_field_icon0 != "") { - sz = drawgetimagesize(hud_field_icon0); + sz = draw_getimagesize(hud_field_icon0); f = sz_x / sz_y; if(hud_fixscoreboardcolumnwidth_iconlen < f) hud_fixscoreboardcolumnwidth_iconlen = f; @@ -605,7 +605,7 @@ string HUD_FixScoreboardColumnWidth(float i, string str) if(hud_field_icon1 != "") { - sz = drawgetimagesize(hud_field_icon1); + sz = draw_getimagesize(hud_field_icon1); f = sz_x / sz_y; if(hud_fixscoreboardcolumnwidth_iconlen < f) hud_fixscoreboardcolumnwidth_iconlen = f; @@ -613,7 +613,7 @@ string HUD_FixScoreboardColumnWidth(float i, string str) if(hud_field_icon2 != "") { - sz = drawgetimagesize(hud_field_icon2); + sz = draw_getimagesize(hud_field_icon2); f = sz_x / sz_y; if(hud_fixscoreboardcolumnwidth_iconlen < f) hud_fixscoreboardcolumnwidth_iconlen = f; @@ -792,6 +792,7 @@ vector HUD_Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_siz body_table_height = 1.25 * hud_fontsize_y * max(1, tm.team_size); // no player? show 1 empty line + pos_y += autocvar_scoreboard_border_thickness; pos -= '1 1 0'; tmp_x = sbwidth + 2; @@ -947,7 +948,7 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size) float weapon_width = sbwidth / weapon_cnt; drawstring(pos, sprintf(_("Accuracy stats (average %d%%)"), average_accuracy), hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL); - pos_y += 1.25 * hud_fontsize_y; + pos_y += 1.25 * hud_fontsize_y + autocvar_scoreboard_border_thickness; vector tmp; tmp_x = sbwidth; tmp_y = height * rows; @@ -977,10 +978,10 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size) if(rows == 2) pos_x += weapon_width / 2; - if(getstati(STAT_SWITCHWEAPON) == WEP_MINSTANEX) + if(switchweapon == WEP_MINSTANEX) g_minstagib = 1; // TODO: real detection for minstagib? - float weapon_stats, weapon_number; + float weapon_stats; if (!acc_levels) rgb = '1 1 1'; @@ -1052,6 +1053,59 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size) return pos; } +vector HUD_DrawKeyValue(vector pos, string key, string value) { + float px = pos_x; + pos_x += hud_fontsize_x * 0.25; + drawstring(pos, key, hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL); + pos_x = xmax - stringwidth(value, FALSE, hud_fontsize) - hud_fontsize_x * 0.25; + drawstring(pos, value, hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL); + pos_x = px; + pos_y+= hud_fontsize_y; + + return pos; +} + +vector HUD_DrawMapStats(vector pos, vector rgb, vector bg_size) { + float stat_secrets_found, stat_secrets_total; + float rows; + string val; + + // get secrets stats + stat_secrets_found = getstatf(STAT_SECRETS_FOUND); + stat_secrets_total = getstatf(STAT_SECRETS_TOTAL); + + // get number of rows + rows = (stat_secrets_total ? 1 : 0); + + // if no rows, return + if not(rows) + return pos; + + // draw table header + drawstring(pos, _("Map stats:"), hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL); + pos_y += 1.25 * hud_fontsize_y + autocvar_scoreboard_border_thickness; + + // draw table + vector tmp; + tmp_x = sbwidth; + tmp_y = hud_fontsize_y * rows; + + 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); + + // draw secrets + val = sprintf("%d/%d", stat_secrets_found, stat_secrets_total); + pos = HUD_DrawKeyValue(pos, _("Secrets found:"), val); + + // update position + pos_y += 1.25 * hud_fontsize_y; + return pos; +} + + vector HUD_DrawScoreboardRankings(vector pos, entity pl, vector rgb, vector bg_size) { float i; @@ -1072,7 +1126,7 @@ vector HUD_DrawScoreboardRankings(vector pos, entity pl, vector rgb, vector bg_ pos_y += hud_fontsize_y; drawstring(pos, _("Rankings"), hud_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL); - pos_y += hud_fontsize_y; + pos_y += hud_fontsize_y + autocvar_scoreboard_border_thickness; vector tmp; tmp_x = sbwidth; tmp_y = 1.25 * hud_fontsize_y * RANKINGS_RECEIVED_CNT; @@ -1102,6 +1156,7 @@ vector HUD_DrawScoreboardRankings(vector pos, entity pl, vector rgb, vector bg_ drawcolorcodedstring(pos + '8 0 0' * hud_fontsize_y, n, '1 1 0' * hud_fontsize_y, scoreboard_alpha_fg, DRAWFLAG_NORMAL); pos_y += 1.25 * hud_fontsize_y; } + pos_y += autocvar_scoreboard_border_thickness; return pos; } @@ -1147,12 +1202,13 @@ void HUD_DrawScoreboard() vector rgb, pos, tmp; entity pl, tm; + string str; - xmin = autocvar_scoreboard_offset_left * vid_conwidth; - ymin = autocvar_con_notify * autocvar_con_notifysize; + xmin = (autocvar_scoreboard_offset_left * vid_conwidth); + ymin = max((autocvar_con_notify * autocvar_con_notifysize), (autocvar_scoreboard_offset_vertical * vid_conwidth)); - xmax = (1 - autocvar_scoreboard_offset_right) * vid_conwidth; - ymax = vid_conheight - ymin; + xmax = ((1 - autocvar_scoreboard_offset_right) * vid_conwidth); + ymax = (vid_conheight - ymin); sbwidth = xmax - xmin; @@ -1162,29 +1218,33 @@ void HUD_DrawScoreboard() pos_z = 0; // Heading - 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; + vector sb_heading_fontsize; + sb_heading_fontsize = hud_fontsize * 2; + drawstring(pos, _("Scoreboard"), sb_heading_fontsize, '1 1 1', scoreboard_alpha_fg, DRAWFLAG_NORMAL); - pos_y += 24; + pos_y += sb_heading_fontsize_y + hud_fontsize_y * 0.25; // Draw the scoreboard - vector bg_size = drawgetimagesize("gfx/scoreboard/scoreboard_bg") * autocvar_scoreboard_bg_scale; + vector bg_size = draw_getimagesize("gfx/scoreboard/scoreboard_bg") * autocvar_scoreboard_bg_scale; if(teamplay) { + vector team_score_baseoffset; + team_score_baseoffset = eY * (2 * autocvar_scoreboard_border_thickness + hud_fontsize_y) - eX * (autocvar_scoreboard_border_thickness + hud_fontsize_x * 0.25); for(tm = teams.sort_next; tm; tm = tm.sort_next) { if(tm.team == COLOR_SPECTATOR) continue; rgb = GetTeamRGB(tm.team); - 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); + str = ftos(tm.(teamscores[ts_primary])); + drawstring(pos + team_score_baseoffset - eX * stringwidth(str, FALSE, hud_fontsize * 1.5), str, hud_fontsize * 1.5, rgb, scoreboard_alpha_fg, DRAWFLAG_NORMAL); if(ts_primary != ts_secondary) - 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); - + { + str = ftos(tm.(teamscores[ts_secondary])); + drawstring(pos + team_score_baseoffset - eX * stringwidth(str, FALSE, hud_fontsize) + eY * hud_fontsize_y * 1.5, str, hud_fontsize, rgb, scoreboard_alpha_fg, DRAWFLAG_NORMAL); + } pos = HUD_Scoreboard_MakeTable(pos, tm, rgb, bg_size); } } @@ -1221,6 +1281,12 @@ void HUD_DrawScoreboard() pos = HUD_DrawScoreboardAccuracyStats(pos, rgb, bg_size); } + + if(teamplay) + pos = HUD_DrawMapStats(pos, GetTeamRGB(myteam), bg_size); + else + pos = HUD_DrawMapStats(pos, rgb, bg_size); + // List spectators float specs; specs = 0; @@ -1241,7 +1307,6 @@ void HUD_DrawScoreboard() } // Print info string - string str; float tl, fl, ll; str = sprintf(_("playing on ^2%s^7"), shortmapname); tl = getstatf(STAT_TIMELIMIT);