]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Create centerprint titles
authorz411 <z411@omaera.org>
Wed, 9 Mar 2022 09:32:45 +0000 (06:32 -0300)
committerz411 <z411@omaera.org>
Wed, 9 Mar 2022 09:33:11 +0000 (06:33 -0300)
hud_luma.cfg
qcsrc/client/announcer.qc
qcsrc/client/hud/panel/centerprint.qc
qcsrc/client/hud/panel/centerprint.qh

index c1f668aaf1c3762ac3ddc55d9bc0e04e44de2998..bd0a1d93cd96730eb7fad6ae0331a1ca9af8e486 100644 (file)
@@ -275,6 +275,7 @@ seta hud_panel_centerprint_align "0.5"
 seta hud_panel_centerprint_flip "0"
 seta hud_panel_centerprint_fontscale "1.4"
 seta hud_panel_centerprint_fontscale_bold "2"
+seta hud_panel_centerprint_fontscale_bold "2.5"
 
 seta hud_panel_minigameboard_pos "0.22 0.15"
 seta hud_panel_minigameboard_size "0.50 0.60"
index 5baaddeffe659fe95552824a287e526088ab7c90..309d4a603a212aa3151533b1290c6e9aea680c8b 100644 (file)
@@ -4,6 +4,7 @@
 #include <client/mutators/_mod.qh>
 #include <common/notifications/all.qh>
 #include <common/stats.qh>
+#include <common/mapinfo.qh>
 
 bool announcer_1min;
 bool announcer_5min;
@@ -26,6 +27,7 @@ void Announcer_Countdown(entity this)
                Local_Notification(MSG_CENTER, CENTER_COUNTDOWN_ROUNDSTOP);
                delete(this);
                announcer_countdown = NULL;
+               centerprint_ClearTitle();
                return;
        }
        if(starttime <= time && roundstarttime != starttime) // game start time has passed
@@ -35,12 +37,15 @@ void Announcer_Countdown(entity this)
        float countdown = (inround ? roundstarttime - time : starttime - time);
        float countdown_rounded = floor(0.5 + countdown);
 
+       if(time >= starttime) centerprint_ClearTitle();
+
        if(countdown <= 0) // countdown has finished, starttime is now
        {
                Local_Notification(MSG_CENTER, CENTER_COUNTDOWN_BEGIN);
                Local_Notification(MSG_MULTI, MULTI_COUNTDOWN_BEGIN);
                delete(this);
                announcer_countdown = NULL;
+               centerprint_ClearTitle();
                return;
        }
        else // countdown is still going
@@ -102,6 +107,10 @@ void Announcer_Gamestart()
                                setthink(announcer_countdown, Announcer_Countdown);
                        }
 
+                       // Set centerprint title
+                       if(time < STAT(GAMESTARTTIME) && !warmup_stage)
+                               centerprint_SetTitle(MapInfo_Type_ToText(gametype));
+
                        if(time + 5.0 < startTime) // if connecting to server while restart was active don't always play prepareforbattle
                        if(time > announcer_countdown.nextthink) // don't play it again if countdown was already going
                                Local_Notification(MSG_ANNCE, ANNCE_PREPARE);
index e8299414ff76c4ca3aee593b0e02a504cfeb08a4..c3022b396f03a741ef74cb664e0cb5d6e6e06b34 100644 (file)
@@ -34,6 +34,7 @@ void HUD_CenterPrint_Export(int fh)
 const int CENTERPRINT_MAX_MSGS = 10;
 const int CENTERPRINT_MAX_ENTRIES = 50;
 const float CENTERPRINT_SPACING = 0.5;
+const float CENTERPRINT_TITLE_SPACING = 1;
 int cpm_index;
 string centerprint_messages[CENTERPRINT_MAX_MSGS];
 int centerprint_msgID[CENTERPRINT_MAX_MSGS];
@@ -43,6 +44,9 @@ float centerprint_expire_time[CENTERPRINT_MAX_MSGS];
 int centerprint_countdown_num[CENTERPRINT_MAX_MSGS];
 bool centerprint_showing;
 
+bool centerprint_title_show;
+string centerprint_title;
+
 void centerprint_Add(int new_id, string strMessage, float duration, int countdown_num)
 {
        TC(int, new_id); TC(int, countdown_num);
@@ -141,6 +145,23 @@ void centerprint_KillAll()
        }
 }
 
