• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ Q_IsColorString函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Q_IsColorString函数的典型用法代码示例。如果您正苦于以下问题:C++ Q_IsColorString函数的具体用法?C++ Q_IsColorString怎么用?C++ Q_IsColorString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Q_IsColorString函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: Q_PrintStrlen

int Q_PrintStrlen( const char *string ) {
	int			len;
	const char	*p;

	if( !string ) {
		return 0;
	}

	len = 0;
	p = string;
	while( *p ) {
		if( Q_IsColorString( p ) ) {
			p += 2;
			continue;
		}
		p++;
		len++;
	}

	return len;
}
开发者ID:thecheeseman,项目名称:libcodc,代码行数:21,代码来源:q_lib.c


示例17: SCR_Text_Width

int SCR_Text_Width(const char *text, float scale, int limit, const fontInfo_t * font)
{
	int             count, len;
	float           out;
	const glyphInfo_t *glyph;
	float           useScale;

// FIXME: see ui_main.c, same problem
//  const unsigned char *s = text;
	const char     *s = text;

	useScale = scale * font->glyphScale;
	out = 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];
				out += glyph->xSkip;
				s++;
				count++;
			}
		}
	}

	return out * useScale;
}
开发者ID:otty,项目名称:cake3,代码行数:40,代码来源:cl_scrn.c


示例18: Q_CleanStr

/*
Clean up player name to be suitable as path name.
Similar to Q_CleanStr() but tweaked.
*/
static void SVD_CleanPlayerName(char *name)
{
        char *src = name, *dst = name, c;
        while ((c = *src)) {
                // note Q_IsColorString(src++) won't work since it's a macro
                if (Q_IsColorString(src)) {
                        src++;
                }
                else if (c == ':' || c == '\\' || c == '/' || c == '*' || c == '?') {
                        *dst++ = '%';
                }
                else if (c > ' ' && c < 0x7f) {
                        *dst++ = c;
                }
                src++;
        }
        *dst = '\0';

        if (strlen(name) == 0) {
                strcpy(name, "UnnamedPlayer");
        }
}
开发者ID:promolic1,项目名称:iourt-fru,代码行数:26,代码来源:sv_ccmds.c


示例19: SCR_DrawSmallStringExt

/*
==================
SCR_DrawSmallString[Color]

Draws a multi-colored string with a drop shadow, optionally forcing
to a fixed color.
==================
*/
void SCR_DrawSmallStringExt( int x, int y, const char *string, qboolean forceColor, qboolean noColorEscape ) {
    const char	*s;
    int			xx;

    // 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_DrawSmallChar( xx, y, *s );
        xx += SMALLCHAR_WIDTH;
        s++;
    }
    re.SetColor( NULL );
}
开发者ID:qrealka,项目名称:ioq3,代码行数:30,代码来源:cl_scrn.c


示例20: CG_DrawStrlen

/*
=================
CG_DrawStrlen

Returns character count, skipping 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 {

			/* LQ3A: Support multiline strings. */
			if (*s == '\n')
			{
				break;
			}

			count++;
			s++;
		}
	}

	return count;
}
开发者ID:monoknot,项目名称:loaded-q3a,代码行数:29,代码来源:cg_drawtools.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Q_LIKELY函数代码示例发布时间:2022-05-30
下一篇:
C++ Q_INT64_C函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap