From 70ebeb95c4b92ca920346f64f39747cd3b5087f4 Mon Sep 17 00:00:00 2001
From: z411 <z411@omaera.org>
Date: Wed, 9 Mar 2022 05:41:21 -0300
Subject: [PATCH] Fix some centerprint mess

---
 _hud_common.cfg                       |  4 +--
 _hud_descriptions.cfg                 |  1 +
 hud_luma.cfg                          |  4 +--
 qcsrc/client/hud/panel/centerprint.qc | 37 +++++++++++++--------------
 qcsrc/common/notifications/all.inc    |  2 +-
 5 files changed, 24 insertions(+), 24 deletions(-)

diff --git a/_hud_common.cfg b/_hud_common.cfg
index 83eb2490dc..82146b562c 100644
--- a/_hud_common.cfg
+++ b/_hud_common.cfg
@@ -119,7 +119,7 @@ seta hud_panel_infomessages_group_time 6 "number of seconds a message of a group
 seta hud_panel_infomessages_group_fadetime 0.4 "group message fade in/out time"
 
 seta hud_panel_centerprint_time 3 "message duration (NOTE: certain messages have a fixed duration)"
-seta hud_panel_centerprint_fade_in 0.15 "how long a message takes to fade in"
+seta hud_panel_centerprint_fade_in 0 "how long a message takes to fade in"
 seta hud_panel_centerprint_fade_in_short 0 " "how long a message that lasts 2 or less seconds takes to fade in"
 seta hud_panel_centerprint_fade_out 0.15 "how long a message takes to fade out (this time is included in the message duration and can't be > 5)"
 seta hud_panel_centerprint_fade_subsequent 1 "enable extra fading effects for each additional message, so that the more messages you have the more they become faded out"
@@ -128,7 +128,7 @@ seta hud_panel_centerprint_fade_subsequent_passone_minalpha 0.5 "minimum factor
 seta hud_panel_centerprint_fade_subsequent_passtwo 10 "division factor for the second pass for alpha fading, it applies another fade on top of the first pass to make it more transitioned"
 seta hud_panel_centerprint_fade_subsequent_passtwo_minalpha 0.5 "minimum factor that the second pass can fade to"
 seta hud_panel_centerprint_fade_subsequent_minfontsize 0.75 "minimum factor for the font size from the subsequent fading effects"
-seta hud_panel_centerprint_fade_minfontsize 0 "minimum factor for the font size from the fading in/out effects"
+seta hud_panel_centerprint_fade_minfontsize 1 "minimum factor for the font size from the fading in/out effects"
 
 seta hud_panel_scoreboard_namesize 15 "size limit of player names and relative column (multiplied by fontsize)"
 seta hud_panel_scoreboard_maxheight 0.6 "max height of the scoreboard; a few players that wouldn't fit into the scoreboard are listed in the last row"
diff --git a/_hud_descriptions.cfg b/_hud_descriptions.cfg
index 185eb5c21e..545e0b92b5 100644
--- a/_hud_descriptions.cfg
+++ b/_hud_descriptions.cfg
@@ -274,6 +274,7 @@ seta hud_panel_centerprint_align "" "text alignment: 0 left, 0.5 center, 1 right
 seta hud_panel_centerprint_flip "" "invert messages order"
 seta hud_panel_centerprint_fontscale "" "scale the text font by this amount"
 seta hud_panel_centerprint_fontscale_bold "" "scale the bold text font by this amount"
+seta hud_panel_centerprint_fontscale_title "" "scale the title text font by this amount"
 
 seta hud_panel_minigameboard_pos "" "position of this panel"
 seta hud_panel_minigameboard_size "" "size of this panel"
diff --git a/hud_luma.cfg b/hud_luma.cfg
index 36f91775c0..c1f668aaf1 100644
--- a/hud_luma.cfg
+++ b/hud_luma.cfg
@@ -273,8 +273,8 @@ seta hud_panel_centerprint_bg_border ""
 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 "1.4"
+seta hud_panel_centerprint_fontscale_bold "2"
 
 seta hud_panel_minigameboard_pos "0.22 0.15"
 seta hud_panel_minigameboard_size "0.50 0.60"