+void centerprint_ClearTitle()
+{
+       strfree(centerprint_title);
+       centerprint_title_show = false;
+}
+
+void centerprint_SetTitle(string title)
+{
+       if(title != centerprint_title) {
+               if(centerprint_title)
+                       strfree(centerprint_title);
+
+               centerprint_title = strzone(title);
+               centerprint_title_show = true;
+       }
+}
+
 float hud_configure_cp_generation_time;
 void HUD_CenterPrint()
 {
@@ -148,8 +169,10 @@ void HUD_CenterPrint()
        {
                if(!autocvar_hud_panel_centerprint) return;
 
-               if(hud_configure_prev)
+               if(hud_configure_prev) {
+                       centerprint_ClearTitle();
                        centerprint_KillAll();
+               }
        }
        else
        {
@@ -162,6 +185,8 @@ void HUD_CenterPrint()
                {
                        if(highlightedPanel == HUD_PANEL(CENTERPRINT))
                        {
+                               centerprint_SetTitle(strcat("test", ftos(hud_configure_cp_generation_time)));
+
                                float r;
                                r = random();
                                if (r > 0.8)
@@ -222,7 +247,7 @@ void HUD_CenterPrint()
        }
 
        int i, j, k, n, g;
-       float a, sz, align, current_msg_posY = 0, msg_size;
+       float a = 1, sz, align, current_msg_posY = 0, msg_size;
        vector pos;
        string ts = "";
        bool all_messages_expired = true;
@@ -231,6 +256,22 @@ void HUD_CenterPrint()
        if (autocvar_hud_panel_centerprint_flip)
                pos.y += panel_size.y;
        align = bound(0, autocvar_hud_panel_centerprint_align, 1);
+
+       // Show title if available
+       if(centerprint_title_show) {
+               vector fontsize = hud_fontsize * autocvar_hud_panel_centerprint_fontscale_title;
+
+               pos.x = panel_pos.x + (panel_size.x - stringwidth(centerprint_title, true, fontsize)) * align;
+               drawcolorcodedstring(pos, centerprint_title, fontsize, 1, DRAWFLAG_NORMAL);
+
+               if (autocvar_hud_panel_centerprint_flip)
+                       pos.y -= fontsize.y + CENTERPRINT_TITLE_SPACING;
+               else
+                       pos.y += fontsize.y + CENTERPRINT_TITLE_SPACING;
+
+               all_messages_expired = false;
+       }
+
        for (g=0, i=0, j=cpm_index; i<CENTERPRINT_MAX_MSGS; ++i, ++j)
        {
                if (j == CENTERPRINT_MAX_MSGS)
@@ -268,7 +309,6 @@ void HUD_CenterPrint()
                }
 
                // fade
-               a = 1;
                if(fade_in_time && centerprint_start_time[j] && time < centerprint_start_time[j] + fade_in_time) // Fade in
                        a = (time - centerprint_start_time[j]) / fade_in_time;
                else if(time < centerprint_expire_time[j] - fade_out_time || centerprint_time[j] < 0) // Regularily printed or forced
index a3646f4d17e64ac19fd5d4a105fb329095f2ee4b..ebc12ef59b6391aaec2dc676672491a371723871 100644 (file)
@@ -12,14 +12,18 @@ float autocvar_hud_panel_centerprint_fade_subsequent_passone_minalpha = 0.5;
 float autocvar_hud_panel_centerprint_fade_subsequent_passtwo = 10;
 float autocvar_hud_panel_centerprint_fade_subsequent_passtwo_minalpha = 0.5;
 float autocvar_hud_panel_centerprint_fade_subsequent_minfontsize = 0.75;
-float autocvar_hud_panel_centerprint_fade_minfontsize = 0;
+float autocvar_hud_panel_centerprint_fade_minfontsize = 1;
 bool autocvar_hud_panel_centerprint_flip;
 float autocvar_hud_panel_centerprint_fontscale;
 float autocvar_hud_panel_centerprint_fontscale_bold = 1.4;
-bool autocvar_hud_panel_centerprint_dynamichud  = true;
+float autocvar_hud_panel_centerprint_fontscale_title = 2;
+bool autocvar_hud_panel_centerprint_dynamichud = true;
 float autocvar_hud_panel_centerprint_time;
 
 void centerprint_Add(int new_id, string strMessage, float duration, int countdown_num);
 void centerprint_AddStandard(string strMessage);
 void centerprint_Kill(int id);
 void centerprint_KillAll();
+
+void centerprint_ClearTitle();
+void centerprint_SetTitle(string title);