From 1de531e44cbdb9f653092fff87c6e368d7b84f4e Mon Sep 17 00:00:00 2001 From: havoc Date: Sat, 27 May 2006 20:07:34 +0000 Subject: [PATCH] centering of notify lines in nexuiz now ignores color codes git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@6395 d7cf8633-e32d-0410-b094-e92efae38249 --- console.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/console.c b/console.c index fee68c0e..23b61964 100644 --- a/console.c +++ b/console.c @@ -774,10 +774,27 @@ void Con_DrawNotify (void) text = con_text + (i % con_totallines)*con_linewidth; if (gamemode == GAME_NEXUIZ) { - int linewidth; + int linewidth = 0; + int chars = 0; + int finalchars = 0; + int j; - for (linewidth = con_linewidth; linewidth && text[linewidth-1] == ' '; linewidth--); - x = (vid_conwidth.integer - linewidth * con_textsize.value) * 0.5; + // count up to the last non-whitespace, and ignore color codes + for (j = 0;j < con_linewidth && text[j];j++) + { + if (text[j] == '^' && (text[j+1] >= '0' && text[j+1] <= '9')) + { + j++; + continue; + } + chars++; + if (text[j] == ' ') + continue; + finalchars = chars; + linewidth = j + 1; + } + // center the line using the calculated width + x = (vid_conwidth.integer - finalchars * con_textsize.value) * 0.5; } else x = 0; -- 2.39.2