From: black Date: Sat, 11 Jun 2005 18:49:09 +0000 (+0000) Subject: -The new Key_Event is enabled by default now and Ive added a check so the X-Git-Tag: xonotic-v0.1.0preview~4755 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=987777618ad4de550ec9b6d79570cf282eb31590;p=xonotic%2Fdarkplaces.git -The new Key_Event is enabled by default now and Ive added a check so the console toggle char is only added to the message line or console input if it is the color tag char. -Some name changes of the colored string constants. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@5427 d7cf8633-e32d-0410-b094-e92efae38249 --- diff --git a/cl_screen.c b/cl_screen.c index ef2bf780..861eed77 100644 --- a/cl_screen.c +++ b/cl_screen.c @@ -46,7 +46,7 @@ static void R_Envmap_f (void); void R_ClearScreen(void); // color tag printing -static vec4_t _draw_colors[] = +static vec4_t string_colors[] = { // Quake3 colors // LordHavoc: why on earth is cyan before magenta in Quake3? @@ -70,9 +70,7 @@ static vec4_t _draw_colors[] = //{0.1, 0.1, 0.1, 1.0} }; -#define _draw_colors_count (sizeof(_draw_colors) / sizeof(vec4_t)) -#define _draw_color_tag '^' -#define _draw_color_default 7 +#define STRING_COLORS_COUNT (sizeof(string_colors) / sizeof(vec4_t)) // color is read and changed in the end void DrawQ_ColoredString( float x, float y, const char *text, int maxlen, float scalex, float scaley, float basered, float basegreen, float baseblue, float basealpha, int flags, int *outcolor ) @@ -83,11 +81,11 @@ void DrawQ_ColoredString( float x, float y, const char *text, int maxlen, float const char *start, *current; if( !outcolor || *outcolor == -1 ) { - colorindex = _draw_color_default; + colorindex = STRING_COLOR_DEFAULT; } else { colorindex = *outcolor; } - color = _draw_colors[colorindex]; + color = string_colors[colorindex]; if( maxlen < 1) len = strlen( text ); @@ -97,7 +95,7 @@ void DrawQ_ColoredString( float x, float y, const char *text, int maxlen, float start = current = text; while( len > 0 ) { // check for color control char - if( *current == _draw_color_tag ) { + if( *current == STRING_COLOR_TAG ) { // get next char current++; len--; @@ -105,7 +103,7 @@ void DrawQ_ColoredString( float x, float y, const char *text, int maxlen, float break; } // display the tag char? - if( *current == _draw_color_tag ) { + if( *current == STRING_COLOR_TAG ) { // only display one of the two start = current; // get the next char @@ -116,7 +114,7 @@ void DrawQ_ColoredString( float x, float y, const char *text, int maxlen, float do { colorindex = colorindex * 10 + (*current - '0'); // only read as long as it makes a valid index - if( colorindex >= _draw_colors_count ) { + if( colorindex >= STRING_COLORS_COUNT ) { // undo the last operation colorindex /= 10; break; @@ -125,13 +123,13 @@ void DrawQ_ColoredString( float x, float y, const char *text, int maxlen, float len--; } while( len > 0 && '0' <= *current && *current <= '9' ); // set the color - color = _draw_colors[colorindex]; + color = string_colors[colorindex]; // we jump over the color tag start = current; } } // go on and read normal text in until the next control char - while( len > 0 && *current != _draw_color_tag ) { + while( len > 0 && *current != STRING_COLOR_TAG ) { current++; len--; } diff --git a/cl_screen.h b/cl_screen.h index d9530c1e..50530abd 100644 --- a/cl_screen.h +++ b/cl_screen.h @@ -41,6 +41,11 @@ DRAWFLAG_2XMODULATE, DRAWFLAG_NUMFLAGS }; +// shared color tag printing constants +#define STRING_COLOR_TAG '^' +#define STRING_COLOR_DEFAULT 7 +#define STRING_COLOR_DEFAULT_STR "7" + // clear the draw queue void DrawQ_Clear(void); // draw an image diff --git a/console.c b/console.c index 910038e5..63236dea 100644 --- a/console.c +++ b/console.c @@ -552,8 +552,9 @@ void Con_Print(const char *msg) char *timestamp = timestamps.integer ? Sys_TimeString(timeformat.string) : ""; // reset the color // FIXME: 1. perhaps we should use a terminal system 2. use a constant instead of 7! - line[index++] = '^'; - line[index++] = '7'; + line[index++] = STRING_COLOR_TAG; + // assert( STRING_COLOR_DEFAULT < 10 ) + line[index++] = STRING_COLOR_DEFAULT + '0'; // special color codes for chat messages must always come first // for Con_PrintToHistory to work properly if (*msg <= 2) diff --git a/keys.c b/keys.c index 6e362d16..0739ac71 100644 --- a/keys.c +++ b/keys.c @@ -893,6 +893,9 @@ Key_Event (int key, char ascii, qboolean down) if( !(key_consoleactive && consolekeys[ key ]) && bind && !strncmp( bind, "toggleconsole", strlen( "toggleconsole" ) ) ) { Cbuf_AddText( bind ); Cbuf_AddText( "\n" ); + if( ascii != STRING_COLOR_TAG ) { + return; + } } else { // during demo playback, all keys ingame bring up the main menu if( cls.demoplayback && !key_consoleactive && key_dest == key_game ) { diff --git a/sbar.c b/sbar.c index 13f46e7b..c43e5ef3 100644 --- a/sbar.c +++ b/sbar.c @@ -1179,7 +1179,7 @@ float Sbar_PrintScoreboardItem(scoreboard_t *s, float x, float y) // print the text //DrawQ_String(x, y, va("%c%4i %s", (s - cl.scores) == cl.playerentity - 1 ? 13 : ' ', (int) s->frags, s->name), 0, 8, 8, 1, 1, 1, 1 * sbar_alpha_fg.value, 0); // FIXME: use a constant for this color tag instead - DrawQ_ColoredString(x, y, va("%c%4i %s^7", (s - cl.scores) == cl.playerentity - 1 ? 13 : ' ', (int) s->frags, s->name), 0, 8, 8, 1, 1, 1, 1 * sbar_alpha_fg.value, 0, NULL ); + DrawQ_ColoredString(x, y, va("%c%4i %s^" STRING_COLOR_DEFAULT_STR, (s - cl.scores) == cl.playerentity - 1 ? 13 : ' ', (int) s->frags, s->name), 0, 8, 8, 1, 1, 1, 1 * sbar_alpha_fg.value, 0, NULL ); return 8; }