]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'master' into terencehill/scoreboard_item_stats
authorterencehill <piuntn@gmail.com>
Mon, 2 Nov 2020 09:49:30 +0000 (10:49 +0100)
committerterencehill <piuntn@gmail.com>
Mon, 2 Nov 2020 09:49:30 +0000 (10:49 +0100)
12 files changed:
_hud_common.cfg
_hud_descriptions.cfg
hud_luma.cfg
hud_luminos.cfg
hud_luminos_minimal.cfg
hud_luminos_minimal_xhair.cfg
hud_luminos_old.cfg
hud_nexuiz.cfg
qcsrc/client/hud/panel/scoreboard.qc
qcsrc/client/hud/panel/scoreboard.qh
qcsrc/client/mutators/events.qh
qcsrc/common/items/all.qh

index f2be854d5b1d9603ad9ae1ca5e66ca4d2d66662b..29c41803f11dcd69647dc4f036ce5eb70ff68604 100644 (file)
@@ -45,8 +45,9 @@ seta hud_panel_centerprint      1 "enable this panel"
 seta hud_panel_itemstime        2 "enable this panel, 1 = show when spectating, 2 = even playing in warmup stage"
 //seta hud_panel_quickmenu        1 "enable this panel"
 //seta hud_panel_scoreboard       1 "enable this panel"
-seta hud_panel_scoreboard_accuracy 1 "show weapon accuracy stats panel on scoreboard; colors can be configured with accuracy_color* cvars"
+seta hud_panel_scoreboard_accuracy 1 "show weapon accuracy stats panel in the scoreboard; colors can be configured with accuracy_color* cvars"
 seta hud_panel_scoreboard_ctf_leaderboard 1 "show a capture time rankings leaderboard in the scoreboard if allowed by the server"
+seta hud_panel_scoreboard_itemstats 1 "show item stats panel in the scoreboard"
 seta hud_panel_strafehud        3 "enable this panel, 1 = show if not observing, 2 = show always, 3 = show only in race/cts if not observing"
 
 seta hud_panel_weapons_dynamichud          1 "apply the dynamic hud effects to this panel"
@@ -119,10 +120,14 @@ seta hud_panel_scoreboard_others_showscore 1 "show scores of players listed in t
 seta hud_panel_scoreboard_spectators_showping 1 "show ping of spectators"
 seta hud_panel_scoreboard_spectators_aligned 0 "align spectators in columns"
 seta hud_panel_scoreboard_minwidth 0.6 "minimum width of the scoreboard"
+seta hud_panel_scoreboard_team_size_position 0 "where to show the team size (0 = do not show, 1 = left of scoreboard, 2 = right of scoreboard), will move team scores to the other side if necessary"
 
 seta hud_panel_scoreboard_accuracy_showdelay 2 "how long to delay displaying accuracy below the scoreboard if it's too far down"
 seta hud_panel_scoreboard_accuracy_showdelay_minpos 0.75 "delay displaying the accuracy panel only if its position is lower than this percentage of the screen height from the top"
-seta hud_panel_scoreboard_team_size_position 0 "where to show the team size (0 = do not show, 1 = left of scoreboard, 2 = right of scoreboard), will move team scores to the other side if necessary"
+
+seta hud_panel_scoreboard_itemstats_filter 1 "filter out less interesting items (ammo and smaller health/armor)"
+seta hud_panel_scoreboard_itemstats_showdelay 2.2 "how long to delay displaying item stats below the scoreboard if it's too far down"
+seta hud_panel_scoreboard_itemstats_showdelay_minpos 0.75 "delay displaying the item stats panel only if its position is lower than this percentage of the screen height from the top"
 
 seta _hud_panel_strafehud_demo "0" "strafehud changes angle during configure"
 seta hud_panel_strafehud_mode "0" "strafehud mode which controls whether the strafehud is centered at \"0\" = view angle, \"1\" = velocity angle"
index 6880f96e045c863e25a083b7e446b0db8b2891a1..8dd81c1cbce4ec8b10fc2e42e7fe4e993d92a386 100644 (file)
@@ -378,6 +378,7 @@ seta hud_panel_scoreboard_table_highlight_alpha_self "" "self highlight alpha of
 seta hud_panel_scoreboard_bg_teams_color_team "" "override panel team color in team tables"
 seta hud_panel_scoreboard_accuracy_doublerows "" "use two rows instead of one"
 seta hud_panel_scoreboard_accuracy_nocolors "" "don't use colors displaying accuracy stats"
+seta hud_panel_scoreboard_itemstats_doublerows "" "use two rows instead of one"
 
 seta hud_panel_strafehud_pos "" "position of this base of the panel"
 seta hud_panel_strafehud_size "" "size of this panel"
