本文整理汇总了C++中Q_IsColorString函数的典型用法代码示例。如果您正苦于以下问题:C++ Q_IsColorString函数的具体用法?C++ Q_IsColorString怎么用?C++ Q_IsColorString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Q_IsColorString函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Sys_AnsiColorPrint
/*
=================
Sys_AnsiColorPrint
Transform Q3 colour codes to ANSI escape sequences
=================
*/
void Sys_AnsiColorPrint( const char *msg ) {
static char buffer[ MAXPRINTMSG ];
int length = 0;
static int q3ToAnsi[ 8 ] = {
30, // COLOR_BLACK
31, // COLOR_RED
32, // COLOR_GREEN
33, // COLOR_YELLOW
34, // COLOR_BLUE
36, // COLOR_CYAN
35, // COLOR_MAGENTA
0 // COLOR_WHITE
};
while( *msg ) {
if( Q_IsColorString( msg ) || *msg == '\n' ) {
// First empty the buffer
if( length > 0 ) {
buffer[ length ] = '\0';
fputs( buffer, stderr );
length = 0;
}
if( *msg == '\n' ) {
// Issue a reset and then the newline
fputs( "\033[0m\n", stderr );
msg++;
} else {
// Print the color code
Com_sprintf( buffer, sizeof( buffer ), "\033[%dm",
q3ToAnsi[ ColorIndex( *( msg + 1 ) ) ] );
fputs( buffer, stderr );
msg += 2;
}
} else {
if( length >= MAXPRINTMSG - 1 )
break;
buffer[ length ] = *msg;
length++;
msg++;
}
}
// Empty anything still left in the buffer
if( length > 0 )
{
buffer[ length ] = '\0';
fputs( buffer, stderr );
}
}
示例2: UI_DrawString2
/*
=================
UI_DrawString2
=================
*/
static void UI_DrawString2( int x, int y, const char* str, vec4_t color, int charw, int charh )
{
const char* s;
char ch;
int forceColor = qfalse; //APSFIXME;
vec4_t tempcolor;
float ax;
float ay;
float aw;
float ah;
float frow;
float fcol;
if (y < -charh)
// offscreen
return;
// draw the colored text
trap_R_SetColor( color );
ax = x * uis.scale + uis.bias;
ay = y * uis.scale;
aw = charw * uis.scale;
ah = charh * uis.scale;
s = str;
while ( *s )
{
if ( Q_IsColorString( s ) )
{
if ( !forceColor )
{
memcpy( tempcolor, g_color_table[ColorIndex(s[1])], sizeof( tempcolor ) );
tempcolor[3] = color[3];
trap_R_SetColor( tempcolor );
}
s += 2;
continue;
}
ch = *s & 255;
if (ch != ' ')
{
frow = (ch>>4)*0.0625;
fcol = (ch&15)*0.0625;
trap_R_DrawStretchPic( ax, ay, aw, ah, fcol, frow, fcol + 0.0625, frow + 0.0625, uis.charset );
}
ax += aw;
s++;
}
示例3: SCR_DrawStringExt
/*
==================
SCR_DrawBigString[Color]
Draws a multi-colored string with a drop shadow, optionally forcing
to a fixed color.
Coordinates are at 640 by 480 virtual resolution
==================
*/
void SCR_DrawStringExt( int x, int y, float size, const char *string, qboolean forceColor, qboolean noColorEscape ) {
const char *s;
int xx;
// draw the drop shadow
re.SetColor(colorBlack);
s = string;
xx = x + 1;
while (*s) {
if ( Q_IsColorString( s ) ) {
s += 2;
continue;
}
SCR_DrawChar( xx, y+2, size, *s );
xx += size;
s++;
}
// draw the colored text
s = string;
xx = x;
re.SetColor( colorWhite );
while ( *s ) {
if ( Q_IsColorString( s ) ) {
if ( !forceColor ) {
re.SetColor(ColorFromChar(s[1]));
}
s += 2;
continue;
}
SCR_DrawChar( xx, y, size, *s );
xx += size;
s++;
}
re.SetColor( NULL );
}
示例4: CG_DrawStrlen
/*
=================
CG_DrawStrlen
Returns character count, skiping color escape codes
=================
*/
int CG_DrawStrlen( const char *str ) {
const char *s = str;
int count = 0;
while ( *s ) {
if ( Q_IsColorString( s ) ) {
s += 2;
} else {
count++;
s++;
}
}
return count;
}
示例5: RemoveColorEscapeSequences
/*
==============
RemoveColorEscapeSequences
==============
*/
void RemoveColorEscapeSequences( char *text ) {
int i, l;
l = 0;
for ( i = 0; text[i]; i++ ) {
if (Q_IsColorString(&text[i])) {
i++;
continue;
}
if (text[i] > 0x7E)
continue;
text[l++] = text[i];
}
text[l] = '\0';
}
示例6: SCR_Strlen
/*
** SCR_Strlen -- skips color escape codes
*/
static int SCR_Strlen( const char *str ) {
const char *s = str;
int count = 0;
const bool use102color = MV_USE102COLOR;
while ( *s ) {
if ( Q_IsColorString( s ) || (use102color && Q_IsColorString_1_02( s ))) {
s += 2;
} else {
count++;
s++;
}
}
return count;
}
示例7: RemoveColorEscapeSequences
/*
==============
RemoveColorEscapeSequences
==============
*/
void RemoveColorEscapeSequences(char *text)
{
int i, l;
l = 0;
for (i = 0; text[i]; i++) {
//Makro - don't remove underlined char escape sequence
if (Q_IsColorString(&text[i]) && text[i+1]!='_') {
i++;
continue;
}
if (text[i] > 0x7E)
continue;
text[l++] = text[i];
}
text[l] = '\0';
}
示例8: G_DecolorString
void G_DecolorString( char *in, char *out, int len )
{
len--;
while( *in && len > 0 )
{
if( Q_IsColorString( in ) )
{
in++;
if( *in )
in++;
continue;
}
*out++ = *in++;
len--;
}
*out = '\0';
}
示例9: CG_drawStrlen
/**
* @brief Real printable charater count
*/
int CG_drawStrlen(const char *str)
{
int cnt = 0;
while (*str)
{
if (Q_IsColorString(str))
{
str += 2;
}
else
{
cnt++;
str++;
}
}
return(cnt);
}
示例10: G_SanitiseString
/*
==================
G_SanitiseString
Remove case and control characters from a string
==================
*/
void G_SanitiseString( char *in, char *out, int len )
{
qboolean skip = qtrue;
int spaces = 0;
len--;
while( *in && len > 0 )
{
// strip leading white space
if( *in == ' ' )
{
if( skip )
{
in++;
continue;
}
spaces++;
}
else
{
spaces = 0;
skip = qfalse;
}
if( Q_IsColorString( in ) )
{
in += 2; // skip color code
continue;
}
if( *in < 32 )
{
in++;
continue;
}
*out++ = tolower( *in++ );
len--;
}
out -= spaces;
*out = 0;
}
示例11: SCR_Text_Height
int SCR_Text_Height(const char *text, float scale, int limit, const fontInfo_t * font)
{
int len, count;
float max;
const glyphInfo_t *glyph;
float useScale;
// TTimo: FIXME
// const unsigned char *s = text;
const char *s = text;
useScale = scale * font->glyphScale;
max = 0;
if(text)
{
len = strlen(text);
if(limit > 0 && len > limit)
{
len = limit;
}
count = 0;
while(s && *s && count < len)
{
if(Q_IsColorString(s))
{
s += 2;
continue;
}
else
{
glyph = &font->glyphs[(int)*s];
if(max < glyph->height)
{
max = glyph->height;
}
s++;
count++;
}
}
}
return max * useScale;
}
示例12: while
char *Q_CleanStr(char *string) {
char *d;
char *s;
int c;
s = string;
d = string;
while ((c = *s) != 0) {
if (Q_IsColorString(s)) {
s++;
} else if (c >= 0x20 && c <= 0x7E) {
*d++ = c;
}
s++;
}
*d = '\0';
return string;
}
示例13: Q_strcpyColor
/*
=================
Q_strcpyColor - This function will return the real length of the string if numChars
len of character data is desired. It looks for color codes and adds 2 to the length
for each combo found. This is used to make color strings show up correctly in column
formatted environments. Otherwise, the columns will be off 2 * num of color codes.
=================
*/
int Q_strcpyColor( const char *src, char *dest, int numChars )
{
int count, len;
char *d;
const char *s;
if( !src || !dest )
{
return 0;
}
count = len = 0;
s = src;
d = dest;
while( *s && count < numChars )
{
if( Q_IsColorString( s ))
{
*d++ = *s++;
*d++ = *s++;
len += 2;
continue;
}
*d = *s;
s++;
d++;
count++;
len++;
}
// Now fill up the end of the string with space characters if needed...
while( count < numChars )
{
*d = ' ';
//d[len] = ' ';
d++;
len++;
count++;
}
return len;
}
示例14: Sys_AnsiColorPrint
/* Transform Q3 colour codes to ANSI escape sequences */
void
Sys_AnsiColorPrint(const char *msg)
{
static char buffer[MAXPRINTMSG];
int length = 0;
while(*msg){
if(Q_IsColorString(msg) || *msg == '\n'){
/* First empty the buffer */
if(length > 0){
buffer[length] = '\0';
fputs(buffer, stderr);
length = 0;
}
if(*msg == '\n'){
/* Issue a reset and then the newline */
fputs("\033[0m\n", stderr);
msg++;
}else{
/* Print the color code */
Q_sprintf(buffer, sizeof(buffer), "\033[%dm",
q3ToAnsi[ ColorIndex(*(msg + 1)) ]);
fputs(buffer, stderr);
msg += 2;
}
}else{
if(length >= MAXPRINTMSG - 1)
break;
buffer[length] = *msg;
length++;
msg++;
}
}
/* Empty anything still left in the buffer */
if(length > 0){
buffer[length] = '\0';
fputs(buffer, stderr);
}
}
示例15: UI_DrawSmallString
void UI_DrawSmallString( int x, int y, const char* str ) {
vec4_t color;
Vector4Set( color, 1, 1, 1, 1 );
R_SetColor( color );
while ( *str ) {
if ( Q_IsColorString( str ) ) {
if ( *( str + 1 ) == COLOR_NULL ) {
Vector4Set( color, 1, 1, 1, 1 );
} else {
Com_Memcpy( color, g_color_table[ ColorIndex( *( str + 1 ) ) ], sizeof ( color ) );
}
str += 2;
R_SetColor( color );
continue;
}
UI_SmallCharacter( x, y, *str );
str++;
x += 6;
}
R_SetColor( NULL );
}