]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
-The new Key_Event is enabled by default now and Ive added a check so the
authorblack <black@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 11 Jun 2005 18:49:09 +0000 (18:49 +0000)
committerblack <black@d7cf8633-e32d-0410-b094-e92efae38249>
Sat, 11 Jun 2005 18:49:09 +0000 (18:49 +0000)
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

cl_screen.c
cl_screen.h
console.c
keys.c
sbar.c

index ef2bf7800d6cf1d6e9534d179d0891b8f5535eb1..861eed77ccf6b58959142ea896573e859b682d71 100644 (file)
@@ -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--;
                }
index d9530c1eb8026422a8f405d77849ea6b0081efd1..50530abd73cb7c2618fa767e1d3ea8528772b313 100644 (file)
@@ -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
index 910038e5f1f514379c61112642b647fe5b13198e..63236dea7045cc6762ebba87815603ca11d5bf81 100644 (file)
--- 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 6e362d16f4e3f01563b65211c2e154ca1c900bed..0739ac71ce090f5df6ca2a99e428f3351c5732bf 100644 (file)
--- 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 13f46e7b35ca1c3bf26d3d23adc7dcf755ea045f..c43e5ef3420b45c86fabfcfc1601a584d830b250 100644 (file)
--- 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;
 }