]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Merge branch 'z411/centerprint_fix' into 'master'
authorterencehill <piuntn@gmail.com>
Sat, 9 Apr 2022 10:16:09 +0000 (10:16 +0000)
committerterencehill <piuntn@gmail.com>
Sat, 9 Apr 2022 10:16:09 +0000 (10:16 +0000)
Fixes a few new centerprint issues

Closes #2678

See merge request xonotic/xonotic-data.pk3dir!1001

hud_luma.cfg
hud_luminos.cfg
hud_luminos_minimal.cfg
hud_luminos_minimal_xhair.cfg
hud_luminos_old.cfg
hud_nexuiz.cfg
qcsrc/client/announcer.qc
qcsrc/client/hud/panel/centerprint.qc
qcsrc/client/hud/panel/score.qc
qcsrc/client/hud/panel/scoreboard.qc

index 68cc7625a76a0e3ec47f37b03e56b4099043729e..0903a0584b40b7ed482ec29efc79fbff5ae86966 100644 (file)
@@ -274,8 +274,8 @@ seta hud_panel_centerprint_bg_padding ""
 seta hud_panel_centerprint_align "0.5"
 seta hud_panel_centerprint_flip "0"
 seta hud_panel_centerprint_fontscale "1"
-seta hud_panel_centerprint_fontscale_bold "1.4"
-seta hud_panel_centerprint_fontscale_title "1.8"
+seta hud_panel_centerprint_fontscale_bold "1.2"
+seta hud_panel_centerprint_fontscale_title "1.3"
 
 seta hud_panel_minigameboard_pos "0.22 0.15"
 seta hud_panel_minigameboard_size "0.50 0.60"
index b0e0e409cdb389fdf159b928a800e0b8a48b9eb5..a0849e5aabf9c4c55acf5cd00264f77f6830d5c4 100644 (file)
@@ -274,8 +274,8 @@ seta hud_panel_centerprint_bg_padding ""
 seta hud_panel_centerprint_align "0.5"
 seta hud_panel_centerprint_flip "0"
 seta hud_panel_centerprint_fontscale "1"
-seta hud_panel_centerprint_fontscale_bold "1.4"
-seta hud_panel_centerprint_fontscale_title "1.8"
+seta hud_panel_centerprint_fontscale_bold "1.2"
+seta hud_panel_centerprint_fontscale_title "1.3"
 
 seta hud_panel_minigameboard_pos "0.22 0.15"
 seta hud_panel_minigameboard_size "0.50 0.60"
index 1f2280bc8bd7079bcc9a707ed3d472f4565360a5..3d93b90b38e538724a51ee64d391acb66d3517d8 100644 (file)
@@ -274,8 +274,8 @@ seta hud_panel_centerprint_bg_padding ""
 seta hud_panel_centerprint_align "0.5"
 seta hud_panel_centerprint_flip "0"
 seta hud_panel_centerprint_fontscale "1"
-seta hud_panel_centerprint_fontscale_bold "1.4"
-seta hud_panel_centerprint_fontscale_title "1.8"
+seta hud_panel_centerprint_fontscale_bold "1.2"
+seta hud_panel_centerprint_fontscale_title "1.3"
 
 seta hud_panel_minigameboard_pos "0.22 0.15"
 seta hud_panel_minigameboard_size "0.50 0.60"
index 76377a22de7e9468c5879120e51db744f9414280..c1a69a88ca192f5affc15999e4cbdc6b3ee39114 100644 (file)
@@ -274,8 +274,8 @@ seta hud_panel_centerprint_bg_padding ""
 seta hud_panel_centerprint_align "0.5"
 seta hud_panel_centerprint_flip "0"
 seta hud_panel_centerprint_fontscale "1"
-seta hud_panel_centerprint_fontscale_bold "1.4"
-seta hud_panel_centerprint_fontscale_title "1.8"
+seta hud_panel_centerprint_fontscale_bold "1.2"
+seta hud_panel_centerprint_fontscale_title "1.3"
 
 seta hud_panel_minigameboard_pos "0.22 0.15"
 seta hud_panel_minigameboard_size "0.50 0.60"
index 121f196ddc5bccfd990972d9ccea28c754bd39fa..f0842bc640a3e4d97913886c3031f9cb51dc9607 100644 (file)
@@ -274,8 +274,8 @@ seta hud_panel_centerprint_bg_padding ""
 seta hud_panel_centerprint_align "0.5"
 seta hud_panel_centerprint_flip "0"
 seta hud_panel_centerprint_fontscale "1"
-seta hud_panel_centerprint_fontscale_bold "1.4"
-seta hud_panel_centerprint_fontscale_title "1.8"
+seta hud_panel_centerprint_fontscale_bold "1.2"
+seta hud_panel_centerprint_fontscale_title "1.3"
 
 seta hud_panel_minigameboard_pos "0.22 0.15"
 seta hud_panel_minigameboard_size "0.50 0.60"
