+ }
+ if (batchcount > 0)
+ {
+ GL_LockArrays(0, batchcount * 4);
+ R_Mesh_Draw(0, batchcount * 4, batchcount * 2, quadelements);
+ GL_LockArrays(0, 0);
+ }
+}
+
+void DrawQ_String(float x, float y, const char *string, int maxlen, float scalex, float scaley, float red, float green, float blue, float alpha, int flags)
+{
+ float shadow;
+ if (r_textshadow.integer) {
+ shadow = (1-((red+green+blue)));
+ shadow = bound(0, shadow, 1);
+ DrawQ_String_Real(x+scalex*0.25,y+scaley*0.25,string,maxlen,scalex,scaley,shadow,shadow,shadow,alpha*0.8,flags);
+ }
+
+ DrawQ_String_Real(x,y,string,maxlen,scalex,scaley,red,green,blue,alpha,flags);
+}
+
+// color tag printing
+static vec4_t string_colors[] =
+{
+ // Quake3 colors
+ // LordHavoc: why on earth is cyan before magenta in Quake3?
+ // LordHavoc: note: Doom3 uses white for [0] and [7]
+ {0.0, 0.0, 0.0, 1.0}, // black
+ {1.0, 0.0, 0.0, 1.0}, // red
+ {0.0, 1.0, 0.0, 1.0}, // green
+ {1.0, 1.0, 0.0, 1.0}, // yellow
+ {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
+ // [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},
+ //{0.0, 1.0, 0.0, 1.0},
+ //{0.0, 0.0, 1.0, 1.0},
+ //{1.0, 1.0, 0.0, 1.0},
+ //{0.0, 1.0, 1.0, 1.0},
+ //{1.0, 0.0, 1.0, 1.0},
+ //{0.1, 0.1, 0.1, 1.0}
+};
+
+#define STRING_COLORS_COUNT (sizeof(string_colors) / sizeof(vec4_t))
+
+// color is read and changed in the end
+float 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 )
+{
+ vec_t *color;
+ int len;
+ int colorindex;
+ const char *start, *current;
+
+ if( !outcolor || *outcolor == -1 ) {
+ colorindex = STRING_COLOR_DEFAULT;
+ } else {
+ colorindex = *outcolor;
+ }
+ color = string_colors[colorindex];
+
+ if( maxlen < 1)
+ len = (int)strlen( text );
+ else
+ len = min( maxlen, (int) strlen( text ) );
+
+ start = current = text;
+ while( len > 0 ) {
+ // check for color control char
+ if( *current == STRING_COLOR_TAG ) {
+ // get next char
+ current++;
+ len--;
+ if( len == 0 ) {
+ break;
+ }
+ // display the tag char?
+ if( *current == STRING_COLOR_TAG ) {
+ // only display one of the two
+ start = current;
+ // get the next char
+ current++;
+ len--;
+ } else if( '0' <= *current && *current <= '9' ) {
+ colorindex = 0;
+ do {
+ colorindex = colorindex * 10 + (*current - '0');
+ // only read as long as it makes a valid index
+ if( colorindex >= (int)STRING_COLORS_COUNT ) {
+ // undo the last operation
+ colorindex /= 10;
+ break;
+ }
+ current++;
+ len--;
+ } while( len > 0 && '0' <= *current && *current <= '9' );
+ // set the color
+ color = string_colors[colorindex];
+ // we jump over the color tag
+ start = current;