]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/client/hud/panel/centerprint.qc
Make the scoreboard a panel
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / hud / panel / centerprint.qc
index 3169d925d24193c34502ed05cfe349d76a66eb38..7dfaa909e3ae7760ec9af933852354222adf437e 100644 (file)
@@ -1,3 +1,7 @@
+#include "centerprint.qh"
+
+#include <client/scoreboard.qh>
+
 // CenterPrint (#16)
 
 const int CENTERPRINT_MAX_MSGS = 10;
@@ -13,6 +17,7 @@ bool centerprint_showing;
 
 void centerprint_generic(int new_id, string strMessage, float duration, int countdown_num)
 {
+    TC(int, new_id); TC(int, countdown_num);
        //printf("centerprint_generic(%d, '%s^7', %d, %d);\n", new_id, strMessage, duration, countdown_num);
        int i, j;
 
@@ -87,6 +92,12 @@ void centerprint_generic(int new_id, string strMessage, float duration, int coun
        centerprint_countdown_num[j] = countdown_num;
 }
 
+void centerprint_kill(int id)
+{
+    TC(int, id);
+       centerprint_generic(id, "", 0, 0);
+}
+
 void centerprint_hud(string strMessage)
 {
        centerprint_generic(0, strMessage, autocvar_hud_panel_centerprint_time, 0);
@@ -94,8 +105,7 @@ void centerprint_hud(string strMessage)
 
 void reset_centerprint_messages()
 {
-       int i;
-       for (i=0; i<CENTERPRINT_MAX_MSGS; ++i)
+       for (int i=0; i<CENTERPRINT_MAX_MSGS; ++i)
        {
                centerprint_expire_time[i] = 0;
                centerprint_time[i] = 1;
@@ -118,7 +128,10 @@ void HUD_CenterPrint ()
        else
        {
                if(!hud_configure_prev)
+               {
                        reset_centerprint_messages();
+                       hud_configure_cp_generation_time = time; // show a message immediately
+               }
                if (time > hud_configure_cp_generation_time)
                {
                        if(highlightedPanel == HUD_PANEL(CENTERPRINT))
@@ -142,13 +155,14 @@ void HUD_CenterPrint ()
        }
 
        // this panel fades only when the menu does
-       float hud_fade_alpha_save = 0;
-       if(scoreboard_fade_alpha)
-       {
-               hud_fade_alpha_save = hud_fade_alpha;
+       float hud_fade_alpha_save = hud_fade_alpha;
+       if(menu_enabled == 1)
+               hud_fade_alpha = 1;
+       else
                hud_fade_alpha = 1 - autocvar__menu_alpha;
-       }
+
        HUD_Panel_UpdateCvars();
+       hud_fade_alpha = hud_fade_alpha_save;
 
        if ( HUD_Radar_Clickable() )
        {
@@ -158,17 +172,13 @@ void HUD_CenterPrint ()
                panel_pos = eY * hud_panel_radar_bottom + eX * 0.5 * (vid_conwidth - panel_size_x);
                panel_size_y = min(panel_size_y, vid_conheight - hud_panel_radar_bottom);
        }
-       else if(scoreboard_fade_alpha)
+       else if(!autocvar__hud_configure && scoreboard_fade_alpha)
        {
-               hud_fade_alpha = hud_fade_alpha_save;
-
                // move the panel below the scoreboard
                if (scoreboard_bottom >= 0.96 * vid_conheight)
                        return;
                vector target_pos;
-
                target_pos = eY * scoreboard_bottom + eX * 0.5 * (vid_conwidth - panel_size.x);
-
                if(target_pos.y > panel_pos.y)
                {
                        panel_pos = panel_pos + (target_pos - panel_pos) * sqrt(scoreboard_fade_alpha);
@@ -176,6 +186,10 @@ void HUD_CenterPrint ()
                }
        }
 
+       if (autocvar_hud_panel_centerprint_dynamichud)
+               HUD_Scale_Enable();
+       else
+               HUD_Scale_Disable();
        HUD_Panel_DrawBg(1);
 
        if (!centerprint_showing)
@@ -246,14 +260,16 @@ void HUD_CenterPrint ()
                // also fade it based on positioning
                if(autocvar_hud_panel_centerprint_fade_subsequent)
                {
-                       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
+                       // pass one: all messages after the first have half alpha
+                       a = a * bound(autocvar_hud_panel_centerprint_fade_subsequent_passone_minalpha, (1 - (g / max(1, autocvar_hud_panel_centerprint_fade_subsequent_passone))), 1);
+                       // pass two: after that, gradually lower alpha even more for each message
+                       a = a * bound(autocvar_hud_panel_centerprint_fade_subsequent_passtwo_minalpha, (1 - (g / max(1, autocvar_hud_panel_centerprint_fade_subsequent_passtwo))), 1);
                }
                a *= panel_fg_alpha;
 
-               // finally set the size based on the new theAlpha from subsequent fading
+               // finally set the size based on the new alpha from subsequent fading
                sz = sz * (autocvar_hud_panel_centerprint_fade_subsequent_minfontsize + a * (1 - autocvar_hud_panel_centerprint_fade_subsequent_minfontsize));
-               drawfontscale = sz * '1 1 0';
+               drawfontscale = hud_scale * sz;
 
                if (centerprint_countdown_num[j])
                        n = tokenizebyseparator(strreplace("^COUNT", count_seconds(centerprint_countdown_num[j]), centerprint_messages[j]), "\n");
@@ -268,7 +284,7 @@ void HUD_CenterPrint ()
                                getWrappedLine_remaining = argv(k);
                                while(getWrappedLine_remaining)
                                {
-                                       ts = getWrappedLine(panel_size.x * sz, fontsize, stringwidth_colors);
+                                       ts = getWrappedLine(panel_size.x * hud_scale.x * sz, fontsize, stringwidth_colors);
                                        if (ts != "")
                                                pos.y -= fontsize.y;
                                        else
@@ -284,13 +300,13 @@ void HUD_CenterPrint ()
                        getWrappedLine_remaining = argv(k);
                        while(getWrappedLine_remaining)
                        {
-                               ts = getWrappedLine(panel_size.x * sz, fontsize, stringwidth_colors);
+                               ts = getWrappedLine(panel_size.x * hud_scale.x * sz, fontsize, stringwidth_colors);
                                if (ts != "")
                                {
                                        if (align)
-                                               pos.x = panel_pos.x + (panel_size.x - stringwidth(ts, true, fontsize)) * align;
+                                               pos.x = panel_pos.x + (panel_size.x - stringwidth(ts, true, fontsize) * sz) * align;
                                        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);
+                                               drawcolorcodedstring(pos + eY * 0.5 * (1 - sz * hud_scale.x) * fontsize.y, ts, fontsize, a, DRAWFLAG_NORMAL);
                                        pos.y += fontsize.y;
                                }
                                else
@@ -309,7 +325,7 @@ void HUD_CenterPrint ()
 
                        if (pos.y < panel_pos.y) // check if the next message can be shown
                        {
-                               drawfontscale = '1 1 0';
+                               drawfontscale = hud_scale;
                                return;
                        }
                }
@@ -321,12 +337,12 @@ void HUD_CenterPrint ()
 
                        if(pos.y > panel_pos.y + panel_size.y - fontsize.y) // check if the next message can be shown
                        {
-                               drawfontscale = '1 1 0';
+                               drawfontscale = hud_scale;
                                return;
                        }
                }
        }
-       drawfontscale = '1 1 0';
+       drawfontscale = hud_scale;
        if (all_messages_expired)
        {
                centerprint_showing = false;