From ca8fc2877866a3f5521100a84c524baa4e06e496 Mon Sep 17 00:00:00 2001 From: terencehill Date: Mon, 27 Jun 2011 21:04:30 +0200 Subject: [PATCH] Fade out the current msg when an empty msg with the same id arrives --- qcsrc/client/hud.qc | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index 9c5f99366..d671962ca 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -4349,6 +4349,7 @@ void HUD_Physics(void) #define CENTERPRINT_MAX_MSGS 10 #define CENTERPRINT_MAX_ENTRIES 50 +#define CENTERPRINT_FADETIME 0.25 float cpm_index; string centerprint_messages[CENTERPRINT_MAX_MSGS]; float centerprint_msgID[CENTERPRINT_MAX_MSGS]; @@ -4387,15 +4388,22 @@ void centerprint_generic(float new_id, string strMessage, float duration, float if (!centerprint_showing) centerprint_showing = TRUE; - if(duration == 0) - duration = max(1, autocvar_hud_panel_centerprint_time); - for (i=0, j=cpm_index; i time + CENTERPRINT_FADETIME || centerprint_expire_time[j] < time) + centerprint_expire_time[j] = time + CENTERPRINT_FADETIME; + return; + } break; // found a msg with the same id, at position j + } } if (i == CENTERPRINT_MAX_MSGS) @@ -4414,6 +4422,8 @@ void centerprint_generic(float new_id, string strMessage, float duration, float centerprint_time[j] = -1; else { + if(duration == 0) + duration = max(1, autocvar_hud_panel_centerprint_time); centerprint_time[j] = duration; centerprint_expire_time[j] = time + duration; } @@ -4508,7 +4518,7 @@ void HUD_CenterPrint (void) entries = bound(1, floor(panel_size_y/height), CENTERPRINT_MAX_ENTRIES); float i, j, k, n; - float a, sz, fade, align, current_msg_pos_y; + float a, sz, align, current_msg_pos_y; vector pos; string ts; @@ -4517,7 +4527,6 @@ void HUD_CenterPrint (void) pos = panel_pos; if (autocvar_hud_panel_centerprint_flip) pos_y += panel_size_y; - fade = min(autocvar_hud_panel_centerprint_time/8, 0.25); align = bound(0, autocvar_hud_panel_centerprint_align, 1); for (i=0, j=cpm_index; i time) + if (centerprint_time[j] < 0 || centerprint_expire_time[j] - CENTERPRINT_FADETIME > time) { a = 1; sz = 1; } else if (centerprint_expire_time[j] > time) { - a = (centerprint_expire_time[j] - time) / fade; + a = (centerprint_expire_time[j] - time) / CENTERPRINT_FADETIME; sz = 0.8 + a * (1 - 0.8); } -- 2.39.2