From: terencehill Date: Sun, 25 Oct 2020 10:28:13 +0000 (+0100) Subject: Item stats panel: add cvar to enable/disable it and delay displaying it if it's too... X-Git-Tag: xonotic-v0.8.5~588^2~17 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=1fafdb33c9ee00c7f671e5e77509d9907346653f;p=xonotic%2Fxonotic-data.pk3dir.git Item stats panel: add cvar to enable/disable it and delay displaying it if it's too far down (like the accuracy panel does) --- diff --git a/_hud_common.cfg b/_hud_common.cfg index 2bcee153c..29c41803f 100644 --- a/_hud_common.cfg +++ b/_hud_common.cfg @@ -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,11 +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_itemstats_filter 1 "filter out less interesting items (ammo and smaller health/armor)" -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_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" diff --git a/qcsrc/client/hud/panel/scoreboard.qc b/qcsrc/client/hud/panel/scoreboard.qc index d7ecff8ae..d02947331 100644 --- a/qcsrc/client/hud/panel/scoreboard.qc +++ b/qcsrc/client/hud/panel/scoreboard.qc @@ -84,8 +84,11 @@ 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; @@ -1664,6 +1667,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) @@ -1946,7 +1985,8 @@ 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 (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); diff --git a/qcsrc/client/mutators/events.qh b/qcsrc/client/mutators/events.qh index c606906ab..cbd2cf31b 100644 --- a/qcsrc/client/mutators/events.qh +++ b/qcsrc/client/mutators/events.qh @@ -178,6 +178,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) \