diff --git a/qcsrc/client/hud/panel/centerprint.qc b/qcsrc/client/hud/panel/centerprint.qc
index 08fe3e65c3..e8299414ff 100644
--- a/qcsrc/client/hud/panel/centerprint.qc
+++ b/qcsrc/client/hud/panel/centerprint.qc
@@ -33,7 +33,7 @@ void HUD_CenterPrint_Export(int fh)
 
 const int CENTERPRINT_MAX_MSGS = 10;
 const int CENTERPRINT_MAX_ENTRIES = 50;
-const float CENTERPRINT_SPACING = 0.7;
+const float CENTERPRINT_SPACING = 0.5;
 int cpm_index;
 string centerprint_messages[CENTERPRINT_MAX_MSGS];
 int centerprint_msgID[CENTERPRINT_MAX_MSGS];
@@ -167,10 +167,11 @@ void HUD_CenterPrint()
 				if (r > 0.8)
 					centerprint_Add(floor(r*1000), sprintf(_("^3Countdown message at time %s, seconds left: ^COUNT"), seconds_tostring(time)), 1, 10);
 				else if (r > 0.55)
-					centerprint_Add(0, sprintf(_("^1Multiline message at time %s that\n^1lasts longer than normal"), seconds_tostring(time)), 20, 0);
+					centerprint_Add(0, sprintf(_("^1Multiline message at time %s that\n^BOLDlasts longer than normal"), seconds_tostring(time)), 20, 0);
 				else
 					centerprint_AddStandard(sprintf(_("Message at time %s"), seconds_tostring(time)));
-				hud_configure_cp_generation_time = time + 1 + random()*4;
+				//hud_configure_cp_generation_time = time + 1 + random()*4;
+				hud_configure_cp_generation_time = time + 1;
 			}
 			else
 			{
@@ -261,8 +262,10 @@ 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_time[j] == 1)
+		if (centerprint_countdown_num[j]) {
 			fade_in_time = autocvar_hud_panel_centerprint_fade_in_short;
+			fade_out_time = 0;
+		}
 
 		// fade
 		a = 1;
@@ -275,8 +278,6 @@ void HUD_CenterPrint()
 
 		if(centerprint_msgID[j] == ORDINAL(CPID_TIMEIN))
 			a = 1;
-		if(centerprint_countdown_num[j])
-			a = 1;
 
 		// while counting down show it anyway in order to hold the current message position
 		if (a <= 0.5/255.0 && centerprint_countdown_num[j] == 0)  // Guaranteed invisible - don't show.
@@ -296,7 +297,9 @@ void HUD_CenterPrint()
 		a *= panel_fg_alpha;
 
 		// 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));
+		// TODO: Apply this only if subsequent, otherwise it fucks it up
+		if(g)
+			sz = sz * (autocvar_hud_panel_centerprint_fade_subsequent_minfontsize + a * (1 - autocvar_hud_panel_centerprint_fade_subsequent_minfontsize));
 		drawfontscale = hud_scale * sz;
 
 		if (centerprint_countdown_num[j])