index 747736b26998c49741663256473f75f1b5289f57..5181130b2e4e9f12c742df5bd4332aeea8d8f27c 100644 (file)
@@ -379,6 +379,7 @@ seta hud_panel_scoreboard_table_highlight_alpha_self "0.4"
 seta hud_panel_scoreboard_bg_teams_color_team "0"
 seta hud_panel_scoreboard_accuracy_doublerows "0"
 seta hud_panel_scoreboard_accuracy_nocolors "0"
+seta hud_panel_scoreboard_itemstats_doublerows "0"
 
 seta hud_panel_strafehud_pos "0.320000 0.570000"
 seta hud_panel_strafehud_size "0.360000 0.020000"
index 3a02780b6b24a754777d03d7ce91173d9765ea72..a91a289705ab4dce76470d4743545ea891447404 100644 (file)
@@ -379,6 +379,7 @@ seta hud_panel_scoreboard_table_highlight_alpha_self "0.3"
 seta hud_panel_scoreboard_bg_teams_color_team "0"
 seta hud_panel_scoreboard_accuracy_doublerows "1"
 seta hud_panel_scoreboard_accuracy_nocolors "0"
+seta hud_panel_scoreboard_itemstats_doublerows "0"
 
 seta hud_panel_strafehud_pos "0.330000 0.570000"
 seta hud_panel_strafehud_size "0.340000 0.020000"
index 80642d6fe535d7a0d09e2d77dbcfbae36cfc7492..31a798f050dd7c71592593b214cfdc09114ed292 100644 (file)
@@ -379,6 +379,7 @@ seta hud_panel_scoreboard_table_highlight_alpha_self "0.3"
 seta hud_panel_scoreboard_bg_teams_color_team "0.7"
 seta hud_panel_scoreboard_accuracy_doublerows "1"
 seta hud_panel_scoreboard_accuracy_nocolors "0"
+seta hud_panel_scoreboard_itemstats_doublerows "0"
 
 seta hud_panel_strafehud_pos "0.380000 0.550000"
 seta hud_panel_strafehud_size "0.240000 0.025000"
index 31abc94cfcc1fae657bf053c0677a8593fbf5f9f..9e6538520a45ac6dc65016012abf80413ff937b9 100644 (file)
@@ -379,6 +379,7 @@ seta hud_panel_scoreboard_table_highlight_alpha_self "0.3"
 seta hud_panel_scoreboard_bg_teams_color_team "0.7"
 seta hud_panel_scoreboard_accuracy_doublerows "1"
 seta hud_panel_scoreboard_accuracy_nocolors "0"
+seta hud_panel_scoreboard_itemstats_doublerows "0"
 
 seta hud_panel_strafehud_pos "0.330000 0.700000"
 seta hud_panel_strafehud_size "0.340000 0.015000"
index d53902eac34183ffdbfef1d60b2a702098cbec55..eac63c6bbcb3295e1f1bbed1b74b44b8dff8923f 100644 (file)
@@ -379,6 +379,7 @@ seta hud_panel_scoreboard_table_highlight_alpha_self "0.3"
 seta hud_panel_scoreboard_bg_teams_color_team "0.7"
 seta hud_panel_scoreboard_accuracy_doublerows "1"
 seta hud_panel_scoreboard_accuracy_nocolors "0"
+seta hud_panel_scoreboard_itemstats_doublerows "0"
 
 seta hud_panel_strafehud_pos "0.320000 0.540000"
 seta hud_panel_strafehud_size "0.360000 0.025000"
index b820ef52499dd172255ff69aef9a45dbf759fc0a..f2a56cc080e42f7f377e26de2edc25623f971b09 100644 (file)
@@ -379,6 +379,7 @@ seta hud_panel_scoreboard_table_highlight_alpha_self "0.25"
 seta hud_panel_scoreboard_bg_teams_color_team "0.7"
 seta hud_panel_scoreboard_accuracy_doublerows "1"
 seta hud_panel_scoreboard_accuracy_nocolors "0"
+seta hud_panel_scoreboard_itemstats_doublerows "0"
 
 seta hud_panel_strafehud_pos "0.360000 0.570000"
 seta hud_panel_strafehud_size "0.280000 0.025000"
index 5821dc46946808598f58f01f77d28b0e7e73ac59..c0f1bc6eac8ff2b046adc90f147767d9ce57daa4 100644 (file)
@@ -13,6 +13,7 @@
 #include <common/scores.qh>
 #include <common/stats.qh>
 #include <common/teams.qh>
