From e1eda37c6ce797c5580abd5e9049dc84c0d42e06 Mon Sep 17 00:00:00 2001 From: terencehill Date: Mon, 17 May 2021 10:47:43 +0200 Subject: [PATCH] Notify panel: improve scoreboard area detection --- qcsrc/client/hud/hud.qh | 1 - qcsrc/client/hud/panel/notify.qc | 5 ++++- qcsrc/client/hud/panel/scoreboard.qc | 12 +++++++----- qcsrc/client/hud/panel/scoreboard.qh | 5 +++++ 4 files changed, 16 insertions(+), 7 deletions(-) diff --git a/qcsrc/client/hud/hud.qh b/qcsrc/client/hud/hud.qh index 44539f416..a7080f90c 100644 --- a/qcsrc/client/hud/hud.qh +++ b/qcsrc/client/hud/hud.qh @@ -107,7 +107,6 @@ entity highlightedPanel; float highlightedAction; // 0 = nothing, 1 = move, 2 = resize const float BORDER_MULTIPLIER = 4; -float scoreboard_bottom; int weapon_accuracy[REGISTRY_MAX(Weapons)]; entity complain_weapon; diff --git a/qcsrc/client/hud/panel/notify.qc b/qcsrc/client/hud/panel/notify.qc index 1ea81f69d..ae4b92211 100644 --- a/qcsrc/client/hud/panel/notify.qc +++ b/qcsrc/client/hud/panel/notify.qc @@ -69,8 +69,11 @@ void HUD_Notify() float minalpha = 1; if (notify_count == 0) minalpha = 0; // hide if empty - else if(panel_pos.y < scoreboard_bottom) + else if (boxesoverlap(panel_pos, panel_pos + panel_size, + eX * scoreboard_left + eY * scoreboard_top, eX * scoreboard_right + eY * scoreboard_bottom)) + { minalpha = 0.5; // transparent if it may overlap the scoreboard + } float f = max(minalpha, (1 - scoreboard_fade_alpha)); if (f <= 0) return; diff --git a/qcsrc/client/hud/panel/scoreboard.qc b/qcsrc/client/hud/panel/scoreboard.qc index 2f756e4ae..e00343e79 100644 --- a/qcsrc/client/hud/panel/scoreboard.qc +++ b/qcsrc/client/hud/panel/scoreboard.qc @@ -1801,12 +1801,14 @@ void Scoreboard_Draw() float excess = max(0, max_namesize - autocvar_hud_panel_scoreboard_namesize * hud_fontsize.x); float fixed_scoreboard_width = bound(vid_conwidth * autocvar_hud_panel_scoreboard_minwidth, vid_conwidth - excess, vid_conwidth * 0.93); - panel_pos.x = 0.5 * (vid_conwidth - fixed_scoreboard_width); + scoreboard_left = 0.5 * (vid_conwidth - fixed_scoreboard_width); + scoreboard_right = scoreboard_left + fixed_scoreboard_width; + panel_pos.x = scoreboard_left; panel_size.x = fixed_scoreboard_width; Scoreboard_UpdatePlayerTeams(); - float initial_pos_y = panel_pos.y; + scoreboard_top = panel_pos.y; vector pos = panel_pos; entity pl, tm; string str; @@ -2100,12 +2102,12 @@ void Scoreboard_Draw() pos.y += 2 * hud_fontsize.y; if (scoreboard_fade_alpha < 1) - scoreboard_bottom = initial_pos_y + (pos.y - initial_pos_y) * scoreboard_fade_alpha; + scoreboard_bottom = scoreboard_top + (pos.y - scoreboard_top) * scoreboard_fade_alpha; else if (pos.y != scoreboard_bottom) { if (pos.y > scoreboard_bottom) - scoreboard_bottom = min(pos.y, scoreboard_bottom + frametime * 10 * (pos.y - initial_pos_y)); + scoreboard_bottom = min(pos.y, scoreboard_bottom + frametime * 10 * (pos.y - scoreboard_top)); else - scoreboard_bottom = max(pos.y, scoreboard_bottom - frametime * 10 * (pos.y - initial_pos_y)); + scoreboard_bottom = max(pos.y, scoreboard_bottom - frametime * 10 * (pos.y - scoreboard_top)); } } diff --git a/qcsrc/client/hud/panel/scoreboard.qh b/qcsrc/client/hud/panel/scoreboard.qh index 7189143e6..cd43b341e 100644 --- a/qcsrc/client/hud/panel/scoreboard.qh +++ b/qcsrc/client/hud/panel/scoreboard.qh @@ -11,6 +11,11 @@ float scoreboard_fade_alpha; float scoreboard_acc_fade_alpha; float scoreboard_itemstats_fade_alpha; +float scoreboard_top; +float scoreboard_bottom; +float scoreboard_left; +float scoreboard_right; + void Cmd_Scoreboard_SetFields(int argc); void Scoreboard_Draw(); void Scoreboard_InitScores(); -- 2.39.2