+ x = startx;
+ y = starty;
+ if (shadow)
+ {
+ x += r_textshadow.value;
+ y += r_textshadow.value;
+ }
+ for (i = 0;i < maxlen && text[i];i++)
+ {
+ if (text[i] == ' ')
+ {
+ x += fnt->width_of[(int) ' '] * w;
+ continue;
+ }
+ if (text[i] == STRING_COLOR_TAG && !ignorecolorcodes && i + 1 < maxlen)
+ {
+ ch = text[++i];
+ if (ch <= '9' && ch >= '0') // ^[0-9] found
+ {
+ colorindex = ch - '0';
+ DrawQ_GetTextColor(color, colorindex, basered, basegreen, baseblue, basealpha, shadow);
+ continue;
+ }
+ else if (ch == STRING_COLOR_RGB_TAG_CHAR && i+3 < maxlen ) // ^x found
+ {
+ // building colorindex...
+ ch = tolower(text[i+1]);
+ tempcolorindex = 0x10000; // binary: 1,0000,0000,0000,0000
+ if (ch <= '9' && ch >= '0') tempcolorindex |= (ch - '0') << 12;
+ else if (ch >= 'a' && ch <= 'f') tempcolorindex |= (ch - 87) << 12;
+ else tempcolorindex = 0;
+ if (tempcolorindex)
+ {
+ ch = tolower(text[i+2]);
+ if (ch <= '9' && ch >= '0') tempcolorindex |= (ch - '0') << 8;
+ else if (ch >= 'a' && ch <= 'f') tempcolorindex |= (ch - 87) << 8;
+ else tempcolorindex = 0;
+ if (tempcolorindex)
+ {
+ ch = tolower(text[i+3]);
+ if (ch <= '9' && ch >= '0') tempcolorindex |= (ch - '0') << 4;
+ else if (ch >= 'a' && ch <= 'f') tempcolorindex |= (ch - 87) << 4;
+ else tempcolorindex = 0;
+ if (tempcolorindex)
+ {
+ colorindex = tempcolorindex | 0xf;
+ // ...done! now colorindex has rgba codes (1,rrrr,gggg,bbbb,aaaa)
+ //Con_Printf("^1colorindex:^7 %x\n", colorindex);
+ DrawQ_GetTextColor(color, colorindex, basered, basegreen, baseblue, basealpha, shadow);
+ i+=3;
+ continue;
+ }
+ }
+ }
+ }
+ else if (ch == STRING_COLOR_TAG)
+ i++;
+ i--;
+ }
+ num = (unsigned char) text[i];
+ thisw = fnt->width_of[num];
+ // FIXME make these smaller to just include the occupied part of the character for slightly faster rendering
+ s = (num & 15)*0.0625f + (0.5f / tw);
+ t = (num >> 4)*0.0625f + (0.5f / th);
+ u = 0.0625f * thisw - (1.0f / tw);
+ v = 0.0625f - (1.0f / th);
+ ac[ 0] = color[0];ac[ 1] = color[1];ac[ 2] = color[2];ac[ 3] = color[3];
+ ac[ 4] = color[0];ac[ 5] = color[1];ac[ 6] = color[2];ac[ 7] = color[3];
+ ac[ 8] = color[0];ac[ 9] = color[1];ac[10] = color[2];ac[11] = color[3];
+ ac[12] = color[0];ac[13] = color[1];ac[14] = color[2];ac[15] = color[3];
+ at[ 0] = s ; at[ 1] = t ;
+ at[ 2] = s+u ; at[ 3] = t ;
+ at[ 4] = s+u ; at[ 5] = t+v ;
+ at[ 6] = s ; at[ 7] = t+v ;
+ av[ 0] = x ; av[ 1] = y ; av[ 2] = 10;
+ av[ 3] = x+w*thisw ; av[ 4] = y ; av[ 5] = 10;
+ av[ 6] = x+w*thisw ; av[ 7] = y+h ; av[ 8] = 10;
+ av[ 9] = x ; av[10] = y+h ; av[11] = 10;
+ ac += 16;
+ at += 8;
+ av += 12;
+ batchcount++;
+ if (batchcount >= QUADELEMENTS_MAXQUADS)
+ {
+ GL_LockArrays(0, batchcount * 4);
+ R_Mesh_Draw(0, batchcount * 4, 0, batchcount * 2, NULL, quadelements, 0, 0);
+ GL_LockArrays(0, 0);
+ batchcount = 0;
+ ac = color4f;
+ at = texcoord2f;
+ av = vertex3f;
+ }
+ x += thisw * w;
+ }
+ }
+ if (batchcount > 0)
+ {
+ GL_LockArrays(0, batchcount * 4);
+ R_Mesh_Draw(0, batchcount * 4, 0, batchcount * 2, NULL, quadelements, 0, 0);
+ GL_LockArrays(0, 0);
+ }