X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fclient%2Fhud%2Fpanel%2Fscoreboard.qc;h=d7ecff8aea2167fd9729c2fdc465a212203b8765;hb=501b37c3ca4780caaf0b46043316dafb0d1c7aed;hp=120feeafa05cb858f0835c232b4e88f796e7ee88;hpb=52fa2a38da3a0f50c1e2a8a43507cebe4c408f6d;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/client/hud/panel/scoreboard.qc b/qcsrc/client/hud/panel/scoreboard.qc index 120feeafa..d7ecff8ae 100644 --- a/qcsrc/client/hud/panel/scoreboard.qc +++ b/qcsrc/client/hud/panel/scoreboard.qc @@ -1,18 +1,19 @@ #include "scoreboard.qh" #include -#include -#include -#include -#include "quickmenu.qh" -#include +#include +#include +#include +#include #include -#include +#include #include #include +#include #include #include #include +#include // Scoreboard (#24) @@ -83,7 +84,8 @@ bool autocvar_hud_panel_scoreboard_accuracy_nocolors = false; float autocvar_hud_panel_scoreboard_accuracy_showdelay = 2; float autocvar_hud_panel_scoreboard_accuracy_showdelay_minpos = 0.75; -bool autocvar_hud_panel_scoreboard_ctf_leaderboard = true; +bool autocvar_hud_panel_scoreboard_itemstats_doublerows = false; +bool autocvar_hud_panel_scoreboard_itemstats_filter = true; bool autocvar_hud_panel_scoreboard_dynamichud = false; @@ -1148,7 +1150,7 @@ bool Scoreboard_WouldDraw() return true; else if (intermission == 2) return false; - else if (spectatee_status != -1 && STAT(HEALTH) <= 0 && autocvar_cl_deathscoreboard && !ISGAMETYPE(CTS) + else if (spectatee_status != -1 && STAT(HEALTH) <= 0 && autocvar_cl_deathscoreboard && !MUTATOR_CALLHOOK(DrawDeathScoreboard) && (!HUD_MinigameMenu_IsOpened() || !active_minigame)) { return true; @@ -1314,6 +1316,133 @@ vector Scoreboard_AccuracyStats_Draw(vector pos, vector rgb, vector bg_size) return initial_pos + (end_pos - initial_pos) * scoreboard_acc_fade_alpha; } +.bool uninteresting; +STATIC_INIT(default_order_items_label) +{ + IL_EACH(default_order_items, true, { + switch(it.netname) + { + case "bullets": + case "cells": + case "plasma": + case "rockets": + case "shells": + case "vaporizer_cells": + case "fuel": + case "armor_small": + case "armor_medium": + case "health_small": + case "health_medium": + it.uninteresting = true; + } + }); +} + +vector Scoreboard_ItemStats_Draw(vector pos, vector rgb, vector bg_size) +{ + float scoreboard_acc_fade_alpha_save = scoreboard_acc_fade_alpha; // debug + scoreboard_acc_fade_alpha = 1; // debug: make Item Stats always visible + + float initial_posx = pos.x; + int disowned_cnt = 0; + int uninteresting_cnt = 0; + IL_EACH(default_order_items, true, { + int q = g_inventory.inv_items[it.m_id]; + //q = 1; // debug: display all items + if (autocvar_hud_panel_scoreboard_itemstats_filter && it.uninteresting) + ++uninteresting_cnt; + else if (!q) + ++disowned_cnt; + }); + int items_cnt = REGISTRY_COUNT(Items) - uninteresting_cnt; + int n = items_cnt - disowned_cnt; + if (n <= 0) return pos; + + int rows = (autocvar_hud_panel_scoreboard_itemstats_doublerows && n >= floor(REGISTRY_COUNT(Items) / 2)) ? 2 : 1; + int columnns = max(6, ceil(n / rows)); + + float height = 40; + float fontsize = height * 1/3; + float item_height = height * 2/3; + + drawstring(pos, _("Item stats"), hud_fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + pos.y += 1.25 * hud_fontsize.y; + if(panel.current_panel_bg != "0") + pos.y += panel_bg_border; + + panel_pos = pos; + panel_size.y = height * rows; + panel_size.y += panel_bg_padding * 2; + + float panel_bg_alpha_save = panel_bg_alpha; + panel_bg_alpha *= scoreboard_acc_fade_alpha; + HUD_Panel_DrawBg(); + panel_bg_alpha = panel_bg_alpha_save; + + vector end_pos = panel_pos + eY * (panel_size.y + hud_fontsize.y); + if(panel.current_panel_bg != "0") + end_pos.y += panel_bg_border * 2; + + if(panel_bg_padding) + { + panel_pos += '1 1 0' * panel_bg_padding; + panel_size -= '2 2 0' * panel_bg_padding; + } + + pos = panel_pos; + vector tmp = panel_size; + + float item_width = tmp.x / columnns / rows; + + if (sbt_bg_alpha) + drawpic_tiled(pos, "gfx/scoreboard/scoreboard_bg", bg_size, tmp, rgb, sbt_bg_alpha * scoreboard_acc_fade_alpha, DRAWFLAG_NORMAL); + + if(sbt_highlight) + { + // column highlighting + for (int i = 0; i < columnns; ++i) + if ((i % 2) == 0) + drawfill(pos + '1 0 0' * item_width * rows * i, '0 1 0' * height * rows + '1 0 0' * item_width * rows, '0 0 0', panel_bg_alpha * 0.2, DRAWFLAG_NORMAL); + + // row highlighting + for (int i = 0; i < rows; ++i) + drawfill(pos + '0 1 0' * item_height + '0 1 0' * height * i, '1 0 0' * panel_size.x + '0 1 0' * fontsize, '1 1 1', sbt_highlight_alpha, DRAWFLAG_NORMAL); + } + + if (rows == 2) + pos.x += item_width / 2; + + float oldposx = pos.x; + vector tmpos = pos; + + int column = 0; + IL_EACH(default_order_items, !(autocvar_hud_panel_scoreboard_itemstats_filter && it.uninteresting), { + int n = g_inventory.inv_items[it.m_id]; + //n = 1 + floor(i * 3 + 4.8) % 7; // debug: display a value for each item + if (n <= 0) continue; + drawpic_aspect_skin(tmpos, it.m_icon, '1 0 0' * item_width + '0 1 0' * item_height, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + string s = ftos(n); + float padding = (item_width - stringwidth(s, false, '1 0 0' * fontsize)) / 2; // center + drawstring(tmpos + '1 0 0' * padding + '0 1 0' * item_height, s, '1 1 0' * fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + tmpos.x += item_width * rows; + pos.x += item_width * rows; + if (rows == 2 && column == columnns - 1) { + tmpos.x = oldposx; + tmpos.y += height; + pos.y += height; + } + ++column; + }); + pos.y += height; + pos.y += 1.25 * hud_fontsize.y; + pos.x = initial_posx; + + panel_size.x += panel_bg_padding * 2; // restore initial width + + scoreboard_acc_fade_alpha = scoreboard_acc_fade_alpha_save; // debug + return pos; +} + vector MapStats_DrawKeyValue(vector pos, string key, string value) { float px = pos.x; pos.x += hud_fontsize.x * 0.25; @@ -1396,7 +1525,7 @@ vector Scoreboard_MapStats_Draw(vector pos, vector rgb, vector bg_size) { } -vector Scoreboard_Rankings_Draw(vector pos, entity pl, vector rgb, vector bg_size) +vector Scoreboard_Rankings_Draw(vector pos, string ranktitle, entity pl, vector rgb, vector bg_size) { int i; RANKINGS_RECEIVED_CNT = 0; @@ -1410,7 +1539,7 @@ vector Scoreboard_Rankings_Draw(vector pos, entity pl, vector rgb, vector bg_siz vector hl_rgb = rgb + '0.5 0.5 0.5'; pos.y += hud_fontsize.y; - drawstring(pos + eX * panel_bg_padding, ((ISGAMETYPE(CTF)) ? _("Capture time rankings") : _("Rankings")), hud_fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); + drawstring(pos + eX * panel_bg_padding, ranktitle, hud_fontsize, '1 1 1', panel_fg_alpha, DRAWFLAG_NORMAL); pos.y += 1.25 * hud_fontsize.y; if(panel.current_panel_bg != "0") pos.y += panel_bg_border; @@ -1506,7 +1635,7 @@ float scoreboard_time; bool have_weapon_stats; bool Scoreboard_AccuracyStats_WouldDraw(float ypos) { - if (ISGAMETYPE(CTS) || ISGAMETYPE(RACE) || ISGAMETYPE(NEXBALL)) + if (MUTATOR_CALLHOOK(DrawScoreboardAccuracy)) return false; if (!autocvar_hud_panel_scoreboard_accuracy || warmup_stage || ypos > 0.91 * vid_conheight) return false; @@ -1629,7 +1758,7 @@ void Scoreboard_Draw() str = ""; if(tl > 0) str = strcat(str, sprintf(_("^3%1.0f minutes"), tl)); - if(!ISGAMETYPE(LMS)) + if(!gametype.m_hidelimits) { if(fl > 0) { @@ -1817,8 +1946,10 @@ void Scoreboard_Draw() if (Scoreboard_AccuracyStats_WouldDraw(pos.y)) pos = Scoreboard_AccuracyStats_Draw(pos, panel_bg_color, bg_size); + pos = Scoreboard_ItemStats_Draw(pos, panel_bg_color, bg_size); - if(ISGAMETYPE(CTS) || ISGAMETYPE(RACE) || (autocvar_hud_panel_scoreboard_ctf_leaderboard && ISGAMETYPE(CTF) && STAT(CTF_SHOWLEADERBOARD))) { + if(MUTATOR_CALLHOOK(ShowRankings)) { + string ranktitle = M_ARGV(0, string); if(race_speedaward) { drawcolorcodedstring(pos, sprintf(_("Speed award: %d%s ^7(%s^7)"), race_speedaward, race_speedaward_unit, ColorTranslateRGB(race_speedaward_holder)), hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL); pos.y += 1.25 * hud_fontsize.y; @@ -1827,7 +1958,7 @@ void Scoreboard_Draw() drawcolorcodedstring(pos, sprintf(_("All-time fastest: %d%s ^7(%s^7)"), race_speedaward_alltimebest, race_speedaward_alltimebest_unit, ColorTranslateRGB(race_speedaward_alltimebest_holder)), hud_fontsize, panel_fg_alpha, DRAWFLAG_NORMAL); pos.y += 1.25 * hud_fontsize.y; } - pos = Scoreboard_Rankings_Draw(pos, playerslots[player_localnum], panel_bg_color, bg_size); + pos = Scoreboard_Rankings_Draw(pos, ranktitle, playerslots[player_localnum], panel_bg_color, bg_size); } pos = Scoreboard_MapStats_Draw(pos, panel_bg_color, bg_size);