X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fclient%2Fhud%2Fpanel%2Fnotify.qc;h=2f1b254b23fe9712df41297104e02fd69fdecb28;hb=69265650c1b6f1193cf02c99baccb28c0db913ed;hp=d132ed44b0c35ee25406248d28f110d91196482f;hpb=d1179864ddf7821d800884ce58b57d206f68f761;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/client/hud/panel/notify.qc b/qcsrc/client/hud/panel/notify.qc index d132ed44b..2f1b254b2 100644 --- a/qcsrc/client/hud/panel/notify.qc +++ b/qcsrc/client/hud/panel/notify.qc @@ -1,9 +1,21 @@ #include "notify.qh" -#include "scoreboard.qh" +#include +#include +#include // Notifications (#4) +void HUD_Notify_Export(int fh) +{ + // allow saving cvars that aesthetically change the panel into hud skin files + HUD_Write_Cvar("hud_panel_notify_flip"); + HUD_Write_Cvar("hud_panel_notify_fontsize"); + HUD_Write_Cvar("hud_panel_notify_time"); + HUD_Write_Cvar("hud_panel_notify_fadetime"); + HUD_Write_Cvar("hud_panel_notify_icon_aspect"); +} + void HUD_Notify_Push(string icon, string attacker, string victim) { if (icon == "") @@ -46,22 +58,36 @@ void HUD_Notify_Push(string icon, string attacker, string victim) void HUD_Notify() { - if (!autocvar__hud_configure) - if (!autocvar_hud_panel_notify) + if (!autocvar__hud_configure && !autocvar_hud_panel_notify) + return; + + HUD_Panel_LoadCvars(); + + if (scoreboard_fade_alpha) + { + float minalpha = 1; + if (notify_count == 0) + minalpha = 0; // hide if empty + 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; + panel_bg_alpha *= f; + panel_fg_alpha *= f; + } - if(1 - scoreboard_fade_alpha <= 0) - return; - HUD_Panel_UpdateCvars(1 - scoreboard_fade_alpha); if (autocvar_hud_panel_notify_dynamichud) HUD_Scale_Enable(); else HUD_Scale_Disable(); HUD_Panel_DrawBg(); - if (!autocvar__hud_configure) - if (notify_count == 0) - return; + if (!autocvar__hud_configure && notify_count == 0) + return; vector pos, size; pos = panel_pos; @@ -74,6 +100,8 @@ void HUD_Notify() } float fade_start = max(0, autocvar_hud_panel_notify_time); + if (intermission) // fade out in half the time + fade_start -= (time - intermission_time); float fade_time = max(0, autocvar_hud_panel_notify_fadetime); float icon_aspect = max(1, autocvar_hud_panel_notify_icon_aspect); @@ -85,7 +113,7 @@ void HUD_Notify() float name_maxwidth = panel_width_half - icon_width_half - size.x * NOTIFY_ICON_MARGIN; vector font_size = '0.5 0.5 0' * entry_height * autocvar_hud_panel_notify_fontsize; - vector icon_size = (eX * icon_aspect + eY) * entry_height; + vector icon_size = vec2(icon_aspect, 1) * entry_height; vector icon_left = eX * (panel_width_half - icon_width_half); vector attacker_right = eX * name_maxwidth; vector victim_left = eX * (size.x - name_maxwidth); @@ -116,7 +144,7 @@ void HUD_Notify() { attacker = sprintf(_("Player %d"), count + 1); victim = sprintf(_("Player %d"), count + 2); - icon = Weapons_from(min(WEP_FIRST + count * 2, WEP_LAST)).model2; + icon = REGISTRY_GET(Weapons, min(WEP_FIRST + count * 2, WEP_LAST)).model2; alpha = bound(0, 1.2 - count / entry_count, 1); } else @@ -147,13 +175,13 @@ void HUD_Notify() icon_pos = pos + icon_left + eY * i * entry_height; drawpic_aspect_skin(icon_pos, icon, icon_size, '1 1 1', panel_fg_alpha * alpha, DRAWFLAG_NORMAL); - victim = textShortenToWidth(victim, name_maxwidth, font_size, stringwidth_colors); + victim = textShortenToWidth(ColorTranslateRGB(victim), name_maxwidth, font_size, stringwidth_colors); victim_pos = pos + victim_left + name_top; drawcolorcodedstring(victim_pos, victim, font_size, panel_fg_alpha * alpha, DRAWFLAG_NORMAL); if (attacker != "") { - attacker = textShortenToWidth(attacker, name_maxwidth, font_size, stringwidth_colors); + attacker = textShortenToWidth(ColorTranslateRGB(attacker), name_maxwidth, font_size, stringwidth_colors); attacker_pos = pos + attacker_right - eX * stringwidth(attacker, true, font_size) + name_top; drawcolorcodedstring(attacker_pos, attacker, font_size, panel_fg_alpha * alpha, DRAWFLAG_NORMAL); }