X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fclient%2Fscoreboard.qc;h=ec17dfca77efe473c73a5146513c1744f6820fe8;hb=520a3a3b0dd71ab7e3e9c47a9cf9631e72ed0d8f;hp=7905c059408c7d5af79e2ac6249759ffe214e64f;hpb=2d1cde17bad3d221b50fd891edb8519bb54a6b77;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/client/scoreboard.qc b/qcsrc/client/scoreboard.qc index 7905c0594..ec17dfca7 100644 --- a/qcsrc/client/scoreboard.qc +++ b/qcsrc/client/scoreboard.qc @@ -761,26 +761,26 @@ vector HUD_Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_siz // rounded header if (teamplay) - drawpic(pos, "gfx/scoreboard/scoreboard_tableheader", tmp, (rgb * autocvar_hud_color_bg_team) + '0.5 0.5 0.5', scoreboard_alpha_bg, DRAWFLAG_NORMAL); + 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; if (teamplay) - drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb * autocvar_hud_color_bg_team, scoreboard_alpha_bg, DRAWFLAG_NORMAL); + 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); @@ -789,14 +789,14 @@ vector HUD_Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_siz // 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; } @@ -846,7 +846,7 @@ vector HUD_Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_siz 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; @@ -883,11 +883,9 @@ float HUD_WouldDrawScoreboard() { 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; } @@ -897,8 +895,6 @@ float average_accuracy; vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size) { float i; - float weapon_hit, weapon_damage, weapon_stats; - float fontsize = 40 * 1/3; float weapon_cnt = WEP_COUNT - 3; // either minstanex/nex are hidden, no port-o-launch, no tuba float rows; if(cvar("scoreboard_accuracy_doublerows")) @@ -906,35 +902,33 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size) 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; if (teamplay) - drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb * autocvar_hud_color_bg_team, scoreboard_alpha_bg, DRAWFLAG_NORMAL); + 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(hud_accuracy_border_thickness, pos, tmp, '0 0 0', scoreboard_alpha_bg * 0.75, 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; @@ -942,11 +936,27 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size) 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? + float weapon_hit, weapon_damage, weapon_stats, weapon_number; + // hits + weapon_stats = getstati(STAT_DAMAGE_HITS); + weapon_number = weapon_stats & 63; + weapon_hits[weapon_number-WEP_FIRST] = floor(weapon_stats / 64); + // fired + weapon_stats = getstati(STAT_DAMAGE_FIRED); + weapon_number = weapon_stats & 63; + weapon_fired[weapon_number-WEP_FIRST] = floor(weapon_stats / 64); + + if (!acc_levels) + rgb = '1 1 1'; + else if (acc_col_x[0] == -1) + for (i = 0; i < acc_levels; ++i) + acc_col[i] = stov(cvar_string(strcat("accuracy_color", ftos(i)))); + for(i = WEP_FIRST; i <= WEP_LAST; ++i) { self = get_weaponinfo(i); @@ -956,17 +966,18 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size) continue; weapon_hit = weapon_hits[i-WEP_FIRST]; weapon_damage = weapon_fired[i-WEP_FIRST]; - if(weapon_damage) - weapon_stats = bound(0, floor(100 * weapon_hit / weapon_damage), 100); - float weapon_alpha; + float weapon_alpha; if(weapon_damage) + { + weapon_stats = bound(0, floor(100 * weapon_hit / weapon_damage), 100); weapon_alpha = scoreboard_alpha_fg; + } else weapon_alpha = 0.2 * scoreboard_alpha_fg; // weapon icon - drawpic_aspect_skin(pos, strcat("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; @@ -976,9 +987,8 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size) 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 - float weapon_hit, weapon_damage; weapon_damage = weapon_fired[self.weapon-WEP_FIRST]; if(weapon_damage) { @@ -986,21 +996,24 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size) weapon_stats = floor(100 * weapon_hit / weapon_damage); } - // 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); + 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_col[j]; + rgb = rgb + factor * (acc_col[j+1] - rgb); + } - drawstring(pos + '1 0 0' * padding + '0 1 0' * height * (2/3), s, '1 1 0' * fontsize, rgb, scoreboard_alpha_fg, DRAWFLAG_NORMAL); + 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; @@ -1012,9 +1025,11 @@ vector HUD_DrawScoreboardAccuracyStats(vector pos, vector rgb, vector bg_size) 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; } @@ -1041,13 +1056,13 @@ vector HUD_DrawScoreboardRankings(vector pos, entity pl, vector rgb, vector bg_ pos_y += hud_fontsize_y; vector tmp; tmp_x = sbwidth; - tmp_y = hud_fontsize_y * RANKINGS_RECEIVED_CNT; + tmp_y = 1.25 * hud_fontsize_y * RANKINGS_RECEIVED_CNT; if (teamplay) - drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb * autocvar_hud_color_bg_team, scoreboard_alpha_bg, DRAWFLAG_NORMAL); + 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(hud_border_thickness, pos, tmp, '0 0 0', scoreboard_alpha_bg * 0.75, 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