index 919ba39a2d8571eef6db3747e11fb91add0f941b..2b035c8a4eccc1b9b25ab3441b4d1c2a151c0844 100644 (file)
@@ -274,8 +274,8 @@ seta hud_panel_centerprint_bg_padding ""
 seta hud_panel_centerprint_align "0.5"
 seta hud_panel_centerprint_flip "0"
 seta hud_panel_centerprint_fontscale "1"
-seta hud_panel_centerprint_fontscale_bold "1.4"
-seta hud_panel_centerprint_fontscale_title "1.8"
+seta hud_panel_centerprint_fontscale_bold "1.2"
+seta hud_panel_centerprint_fontscale_title "1.3"
 
 seta hud_panel_minigameboard_pos "0.22 0.15"
 seta hud_panel_minigameboard_size "0.50 0.60"
index 6a211246f3047bba3b7c49e5f394cebe571f706e..59f977818748240387cc9cca1bc569093a9623d4 100644 (file)
@@ -2,6 +2,7 @@
 
 #include <client/draw.qh>
 #include <client/hud/panel/centerprint.qh>
+#include <client/hud/panel/scoreboard.qh>
 #include <client/mutators/_mod.qh>
 #include <common/notifications/all.qh>
 #include <common/stats.qh>
@@ -20,6 +21,39 @@ string AnnouncerOption()
 
 entity announcer_countdown;
 
+/**
+ * Displays duel title; updates it if the players in-game have changed.
+ */
+string prev_pl1_name;
+string prev_pl2_name;
+void Announcer_Duel()
+{
+       Scoreboard_UpdatePlayerTeams();
+
+       entity pl1 = players.sort_next;
+       entity pl2 = pl1.sort_next;
+       string pl1_name = (pl1 && pl1.team != NUM_SPECTATOR ? entcs_GetName(pl1.sv_entnum) : "???");
+       string pl2_name = (pl2 && pl2.team != NUM_SPECTATOR ? entcs_GetName(pl2.sv_entnum) : "???");
+
+       if(pl1_name == prev_pl1_name && pl2_name == prev_pl2_name)
+               return; // Players haven't changed, stop here
+
+       strcpy(prev_pl1_name, pl1_name);
+       strcpy(prev_pl2_name, pl2_name);
+
+       // There are new duelers, update title
+       float offset = stringwidth(pl2_name, true, hud_fontsize) - stringwidth(pl1_name, true, hud_fontsize) - 1;
+       centerprint_SetTitle(sprintf("^BG%s^BG  %s  %s", pl1_name, _("vs"), pl2_name), offset / 2);
+}
+
+void Announcer_ClearTitle()
+{
+       strfree(prev_pl1_name);
+       strfree(prev_pl2_name);
+       centerprint_ClearTitle();
+}
+
+bool prev_inround;
 void Announcer_Countdown(entity this)
 {
        float starttime = STAT(GAMESTARTTIME);
@@ -29,7 +63,7 @@ void Announcer_Countdown(entity this)
                Local_Notification(MSG_CENTER, CENTER_COUNTDOWN_ROUNDSTOP);
                delete(this);
                announcer_countdown = NULL;
-               centerprint_ClearTitle();
+               Announcer_ClearTitle();
                return;
        }
 
@@ -43,13 +77,14 @@ void Announcer_Countdown(entity this)
                Local_Notification(MSG_MULTI, MULTI_COUNTDOWN_BEGIN);
                delete(this);
                announcer_countdown = NULL;
-               centerprint_ClearTitle();
+               Announcer_ClearTitle();
                return;
        }
        else // countdown is still going
        {
                if(inround)
                {
+                       if(!prev_inround) Announcer_ClearTitle(); // clear title if we just started the match
                        Local_Notification(MSG_CENTER, CENTER_COUNTDOWN_ROUNDSTART, STAT(ROUNDS_PLAYED) + 1, countdown_rounded);
                        Notification annce_num = Announcer_PickNumber(CNT_ROUNDSTART, countdown_rounded);
                        if(annce_num != NULL)
@@ -65,6 +100,8 @@ void Announcer_Countdown(entity this)
                        this.nextthink = (starttime - (countdown - 1));
                }
        }
