X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fclient%2Fhud.qc;h=93f1b548cd6acebd8a0341546a62a8274c4fcf20;hb=ee3543c1c14ffc6cd14b6dbd07d76d4cb65e3bd6;hp=d3f24bd831347f0b52f1dac16947dfa3ef97d3ce;hpb=d655a433e8434031ff5665b9306b9a52de26f6bd;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/client/hud.qc b/qcsrc/client/hud.qc index d3f24bd83..93f1b548c 100644 --- a/qcsrc/client/hud.qc +++ b/qcsrc/client/hud.qc @@ -4041,7 +4041,7 @@ float centerprint_showing; void centerprint_generic(float new_id, string strMessage, float duration, float countdown_num) { - //print(sprintf("centerprint_generic(%d, '%s^7', %d, %d);\n", new_id, strMessage, duration, countdown_num)); + //printf("centerprint_generic(%d, '%s^7', %d, %d);\n", new_id, strMessage, duration, countdown_num); float i, j; if(strMessage == "" && new_id == 0) @@ -4207,8 +4207,7 @@ void HUD_CenterPrint (void) float a, sz, align, current_msg_pos_y = 0, msg_size; vector pos; string ts; - - n = -1; // if no msg will be displayed, n stays -1 + float all_messages_expired = TRUE; pos = panel_pos; if (autocvar_hud_panel_centerprint_flip) @@ -4231,16 +4230,20 @@ void HUD_CenterPrint (void) continue; } + all_messages_expired = FALSE; // fade the centerprint_hud in/out - if(centerprint_time[j] < 0) - a = bound(0, (time - centerprint_expire_time[j]) / max(0.0001, autocvar_hud_panel_centerprint_fade_in), 1); - else if(centerprint_expire_time[j] - autocvar_hud_panel_centerprint_fade_out > time) - a = bound(0, (time - (centerprint_expire_time[j] - centerprint_time[j])) / max(0.0001, autocvar_hud_panel_centerprint_fade_in), 1); - else if(centerprint_expire_time[j] > time) + 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); + 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); + else // Expiring soon, so fade it out. a = (centerprint_expire_time[j] - time) / max(0.0001, autocvar_hud_panel_centerprint_fade_out); - else - a = 0; + + if (a <= 0.5/255.0) // Guaranteed invisible - don't show. + continue; + if (a > 1) + a = 1; // set the size from fading in/out before subsequent fading sz = autocvar_hud_panel_centerprint_fade_minfontsize + a * (1 - autocvar_hud_panel_centerprint_fade_minfontsize); @@ -4251,6 +4254,7 @@ void HUD_CenterPrint (void) a = a * bound(autocvar_hud_panel_centerprint_fade_subsequent_passone_minalpha, (1 - (g / max(1, autocvar_hud_panel_centerprint_fade_subsequent_passone))), 1); // pass one: all messages after the first have half theAlpha a = a * bound(autocvar_hud_panel_centerprint_fade_subsequent_passtwo_minalpha, (1 - (g / max(1, autocvar_hud_panel_centerprint_fade_subsequent_passtwo))), 1); // pass two: after that, gradually lower theAlpha even more for each message } + a *= panel_fg_alpha; // finally set the size based on the new theAlpha from subsequent fading sz = sz * (autocvar_hud_panel_centerprint_fade_subsequent_minfontsize + a * (1 - autocvar_hud_panel_centerprint_fade_subsequent_minfontsize)); @@ -4290,7 +4294,8 @@ void HUD_CenterPrint (void) { if (align) pos_x = panel_pos_x + (panel_size_x - stringwidth(ts, TRUE, fontsize)) * align; - drawcolorcodedstring(pos + eY * 0.5 * (1 - sz) * fontsize_y, ts, fontsize, a * panel_fg_alpha, DRAWFLAG_NORMAL); + if (a > 0.5/255.0) // Otherwise guaranteed invisible - don't show. This is checked a second time after some multiplications with other factors were done so temporary changes of these cannot cause flicker. + drawcolorcodedstring(pos + eY * 0.5 * (1 - sz) * fontsize_y, ts, fontsize, a, DRAWFLAG_NORMAL); pos_y += fontsize_y; } else @@ -4327,7 +4332,7 @@ void HUD_CenterPrint (void) } } drawfontscale = '1 1 0'; - if (n == -1) + if (all_messages_expired) { centerprint_showing = FALSE; reset_centerprint_messages();