From: terencehill Date: Tue, 27 Apr 2021 13:39:48 +0000 (+0200) Subject: Allow customizing item stats filter with hud_panel_scoreboard_itemstats_filter_mask X-Git-Tag: xonotic-v0.8.5~429 X-Git-Url: http://git.xonotic.org/?a=commitdiff_plain;h=91b14543fa55daae62bc3cbdb5d3b3e082a9c5c3;p=xonotic%2Fxonotic-data.pk3dir.git Allow customizing item stats filter with hud_panel_scoreboard_itemstats_filter_mask --- diff --git a/_hud_common.cfg b/_hud_common.cfg index a62837f5f..c622cca34 100644 --- a/_hud_common.cfg +++ b/_hud_common.cfg @@ -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" diff --git a/qcsrc/client/hud/panel/scoreboard.qc b/qcsrc/client/hud/panel/scoreboard.qc index 985796044..2f756e4ae 100644 --- a/qcsrc/client/hud/panel/scoreboard.qc +++ b/qcsrc/client/hud/panel/scoreboard.qc @@ -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