+
+       prev_inround = inround;
 }
 
 /**
@@ -95,6 +132,9 @@ void Announcer_Gamestart()
                return;
        }
 
+       if(announcer_countdown && gametype.m_1v1)
+               Announcer_Duel();
+
        if(previous_game_starttime != startTime)
        {
                if(time < startTime)
@@ -108,15 +148,7 @@ void Announcer_Gamestart()
                        if(!warmup_stage && time < STAT(GAMESTARTTIME))
                        {
                                if (gametype.m_1v1)
-                               {
-                                       entity pl1 = players.sort_next;
-                                       entity pl2 = pl1.sort_next;
-                                       string pl1_name = (pl1 && pl1.team != NUM_SPECTATOR ? entcs_GetName(pl1.sv_entnum) : "???");
-                                       string pl2_name = (pl2 && pl2.team != NUM_SPECTATOR ? entcs_GetName(pl2.sv_entnum) : "???");
-
-                                       float offset = stringwidth(pl2_name, true, hud_fontsize) - stringwidth(pl1_name, true, hud_fontsize) - 1;
-                                       centerprint_SetTitle(sprintf("^BG%s^BG%s%s", pl1_name, _("  vs  "), pl2_name), offset / 2); // Show duelers in 1v1 game mode
-                               }
+                                       Announcer_Duel();
                                else
                                        centerprint_SetTitle(strcat("^BG", MapInfo_Type_ToText(gametype)), 0); // Show game type as title
 
index 5a18bf388a4422cc60439a6c1642330b3849ca31..307e3c899a52504a30b464dfcd5c3ee45ff70308 100644 (file)
@@ -33,8 +33,8 @@ void HUD_CenterPrint_Export(int fh)
 
 const int CENTERPRINT_MAX_MSGS = 10;
 const int CENTERPRINT_MAX_ENTRIES = 50;
-const float CENTERPRINT_BASE_SIZE = 1.4;
-const float CENTERPRINT_SPACING = 0.5;
+const float CENTERPRINT_BASE_SIZE = 1.3;
+const float CENTERPRINT_SPACING = 0.3;
 const float CENTERPRINT_TITLE_SPACING = 0.35;
 int cpm_index;
 string centerprint_messages[CENTERPRINT_MAX_MSGS];
@@ -86,9 +86,10 @@ void centerprint_Add(int new_id, string strMessage, float duration, int countdow
                        j = 0;
                if (new_id && new_id == centerprint_msgID[j])
                {
-                       if (strMessage == "" && centerprint_messages[j] != "" && centerprint_countdown_num[j] == 0)
+                       if (strMessage == "" && centerprint_messages[j] != "")
                        {
                                // fade out the current msg (duration and countdown_num are ignored)
+                               centerprint_start_time[j] = 0;
                                centerprint_time[j] = min(5, autocvar_hud_panel_centerprint_fade_out);
                                centerprint_expire_time[j] = -1; // don't use the variable time here!
                                return;
@@ -158,10 +159,7 @@ void centerprint_ClearTitle()
 void centerprint_SetTitle(string title, float offset)
 {
        if(title != centerprint_title) {
-               if(centerprint_title)
-                       strfree(centerprint_title);
-
-               centerprint_title = strzone(CCR(title));
+               strcpy(centerprint_title, CCR(title));
                centerprint_title_offset = offset;
        }
 }
@@ -303,7 +301,7 @@ void HUD_CenterPrint()
                }
                if (centerprint_expire_time[j] <= time)
                {
-                       if (centerprint_countdown_num[j] && centerprint_time[j] > 0)
+                       if (centerprint_countdown_num[j] && centerprint_time[j] > 0 && centerprint_start_time[j])
                        {
                                centerprint_countdown_num[j] = centerprint_countdown_num[j] - 1;
                                if (centerprint_countdown_num[j] == 0)
@@ -321,7 +319,7 @@ void HUD_CenterPrint()
                float fade_in_time = autocvar_hud_panel_centerprint_fade_in;
                float fade_out_time = autocvar_hud_panel_centerprint_fade_out;
 
-               if (centerprint_countdown_num[j]) {
+               if (centerprint_countdown_num[j] && centerprint_start_time[j]) {
                        fade_in_time = 0;
                        fade_out_time = 0;
                }
index 24a059a6c9460592fec67b461b411b21c3026fd9..164f60534d5138ee42310131e10af4dc5eb47944 100644 (file)
@@ -77,8 +77,7 @@ void HUD_Score_Rankings(vector pos, vector mySize, entity me)
                return;
        }
 
-       if (!scoreboard_fade_alpha) // the scoreboard too calls Scoreboard_UpdatePlayerTeams
-               Scoreboard_UpdatePlayerTeams();
+       Scoreboard_UpdatePlayerTeams();
        if (team_count)
        {
                // show team scores in the first line
index b3d24e59db7d8d9bd102ff42ce3ca66874380873..ed8715e022909cd1545784a29c222d3d1d130c92 100644 (file)
@@ -209,6 +209,11 @@ void Scoreboard_InitScores()
 //float lastpnum;
 void Scoreboard_UpdatePlayerTeams()
 {
+       static float update_time;
+       if (time <= update_time)
+               return;
+       update_time = time;
+
        entity pl, tmp;
        //int num = 0;
        for(pl = players.sort_next; pl; pl = pl.sort_next)