From 5d9cd673687cab5884807f299861b501885c2bae Mon Sep 17 00:00:00 2001 From: terencehill Date: Mon, 7 Mar 2022 15:29:28 +0100 Subject: [PATCH] Fade in centerprint messages that last less than 2 seconds (with default setting only countdown messages last less than 2 seconds) --- _hud_common.cfg | 1 + qcsrc/client/hud/panel/centerprint.qc | 8 ++++++-- qcsrc/client/hud/panel/centerprint.qh | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/_hud_common.cfg b/_hud_common.cfg index 82e5b579a..83eb2490d 100644 --- a/_hud_common.cfg +++ b/_hud_common.cfg @@ -120,6 +120,7 @@ seta hud_panel_infomessages_group_fadetime 0.4 "group message fade in/out time" seta hud_panel_centerprint_time 3 "message duration (NOTE: certain messages have a fixed duration)" seta hud_panel_centerprint_fade_in 0.15 "how long a message takes to fade in" +seta hud_panel_centerprint_fade_in_short 0 " "how long a message that lasts 2 or less seconds takes to fade in" seta hud_panel_centerprint_fade_out 0.15 "how long a message takes to fade out (this time is included in the message duration and can't be > 5)" seta hud_panel_centerprint_fade_subsequent 1 "enable extra fading effects for each additional message, so that the more messages you have the more they become faded out" seta hud_panel_centerprint_fade_subsequent_passone 3 "division factor for the first pass for alpha fading, with 2 all messages after the first have half alpha" diff --git a/qcsrc/client/hud/panel/centerprint.qc b/qcsrc/client/hud/panel/centerprint.qc index 105908094..07a752a8e 100644 --- a/qcsrc/client/hud/panel/centerprint.qc +++ b/qcsrc/client/hud/panel/centerprint.qc @@ -274,11 +274,15 @@ void HUD_CenterPrint() all_messages_expired = false; + float fade_in_time = autocvar_hud_panel_centerprint_fade_in; + if (centerprint_time[j] <= 2) + fade_in_time = autocvar_hud_panel_centerprint_fade_in_short; + // fade if(centerprint_time[j] < 0) // Expired but forced. Expire time is the fade-in time. - a = (time - centerprint_expire_time[j]) / max(0.0001, autocvar_hud_panel_centerprint_fade_in); + a = (time - centerprint_expire_time[j]) / max(0.0001, fade_in_time); else if(centerprint_expire_time[j] - autocvar_hud_panel_centerprint_fade_out > time) // Regularily printed. Not fading out yet. - a = (time - (centerprint_expire_time[j] - centerprint_time[j])) / max(0.0001, autocvar_hud_panel_centerprint_fade_in); + a = (time - (centerprint_expire_time[j] - centerprint_time[j])) / max(0.0001, fade_in_time); else // Expiring soon, so fade it out. a = (centerprint_expire_time[j] - time) / max(0.0001, autocvar_hud_panel_centerprint_fade_out); diff --git a/qcsrc/client/hud/panel/centerprint.qh b/qcsrc/client/hud/panel/centerprint.qh index a143fa0a2..a3646f4d1 100644 --- a/qcsrc/client/hud/panel/centerprint.qh +++ b/qcsrc/client/hud/panel/centerprint.qh @@ -4,6 +4,7 @@ bool autocvar_hud_panel_centerprint; float autocvar_hud_panel_centerprint_align; float autocvar_hud_panel_centerprint_fade_in = 0.15; +float autocvar_hud_panel_centerprint_fade_in_short = 0; float autocvar_hud_panel_centerprint_fade_out = 0.15; float autocvar_hud_panel_centerprint_fade_subsequent = 1; float autocvar_hud_panel_centerprint_fade_subsequent_passone = 3; -- 2.39.2