]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud.qc
Separate minfontsize between subsequent fading and fading in/out effects for centerprints
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud.qc
index 459af161afcabfe128fb0d5ad69afadbd1cde93b..7166a33c5c9393f2835aecc168a5c6b9403d6294 100644 (file)
@@ -1805,52 +1805,51 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s
                        HUD_KillNotify_Push(s1, "", 0, DEATH_GENERIC);
                        if(alsoprint)
                        {
-                           if(gentle)
-                    print (sprintf(_("^1%s^1 ran into a turret\n"), s1));
-                else
-                {                                
-                    switch(type)
-                    {
-                        case DEATH_TURRET_EWHEEL:
-                            print (sprintf(_("^1%s^1 was laserd down by a eWheel turret \n"), s1));
-                            break;
-                        case DEATH_TURRET_FLAC:
-                            print (sprintf(_("^1%s^1 got caught in the flac \n"), s1));
-                            break;
-                        case DEATH_TURRET_MACHINEGUN:
-                            print (sprintf(_("^1%s^1 was riddeld full of riddled by a machinegun turret \n"), s1));
-                            break;
-                        case DEATH_TURRET_WALKER_GUN:
-                            print (sprintf(_("^1%s^1 got served a led enrichment by a walker turret \n"), s1));
-                            break;
-                        case DEATH_TURRET_WALKER_MEELE:
-                            print (sprintf(_("^1%s^1 was impaled by a walker turret \n"), s1));
-                            break;
-                        case DEATH_TURRET_WALKER_ROCKET:
-                            print (sprintf(_("^1%s^1 was rocketed to hell by a walker turret \n"), s1));
-                            break;
-                        case DEATH_TURRET_HELLION:
-                            print (sprintf(_("^1%s^1 was blasted away hellion turret \n"), s1));
-                            break;
-                        case DEATH_TURRET_HK:
-                            print (sprintf(_("^1%s^1 could not hide from the hunter turret \n"), s1));
-                            break;
-                        case DEATH_TURRET_MLRS:
-                            print (sprintf(_("^1%s^1 got turned into smoldering gibs by a mlrs turret \n"), s1));
-                            break;
-                        case DEATH_TURRET_PLASMA:
-                            print (sprintf(_("^1%s^1 got served some superheated plasma from a plasma turret \n"), s1));
-                            break;
-                        case DEATH_TURRET_PHASER:
-                            print (sprintf(_("^1%s^1 was phased out \n"), s1));
-                            break;
-                        case DEATH_TURRET_TESLA:                               
-                            print (sprintf(_("^1%s^1 was electrocuted by a tesla turret \n"), s1));
-                            break;
-                    }
-                }
+                               if(gentle)
+                                       print (sprintf(_("^1%s^1 ran into a turret\n"), s1));
+                               else
+                               {
+                                       switch(type)
+                                       {
+                                               case DEATH_TURRET_EWHEEL:
+                                                       print (sprintf(_("^1%s^1 was laserd down by a eWheel turret \n"), s1));
+                                                       break;
+                                               case DEATH_TURRET_FLAC:
+                                                       print (sprintf(_("^1%s^1 got caught in the flac \n"), s1));
+                                                       break;
+                                               case DEATH_TURRET_MACHINEGUN:
+                                                       print (sprintf(_("^1%s^1 was riddeld full of riddled by a machinegun turret \n"), s1));
+                                                       break;
+                                               case DEATH_TURRET_WALKER_GUN:
+                                                       print (sprintf(_("^1%s^1 got served a led enrichment by a walker turret \n"), s1));
+                                                       break;
+                                               case DEATH_TURRET_WALKER_MEELE:
+                                                       print (sprintf(_("^1%s^1 was impaled by a walker turret \n"), s1));
+                                                       break;
+                                               case DEATH_TURRET_WALKER_ROCKET:
+                                                       print (sprintf(_("^1%s^1 was rocketed to hell by a walker turret \n"), s1));
+                                                       break;
+                                               case DEATH_TURRET_HELLION:
+                                                       print (sprintf(_("^1%s^1 was blasted away hellion turret \n"), s1));
+                                                       break;
+                                               case DEATH_TURRET_HK:
+                                                       print (sprintf(_("^1%s^1 could not hide from the hunter turret \n"), s1));
+                                                       break;
+                                               case DEATH_TURRET_MLRS:
+                                                       print (sprintf(_("^1%s^1 got turned into smoldering gibs by a mlrs turret \n"), s1));
+                                                       break;
+                                               case DEATH_TURRET_PLASMA:
+                                                       print (sprintf(_("^1%s^1 got served some superheated plasma from a plasma turret \n"), s1));
+                                                       break;
+                                               case DEATH_TURRET_PHASER:
+                                                       print (sprintf(_("^1%s^1 was phased out \n"), s1));
+                                                       break;
+                                               case DEATH_TURRET_TESLA:                        
+                                                       print (sprintf(_("^1%s^1 was electrocuted by a tesla turret \n"), s1));
+                                                       break;
+                                       }
+                               }
                        }
