++s;
switch((s == end) ? 0 : *s)
{
- case STRING_COLOR_RGB_DEFAULT:
+ case STRING_COLOR_RGB_TAG_CHAR:
if (s+1 != end && isxdigit(s[1]) &&
s+2 != end && isxdigit(s[2]) &&
s+3 != end && isxdigit(s[3]) )
break;
}
++len; // STRING_COLOR_TAG
- ++len; // STRING_COLOR_RGB_DEFAULT
+ ++len; // STRING_COLOR_RGB_TAG_CHAR
break;
- /*case 'a':
- if ( s+1 != end && ( isxdigit(s[1]) || (s[1] == '+' || s[1] == '-') ) )
- {
- s++;
- break;
- }
- ++len; // STRING_COLOR_TAG
- ++len; // STRING_COLOR_RGB_DEFAULT
- break;*/
case 0: // ends with unfinished color code!
++len;
if(valid)
++in;
switch((in == end) ? 0 : *in)
{
- case STRING_COLOR_RGB_DEFAULT:
+ case STRING_COLOR_RGB_TAG_CHAR:
if (in+1 != end && isxdigit(in[1]) &&
in+2 != end && isxdigit(in[2]) &&
in+3 != end && isxdigit(in[3]) )
APPEND(STRING_COLOR_TAG);
if(escape_carets)
APPEND(STRING_COLOR_TAG);
- APPEND(STRING_COLOR_RGB_DEFAULT);
+ APPEND(STRING_COLOR_RGB_TAG_CHAR);
break;
- /*case 'a':
- if ( in+1 != end && ( isxdigit(in[1]) || (in[1] == '+' || in[1] == '-') ) )
- {
- in++;
- break;
- }*/
case 0: // ends with unfinished color code!
APPEND(STRING_COLOR_TAG);
// finish the code by appending another caret when escaping
switch(*in)
{
case STRING_COLOR_TAG:
- if( in[1] == STRING_COLOR_RGB_DEFAULT && isxdigit(in[2]) && isxdigit(in[3]) && isxdigit(in[4]) )
+ if( in[1] == STRING_COLOR_RGB_TAG_CHAR && isxdigit(in[2]) && isxdigit(in[3]) && isxdigit(in[4]) )
{
char r = tolower(in[2]);
char g = tolower(in[3]);
switch(color)
{
- /*case 'a':
- if ( isxdigit(in[2]) || in[2] == '+' || in[2] == '-' )
- {
- in+=2;
- break;
- }*/
case STRING_COLOR_TAG:
++in;
*out++ = STRING_COLOR_TAG;
case STRING_COLOR_TAG:
switch(in[1])
{
- case STRING_COLOR_RGB_DEFAULT:
+ case STRING_COLOR_RGB_TAG_CHAR:
if ( isxdigit(in[2]) && isxdigit(in[3]) && isxdigit(in[4]) )
{
in+=4;
break;
}
*out++ = STRING_COLOR_TAG;
- *out++ = STRING_COLOR_RGB_DEFAULT;
+ *out++ = STRING_COLOR_RGB_TAG_CHAR;
++in;
break;
- /*case 'a':
- if ( isxdigit(in[2]) || in[2] == '+' || in[2] == '-' )
- {
- in+=2;
- break;
- }*/
case STRING_COLOR_TAG:
++in;
*out++ = STRING_COLOR_TAG;
} else if (*in == STRING_COLOR_TAG) // ^[0-9]^ found, don't print ^[0-9]
continue;
}
- else if (*in == STRING_COLOR_RGB_DEFAULT) // ^x found
+ else if (*in == STRING_COLOR_RGB_TAG_CHAR) // ^x found
{
if ( isxdigit(in[1]) && isxdigit(in[2]) && isxdigit(in[3]) )
{
}
else in--;
}
- /*else if (*in == 'a') // ^a found
- {
- if ( isxdigit(in[1]) || isxdigit(in[1]) == '+' || isxdigit(in[1]) == '-')
- {
- in+=2;
- if (!*in)
- {
- *out = 0;
- return;
- } else if (*in == STRING_COLOR_TAG) // ^ax^ found, don't print ^ax
- continue;
- }
- else in = in--;
- }*/
else if (*in != STRING_COLOR_TAG)
--in;
}
color = buffer[match+1];
break;
}
- else if(buffer[match+1] == STRING_COLOR_RGB_DEFAULT)
+ else if(buffer[match+1] == STRING_COLOR_RGB_TAG_CHAR)
{
if ( isxdigit(buffer[match+2]) && isxdigit(buffer[match+3]) && isxdigit(buffer[match+4]) )
{
{
pos -= 2;
}
- else if( pos >= 5 && buffer[pos-5] == STRING_COLOR_TAG && buffer[pos-4] == STRING_COLOR_RGB_DEFAULT)
+ else if( pos >= 5 && buffer[pos-5] == STRING_COLOR_TAG && buffer[pos-4] == STRING_COLOR_RGB_TAG_CHAR)
{
if ( isxdigit(buffer[pos-3]) && isxdigit(buffer[pos-2]) && isxdigit(buffer[pos-1]) )
{
if (color == -1)
{
buffer[pos++] = STRING_COLOR_TAG;
- buffer[pos++] = STRING_COLOR_RGB_DEFAULT;
+ buffer[pos++] = STRING_COLOR_RGB_TAG_CHAR;
buffer[pos++] = r;
buffer[pos++] = g;
buffer[pos++] = b;
}
- /*else if (color == -2)
- {
- buffer[pos++] = STRING_COLOR_TAG;
- buffer[pos++] = 'a';
- buffer[pos++] = a;
- }*/
else
{
buffer[pos++] = STRING_COLOR_TAG;
#define STRING_COLOR_TAG '^'
#define STRING_COLOR_DEFAULT 7
#define STRING_COLOR_DEFAULT_STR "^7"
-#define STRING_COLOR_RGB_DEFAULT 'x'
-#define STRING_COLOR_RGB_DEFAULT_STR "^xfff"
-//#define STRING_COLOR_ALPHA_DEFAULT 'a'
-//#define STRING_COLOR_ALPHA_DEFAULT_STR "^af"
+#define STRING_COLOR_RGB_TAG_CHAR 'x'
+#define STRING_COLOR_RGB_TAG "^x"
// all of these functions will set r_defdef.draw2dstage if not in 2D rendering mode (and of course prepare for 2D rendering in that case)
size_t i;
float x = 0;
char ch;
- int current_alpha, tempcolorindex;
+ int tempcolorindex;
if (*maxlen < 1)
*maxlen = 1<<30;
maxwidth /= fnt->scale;
- current_alpha = 0xf;
-
for (i = 0;i < *maxlen && text[i];i++)
{
if (text[i] == ' ')
colorindex = ch - '0';
continue;
}
- else if (ch == STRING_COLOR_RGB_DEFAULT && i + 3 < *maxlen ) // ^x found
+ else if (ch == STRING_COLOR_RGB_TAG_CHAR && i + 3 < *maxlen ) // ^x found
{
// building colorindex...
ch = tolower(text[i+1]);
else tempcolorindex = 0;
if (tempcolorindex)
{
- colorindex = tempcolorindex | current_alpha;
+ colorindex = tempcolorindex | 0xf;
// ...done! now colorindex has rgba codes (1,rrrr,gggg,bbbb,aaaa)
i+=3;
continue;
}
}
}
- /*else if (ch == 'a' && i + 1 < *maxlen) // ^a found
- {
- if (colorindex > 9)
- {
- ch = tolower(text[i+1]);
- if (ch <= '9' && ch >= '0') current_alpha = (ch - '0');
- else if (ch >= 'a' && ch <= 'f') current_alpha = (ch - 87);
- else if (ch == '+' && colorindex > 9)
- {
- current_alpha = colorindex & 0xf;
- if (current_alpha < 0xf)
- current_alpha++;
- }
- else if (ch == '-' && colorindex > 9)
- {
- current_alpha = colorindex & 0xf;
- if (current_alpha > 0)
- current_alpha--;
- }
- colorindex = ((colorindex >> 4 ) << 4) + current_alpha;
- }
- i++;
- continue;
- }*/
else if (ch == STRING_COLOR_TAG) // ^^ found, ignore the first ^ and go to print the second
i++;
i--;
float texcoord2f[QUADELEMENTS_MAXQUADS*4*2];
float color4f[QUADELEMENTS_MAXQUADS*4*4];
int ch;
- int current_alpha, tempcolorindex;
+ int tempcolorindex;
int tw, th;
tw = R_TextureWidth(fnt->tex);
x += r_textshadow.value;
y += r_textshadow.value;
}
- current_alpha = 0xf;
for (i = 0;i < maxlen && text[i];i++)
{
if (text[i] == ' ')
DrawQ_GetTextColor(color, colorindex, basered, basegreen, baseblue, basealpha, shadow);
continue;
}
- else if (ch == STRING_COLOR_RGB_DEFAULT && i+3 < maxlen ) // ^x found
+ else if (ch == STRING_COLOR_RGB_TAG_CHAR && i+3 < maxlen ) // ^x found
{
// building colorindex...
ch = tolower(text[i+1]);
else tempcolorindex = 0;
if (tempcolorindex)
{
- colorindex = tempcolorindex | current_alpha;
+ 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);
}
}
}
- /*else if (ch == 'a' && i+1 < maxlen ) // ^a found
- {
- if (colorindex > 9) // colorindex is a RGB color
- {
- ch = tolower(text[i+1]);
- if (ch <= '9' && ch >= '0') current_alpha = (ch - '0');
- else if (ch >= 'a' && ch <= 'f') current_alpha = (ch - 87);
- else if (ch == '+' && colorindex > 9)
- {
- current_alpha = colorindex & 0xf;
- if (current_alpha < 0xf)
- current_alpha++;
- }
- else if (ch == '-' && colorindex > 9)
- {
- current_alpha = colorindex & 0xf;
- if (current_alpha > 0)
- current_alpha--;
- }
- colorindex = ((colorindex >> 4 ) << 4) + current_alpha;
- //Con_Printf("^1colorindex:^7 %x\n", colorindex);
- DrawQ_GetTextColor(color, colorindex, basered, basegreen, baseblue, basealpha, shadow);
- }
- i++;
- continue;
- }*/
else if (ch == STRING_COLOR_TAG)
i++;
i--;
i++;
continue;
}
- if (host_client->name[i+1] == STRING_COLOR_RGB_DEFAULT && isxdigit(host_client->name[i+2]) && isxdigit(host_client->name[i+3]) && isxdigit(host_client->name[i+4]))
+ if (host_client->name[i+1] == STRING_COLOR_RGB_TAG_CHAR && isxdigit(host_client->name[i+2]) && isxdigit(host_client->name[i+3]) && isxdigit(host_client->name[i+4]))
{
j = i;
i += 4;