]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - cl_screen.c
more size_t
[xonotic/darkplaces.git] / cl_screen.c
index ef2bf7800d6cf1d6e9534d179d0891b8f5535eb1..c11c4966231d576a16c57f4354e50caac5761223 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?
@@ -58,7 +58,10 @@ static vec4_t _draw_colors[] =
        {0.0, 0.0, 1.0, 1.0}, // blue
        {0.0, 1.0, 1.0, 1.0}, // cyan
        {1.0, 0.0, 1.0, 1.0}, // magenta
-       {1.0, 1.0, 1.0, 1.0}  // white
+       {1.0, 1.0, 1.0, 1.0}, // white
+       // [515]'s BX_COLOREDTEXT extension
+       {1.0, 1.0, 1.0, 0.5}, // half transparent
+       {0.5, 0.5, 0.5, 1.0}  // half brightness
        // Black's color table
        //{1.0, 1.0, 1.0, 1.0},
        //{1.0, 0.0, 0.0, 1.0},
@@ -70,9 +73,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,21 +84,21 @@ 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 );
+               len = (int)strlen( text );
        else
-               len = min( maxlen, (signed) strlen( text ) );
+               len = min( maxlen, (int) strlen( text ) );
 
        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 +106,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 +117,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 +126,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];
-                               // we jump over the color tag 
+                               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--;
                }
@@ -432,7 +433,7 @@ void R_TimeReport(char *desc)
        t = (int) ((r_timereport_current - r_timereport_temp) * 1000000.0);
 
        dpsnprintf(tempbuf, sizeof(tempbuf), "%8i %s", t, desc);
-       length = strlen(tempbuf);
+       length = (int)strlen(tempbuf);
        while (length < 20)
                tempbuf[length++] = ' ';
        tempbuf[length] = 0;
@@ -609,7 +610,7 @@ void DrawQ_String_Real(float x, float y, const char *string, int maxlen, float s
        if (alpha < (1.0f / 255.0f))
                return;
        if (maxlen < 1)
-               len = strlen(string);
+               len = (int)strlen(string);
        else
                for (len = 0;len < maxlen && string[len];len++);
        for (;len > 0 && string[0] == ' ';string++, x += scalex, len--);