-                               
                } else if (type == DEATH_CUSTOM) {
                        HUD_KillNotify_Push(s1, "", 0, DEATH_CUSTOM);
                        if(alsoprint)
@@ -4482,7 +4481,6 @@ float centerprint_msgID[CENTERPRINT_MAX_MSGS];
 float centerprint_time[CENTERPRINT_MAX_MSGS];
 float centerprint_expire_time[CENTERPRINT_MAX_MSGS];
 float centerprint_countdown_num[CENTERPRINT_MAX_MSGS];
-float centerprint_fadetime;
 float centerprint_showing;
 
 void centerprint_generic(float new_id, string strMessage, float duration, float countdown_num)
@@ -4515,8 +4513,6 @@ void centerprint_generic(float new_id, string strMessage, float duration, float
        if (!centerprint_showing)
                centerprint_showing = TRUE;
 
-       centerprint_fadetime = bound(0, autocvar_hud_panel_centerprint_fadetime, 1);
-
        for (i=0, j=cpm_index; i<CENTERPRINT_MAX_MSGS; ++i, ++j)
        {
                if (j == CENTERPRINT_MAX_MSGS)
@@ -4526,9 +4522,9 @@ void centerprint_generic(float new_id, string strMessage, float duration, float
                        if (strMessage == "" && centerprint_messages[j] != "" && centerprint_countdown_num[j] == 0)
                        {
                                // fade out the current msg (duration and countdown_num are ignored)
-                               centerprint_time[j] = centerprint_fadetime;
-                               if (centerprint_expire_time[j] > time + centerprint_fadetime || centerprint_expire_time[j] < time)
-                                       centerprint_expire_time[j] = time + centerprint_fadetime;
+                               centerprint_time[j] = min(5, autocvar_hud_panel_centerprint_fade_out);
+                               if (centerprint_expire_time[j] > time + min(5, autocvar_hud_panel_centerprint_fade_out) || centerprint_expire_time[j] < time)
+                                       centerprint_expire_time[j] = time + min(5, autocvar_hud_panel_centerprint_fade_out);
                                return;
                        }
                        break; // found a msg with the same id, at position j
@@ -4619,9 +4615,14 @@ void HUD_CenterPrint (void)
                if (scoreboard_bottom >= 0.96 * vid_conheight)
                        return;
                vector target_pos;
+               
                target_pos = eY * scoreboard_bottom + eX * 0.5 * (vid_conwidth - panel_size_x);
-               panel_pos = panel_pos + (target_pos - panel_pos) * sqrt(scoreboard_fade_alpha);
-               panel_size_y = min(panel_size_y, vid_conheight - scoreboard_bottom);
+               
+               if(target_pos_y > panel_pos_y)
+               {
+                       panel_pos = panel_pos + (target_pos - panel_pos) * sqrt(scoreboard_fade_alpha);
+                       panel_size_y = min(panel_size_y, vid_conheight - scoreboard_bottom);
+               }
        }
 
        HUD_Panel_DrawBg(1);
@@ -4673,21 +4674,23 @@ void HUD_CenterPrint (void)
                }
                
                // fade the centerprint in/out 
-               if (centerprint_time[j] < 0 || centerprint_expire_time[j] - centerprint_fadetime > time)
-               {
-                       a = bound(0, (time - (centerprint_expire_time[j] - centerprint_time[j])) / centerprint_fadetime, 1);
-               }
+               if (centerprint_time[j] < 0 || 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)
-               {
-                       a = (centerprint_expire_time[j] - time) / centerprint_fadetime;
-               }
+                       a = (centerprint_expire_time[j] - time) / max(0.0001, autocvar_hud_panel_centerprint_fade_out);
+               
+               // 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); 
                
                // also fade it based on positioning
-               a = a * bound(0.5, (1 - (i / 2)), 1); // pass one: all messages after the first have half alpha
-               a = a * bound(0.5, (1 - (i / 10)), 1); // pass two: after that, gradually lower alpha even more for each message
+               if(autocvar_hud_panel_centerprint_fade_subsequent)
+               {
+                       a = a * bound(autocvar_hud_panel_centerprint_fade_subsequent_passone_minalpha, (1 - (i / max(1, autocvar_hud_panel_centerprint_fade_subsequent_passone))), 1); // pass one: all messages after the first have half alpha
+                       a = a * bound(autocvar_hud_panel_centerprint_fade_subsequent_passtwo_minalpha, (1 - (i / max(1, autocvar_hud_panel_centerprint_fade_subsequent_passtwo))), 1); // pass two: after that, gradually lower alpha even more for each message
+               }
                
-               // finally set the size based on the new alpha
-               sz = 0.75 + a * (1 - 0.75); 
+               // finally set the size based on the new alpha from subsequent fading
+               sz = autocvar_hud_panel_centerprint_fade_subsequent_minfontsize + a * (1 - autocvar_hud_panel_centerprint_fade_subsequent_minfontsize); 
                drawfontscale = sz * '1 1 0';
                
                if (centerprint_countdown_num[j])