+#include <common/items/inventory.qh>
 
 // Scoreboard (#24)
 
@@ -83,6 +84,12 @@ 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_itemstats = true;
+bool autocvar_hud_panel_scoreboard_itemstats_doublerows = false;
+bool autocvar_hud_panel_scoreboard_itemstats_filter = true;
+float autocvar_hud_panel_scoreboard_itemstats_showdelay = 2.2; // slightly more delayed than accuracy
+float autocvar_hud_panel_scoreboard_itemstats_showdelay_minpos = 0.75;
+
 bool autocvar_hud_panel_scoreboard_dynamichud = false;
 
 float autocvar_hud_panel_scoreboard_maxheight = 0.6;
@@ -1069,7 +1076,7 @@ vector Scoreboard_MakeTable(vector pos, entity tm, vector rgb, vector bg_size)
        panel_size.y += panel_bg_padding * 2;
        HUD_Panel_DrawBg();
 
-       vector end_pos = panel_pos + eY * (panel_size.y + 0.5* hud_fontsize.y);
+       vector end_pos = panel_pos + eY * (panel_size.y + 0.5 * hud_fontsize.y);
        if(panel.current_panel_bg != "0")
                end_pos.y += panel_bg_border * 2;
 
@@ -1161,7 +1168,7 @@ vector Scoreboard_AccuracyStats_Draw(vector pos, vector rgb, vector bg_size)
 {
        if (frametime)
        {
-               if (scoreboard_fade_alpha == 1)
+               if (scoreboard_fade_alpha < 1)
                        scoreboard_acc_fade_alpha = min(1, scoreboard_acc_fade_alpha + frametime * 10);
                else
                        scoreboard_acc_fade_alpha = 1; // sync fading with the scoreboard
@@ -1215,7 +1222,7 @@ vector Scoreboard_AccuracyStats_Draw(vector pos, vector rgb, vector bg_size)
        HUD_Panel_DrawBg();
        panel_bg_alpha = panel_bg_alpha_save;
 
-       vector end_pos = panel_pos + eY * (panel_size.y + hud_fontsize.y);
+       vector end_pos = panel_pos + eY * (panel_size.y + 0.5 * hud_fontsize.y);
        if(panel.current_panel_bg != "0")
                end_pos.y += panel_bg_border * 2;
 
@@ -1312,6 +1319,136 @@ 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)
+{
+       if (frametime)
+       {
+               if (scoreboard_fade_alpha < 1)
+                       scoreboard_itemstats_fade_alpha = min(1, scoreboard_itemstats_fade_alpha + frametime * 10);
+               else
+                       scoreboard_itemstats_fade_alpha = 1; // sync fading with the scoreboard
+       }
+       vector initial_pos = pos;
+
+       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 + eX * panel_bg_padding, _("Item stats"), hud_fontsize, '1 1 1', panel_fg_alpha * scoreboard_itemstats_fade_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_itemstats_fade_alpha;
+       HUD_Panel_DrawBg();
+       panel_bg_alpha = panel_bg_alpha_save;
+
+       vector end_pos = panel_pos + eY * (panel_size.y + 0.5 * 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_itemstats_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', sbt_highlight_alpha * scoreboard_itemstats_fade_alpha, 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, rgb, sbt_highlight_alpha * scoreboard_itemstats_fade_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 * scoreboard_itemstats_fade_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 * scoreboard_itemstats_fade_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;
+       });
+
+       panel_size.x += panel_bg_padding * 2; // restore initial width
+
+       if (scoreboard_itemstats_fade_alpha == 1)
+               return end_pos;
+       return initial_pos + (end_pos - initial_pos) * scoreboard_itemstats_fade_alpha;
+}
+
 vector MapStats_DrawKeyValue(vector pos, string key, string value) {
        float px = pos.x;
        pos.x += hud_fontsize.x * 0.25;
@@ -1359,7 +1496,7 @@ vector Scoreboard_MapStats_Draw(vector pos, vector rgb, vector bg_size) {
        panel_size.y += panel_bg_padding * 2;
        HUD_Panel_DrawBg();
 
-       vector end_pos = panel_pos + eY * (panel_size.y + hud_fontsize.y);
+       vector end_pos = panel_pos + eY * (panel_size.y + 0.5 * hud_fontsize.y);
        if(panel.current_panel_bg != "0")
                end_pos.y += panel_bg_border * 2;
 
@@ -1445,7 +1582,7 @@ vector Scoreboard_Rankings_Draw(vector pos, string ranktitle, entity pl, vector
 
        HUD_Panel_DrawBg();
 
-       vector end_pos = panel_pos + eY * (panel_size.y + hud_fontsize.y);
+       vector end_pos = panel_pos + eY * (panel_size.y + 0.5 * hud_fontsize.y);
        if(panel.current_panel_bg != "0")
                end_pos.y += panel_bg_border * 2;
 
@@ -1533,6 +1670,42 @@ bool Scoreboard_AccuracyStats_WouldDraw(float ypos)
        return true;
 }
 
+bool have_item_stats;
+bool Scoreboard_ItemStats_WouldDraw(float ypos)
+{
+       if (MUTATOR_CALLHOOK(DrawScoreboardItemStats))
+               return false;
+       if (!autocvar_hud_panel_scoreboard_itemstats || warmup_stage || ypos > 0.91 * vid_conheight)
+               return false;
+
+       if (time < scoreboard_time + autocvar_hud_panel_scoreboard_itemstats_showdelay
+               && ypos > autocvar_hud_panel_scoreboard_itemstats_showdelay_minpos * vid_conheight
+               && !intermission)
+       {
+               return false;
+       }
+
+       if (!have_item_stats)
+       {
+               IL_EACH(default_order_items, true, {
+                       if (!(autocvar_hud_panel_scoreboard_itemstats_filter && it.uninteresting))
+                       {
+                               int q = g_inventory.inv_items[it.m_id];
+                               //q = 1; // debug: display all items
+                               if (q)
+                               {
+                                       have_item_stats = true;
+                                       break;
+                               }
+                       }
+               });
+               if (!have_item_stats)
+                       return false;
+       }
+
+       return true;
+}
+
 void Scoreboard_Draw()
 {
        if(!autocvar__hud_configure)
@@ -1568,6 +1741,7 @@ void Scoreboard_Draw()
                if (!scoreboard_fade_alpha)
                {
                        scoreboard_acc_fade_alpha = 0;
+                       scoreboard_itemstats_fade_alpha = 0;
                        return;
                }
        }
@@ -1815,6 +1989,8 @@ void Scoreboard_Draw()
 
        if (Scoreboard_AccuracyStats_WouldDraw(pos.y))
                pos = Scoreboard_AccuracyStats_Draw(pos, panel_bg_color, bg_size);
+       if (Scoreboard_ItemStats_WouldDraw(pos.y))
+               pos = Scoreboard_ItemStats_Draw(pos, panel_bg_color, bg_size);
 
        if(MUTATOR_CALLHOOK(ShowRankings)) {
                string ranktitle = M_ARGV(0, string);
index f0dbdb5c6d6a1f92fa2505533d8ffe2d8dba48e0..7189143e669831af26eb7576c6ff43453f214ba6 100644 (file)
@@ -9,6 +9,7 @@ bool scoreboard_showscores;
 bool scoreboard_active;
 float scoreboard_fade_alpha;
 float scoreboard_acc_fade_alpha;
+float scoreboard_itemstats_fade_alpha;
 
 void Cmd_Scoreboard_SetFields(int argc);
 void Scoreboard_Draw();
index 7115ed4dfba7c6b27233c8b4123ec11928e78ff8..245224ba237d7e56cbe3b73388ced6de5d6e8f0c 100644 (file)
@@ -181,6 +181,9 @@ MUTATOR_HOOKABLE(DrawDeathScoreboard, EV_NO_ARGS);
 /** Return true to not show accuracy stats in the scoreboard */
 MUTATOR_HOOKABLE(DrawScoreboardAccuracy, EV_NO_ARGS);
 
+/** Return true to not show accuracy stats in the scoreboard */
+MUTATOR_HOOKABLE(DrawScoreboardItemStats, EV_NO_ARGS);
+
 /** Called when drawing info messages, allows adding new info messages. Return true to hide the standard join message */
 #define EV_DrawInfoMessages(i, o) \
        /** pos */                          i(vector, MUTATOR_ARGV_0_vector) \
index 359c0017955794bade60ea96a9565ed2edf5c009..7134a9947b674aa1d2b6573ba598d9bfd969bef7 100644 (file)
@@ -12,6 +12,17 @@ REGISTRY_DEPENDS(Items, Models)
 REGISTER_REGISTRY(Items)
 #define REGISTER_ITEM(id, class) REGISTER(Items, ITEM, id, m_id, NEW(class))
 
+#ifdef CSQC
+IntrusiveList default_order_items;
+STATIC_INIT(default_order_items)
+{
+       default_order_items = IL_NEW();
+       FOREACH(Items, true, {
+               IL_PUSH(default_order_items, it);
+       });
+}
+#endif
+
 REGISTRY_SORT(Items)
 REGISTRY_CHECK(Items)