当前位置: 首页>>代码示例>>C++>>正文


C++ Q_IsColorString函数代码示例

本文整理汇总了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 );
	}
}
开发者ID:DerSaidin,项目名称:OpenWolf,代码行数:58,代码来源:sys_main.cpp

示例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++;
	}
开发者ID:linux26,项目名称:corkscrew,代码行数:56,代码来源:ui_atoms.c

示例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 );
}
开发者ID:qrealka,项目名称:ioq3,代码行数:47,代码来源:cl_scrn.c

示例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;
}
开发者ID:AdrienJaguenet,项目名称:Enemy-Territory,代码行数:22,代码来源:cg_drawtools.c

示例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';
}
开发者ID:SilverlineDev,项目名称:mint-arena,代码行数:20,代码来源:ai_main.c

示例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;
}
开发者ID:entdark,项目名称:jk2mv,代码行数:20,代码来源:cl_scrn.cpp

示例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';
}
开发者ID:zturtleman,项目名称:reaction,代码行数:22,代码来源:ai_main.c

示例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';
}
开发者ID:sago007,项目名称:oax,代码行数:18,代码来源:g_cmds_ext.c

示例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);
}
开发者ID:winrid,项目名称:etlegacy,代码行数:21,代码来源:cg_scoreboard.c

示例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;
}
开发者ID:sago007,项目名称:oax,代码行数:50,代码来源:g_cmds_ext.c

示例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;
}
开发者ID:otty,项目名称:cake3,代码行数:43,代码来源:cl_scrn.c

示例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;
}
开发者ID:boutetnico,项目名称:ETrun,代码行数:19,代码来源:q_shared.c

示例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;
}
开发者ID:Developer626,项目名称:legacy,代码行数:50,代码来源:ui_servers2.c

示例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);
	}
}
开发者ID:icanhas,项目名称:yantar,代码行数:42,代码来源:main.c

示例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 );
}
开发者ID:janisl,项目名称:jlquake,代码行数:21,代码来源:draw.cpp


注:本文中的Q_IsColorString函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。