@@ -314,6 +317,7 @@ void HUD_CenterPrint()
 				{
 					bool is_bold = (substring(getWrappedLine_remaining, 0, 5) == BOLD_OPERATOR);
 					vector fontsize = hud_fontsize * (is_bold ? autocvar_hud_panel_centerprint_fontscale_bold : autocvar_hud_panel_centerprint_fontscale);
+
 					ts = getWrappedLine(panel_size.x * hud_scale.x * sz, fontsize, stringwidth_colors);
 					if (ts != "")
 						pos.y -= fontsize.y;
@@ -331,14 +335,14 @@ void HUD_CenterPrint()
 
 			bool is_bold = (substring(getWrappedLine_remaining, 0, 5) == BOLD_OPERATOR);
 			vector fontsize = hud_fontsize * (is_bold ? autocvar_hud_panel_centerprint_fontscale_bold : autocvar_hud_panel_centerprint_fontscale);
+			if (is_bold)
+				getWrappedLine_remaining = substring(getWrappedLine_remaining, 5, -1);
 
 			while(getWrappedLine_remaining)
 			{
 				ts = getWrappedLine(panel_size.x * hud_scale.x * sz, fontsize, stringwidth_colors);
 				if (ts != "")
 				{
-					if (is_bold)
-						ts = substring(ts, 5, -1);
 					if (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.
@@ -352,18 +356,15 @@ void HUD_CenterPrint()
 			}
 		}
 
-		float height_used = pos.y - msg_size;
-
 		++g; // move next position number up
 
 		msg_size = pos.y - msg_size;
+
 		if (autocvar_hud_panel_centerprint_flip)
 		{
-			pos.y += height_used;
-			//pos.y = current_msg_posY - CENTERPRINT_SPACING * fontsize.y;
+			pos.y -= msg_size + CENTERPRINT_SPACING * hud_fontsize.y;
 			if (a < 1 && centerprint_msgID[j] == 0) // messages with id can be replaced just after they are faded out, so never move over them the next messages
-				//pos.y += (msg_size + CENTERPRINT_SPACING * fontsize.y) * (1 - sqrt(sz));
-				pos.y += height_used * (1 - sqrt(sz));
+				pos.y += (1 - sqrt(a));
 
 			if (pos.y < panel_pos.y) // check if the next message can be shown
 			{
@@ -373,11 +374,9 @@ void HUD_CenterPrint()
 		}
 		else
 		{
-			//pos.y += CENTERPRINT_SPACING * fontsize.y;
-			pos.y += height_used;
+			pos.y += CENTERPRINT_SPACING * hud_fontsize.y;
 			if (a < 1 && centerprint_msgID[j] == 0) // messages with id can be replaced just after they are faded out, so never move over them the next messages
-				//pos.y -= (msg_size + CENTERPRINT_SPACING * fontsize.y) * (1 - sqrt(sz));
-				pos.y -= height_used * (1 - sqrt(sz));
+				pos.y -= (1 - sqrt(a));
 
 			if(pos.y > panel_pos.y + panel_size.y - hud_fontsize.y) // check if the next message can be shown
 			{
diff --git a/qcsrc/common/notifications/all.inc b/qcsrc/common/notifications/all.inc
index 33fbee3bd8..ef68e00a3a 100644
--- a/qcsrc/common/notifications/all.inc
+++ b/qcsrc/common/notifications/all.inc
@@ -526,7 +526,7 @@ string multiteam_info_sprintf(string input, string teamname) { return ((input !=
     MSG_CENTER_NOTIF(ASSAULT_DEFENDING,                 N_ENABLE,    0, 0, "",               CPID_ASSAULT_ROLE,      "0 0",  _("^BGYou are defending!"), "")
     MSG_CENTER_NOTIF(ASSAULT_OBJ_DESTROYED,             N_ENABLE,    0, 1, "f1time",         CPID_ASSAULT_ROLE,      "0 0",  _("^BGObjective destroyed in ^F4%s^BG!"), "")
 
-    MSG_CENTER_NOTIF(COUNTDOWN_BEGIN,                   N_ENABLE,    0, 0, "",               CPID_ROUND,             "2 0",  _("^F4Begin!"), "")
+    MSG_CENTER_NOTIF(COUNTDOWN_BEGIN,                   N_ENABLE,    0, 0, "",               CPID_ROUND,             "2 0",  _("^BOLDBegin!"), "")
     MSG_CENTER_NOTIF(COUNTDOWN_GAMESTART,               N_ENABLE,    0, 1, "",               CPID_ROUND,             "1 f1", _("^BGGame starts in\n^BOLD^COUNT"), "")
     MSG_CENTER_NOTIF(COUNTDOWN_ROUNDSTART,              N_ENABLE,    0, 1, "",               CPID_ROUND,             "1 f1", _("^BGRound starts in\n^BOLD^COUNT"), "")
     MSG_CENTER_NOTIF(COUNTDOWN_ROUNDSTOP,               N_ENABLE,    0, 0, "",               CPID_ROUND,             "2 0",  _("^F4Round cannot start"), "")
-- 
2.39.5