]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Allow customizing item stats filter with hud_panel_scoreboard_itemstats_filter_mask
authorterencehill <piuntn@gmail.com>
Tue, 27 Apr 2021 13:39:48 +0000 (15:39 +0200)
committerterencehill <piuntn@gmail.com>
Tue, 27 Apr 2021 13:39:48 +0000 (15:39 +0200)
_hud_common.cfg
qcsrc/client/hud/panel/scoreboard.qc

index a62837f5f8b4f0881871938eb9246a8aaa534eb8..c622cca34ca126756b3753bb937e32160cbeaea0 100644 (file)
@@ -129,7 +129,8 @@ seta hud_panel_scoreboard_playerid_suffix " " "player id suffix"
 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_itemstats_filter 1 "filter out less interesting items (ammo and smaller health/armor)"
+seta hud_panel_scoreboard_itemstats_filter 1 "filter out less interesting items (according to hud_panel_scoreboard_itemstats_filter_mask)"
+seta hud_panel_scoreboard_itemstats_filter_mask 12 "[0-1][0-4]: the tens digit filters out all ammo items if set to 1, the units digit filters out health/armor items (1 small, 2 medium too, 3 big too, 4 mega too)"
 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"
 
index 9857960440fd79f7da6361eb7ccdd1822890cff9..2f756e4ae190bbca581d0403001db6c9ac6d46cb 100644 (file)
@@ -89,7 +89,8 @@ 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;
+int autocvar_hud_panel_scoreboard_itemstats_filter = 1;
+int autocvar_hud_panel_scoreboard_itemstats_filter_mask = 12;
 float autocvar_hud_panel_scoreboard_itemstats_showdelay = 2.2; // slightly more delayed than accuracy
 float autocvar_hud_panel_scoreboard_itemstats_showdelay_minpos = 0.75;
 
@@ -1351,18 +1352,31 @@ vector Scoreboard_AccuracyStats_Draw(vector pos, vector rgb, vector bg_size)
        return end_pos;
 }
 
-.bool uninteresting;
-STATIC_INIT(default_order_items_label)
+bool is_item_filtered(entity it)
 {
-       IL_EACH(default_order_items, true, {
-               if(!(it.instanceOfPowerup
-                       || it == ITEM_HealthMega || it == ITEM_HealthBig
-                       || it == ITEM_ArmorMega || it == ITEM_ArmorBig
-                       ))
+       if (!autocvar_hud_panel_scoreboard_itemstats_filter)
+               return false;
+       int mask = autocvar_hud_panel_scoreboard_itemstats_filter_mask;
+       if (mask <= 0)
+               return false;
+       if (it.instanceOfArmor || it.instanceOfHealth)
+       {
+               int ha_mask = floor(mask) % 10;
+               switch (ha_mask)
                {
-                       it.uninteresting = true;
+                       default: return false;
+                       case 4: if (it == ITEM_HealthMega || it == ITEM_ArmorMega) return true; // else fallthrough
+                       case 3: if (it == ITEM_HealthBig || it == ITEM_ArmorBig) return true; // else fallthrough
+                       case 2: if (it == ITEM_HealthMedium || it == ITEM_ArmorMedium) return true; // else fallthrough
+                       case 1: if (it == ITEM_HealthSmall || it == ITEM_ArmorSmall) return true; // else fallthrough
                }
-       });
+       }
+       if (it.instanceOfAmmo)
+       {
+               int ammo_mask = floor(mask / 10) % 10;
+               return (ammo_mask == 1);
+       }
+       return false;
 }
 
 vector Scoreboard_ItemStats_Draw(vector pos, vector rgb, vector bg_size)
@@ -1374,7 +1388,7 @@ vector Scoreboard_ItemStats_Draw(vector pos, vector rgb, vector bg_size)
        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)
+               if (is_item_filtered(it))
                        ++uninteresting_cnt;
                else if (!q)
                        ++disowned_cnt;
@@ -1441,7 +1455,7 @@ vector Scoreboard_ItemStats_Draw(vector pos, vector rgb, vector bg_size)
        vector tmpos = pos;
 
        int column = 0;
-       IL_EACH(default_order_items, !(autocvar_hud_panel_scoreboard_itemstats_filter && it.uninteresting), {
+       IL_EACH(default_order_items, !is_item_filtered(it), {
                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;
@@ -1703,7 +1717,7 @@ bool Scoreboard_ItemStats_WouldDraw(float ypos)
        if (!have_item_stats)
        {
                IL_EACH(default_order_items, true, {
-                       if (!(autocvar_hud_panel_scoreboard_itemstats_filter && it.uninteresting))
+                       if (!is_item_filtered(it))
                        {
                                int q = g_inventory.inv_items[it.m_id];
                                //q = 1; // debug: display all items