예제 #1
0
/*
================
SCR_ExecuteLayoutString 

================
*/
void SCR_ExecuteLayoutString (char *s)
{
	int		x, y;
	int		value;
	char	*token;
	int		width;
	int		index;
	clientinfo_t	*ci;

	if (cls.state != ca_active || !cl.refresh_prepped)
		return;

	if (!s[0])
		return;

	x = 0;
	y = 0;
	width = 3;

	while (s)
	{
		token = COM_Parse (&s);
		if (!strcmp(token, "xl"))
		{
			token = COM_Parse (&s);
			x = atoi(token);
			continue;
		}
		if (!strcmp(token, "xr"))
		{
			token = COM_Parse (&s);
			x = viddef.width + atoi(token);
			continue;
		}
		if (!strcmp(token, "xv"))
		{
			token = COM_Parse (&s);
			x = viddef.width/2 - 160 + atoi(token);
			continue;
		}

		if (!strcmp(token, "yt"))
		{
			token = COM_Parse (&s);
			y = atoi(token);
			continue;
		}
		if (!strcmp(token, "yb"))
		{
			token = COM_Parse (&s);
			y = viddef.height + atoi(token);
			continue;
		}
		if (!strcmp(token, "yv"))
		{
			token = COM_Parse (&s);
			y = viddef.height/2 - 120 + atoi(token);
			continue;
		}

		if (!strcmp(token, "pic"))
		{	// draw a pic from a stat number
			token = COM_Parse (&s);
			value = cl.frame.playerstate.stats[atoi(token)];
			if (value >= MAX_IMAGES)
				Com_Error (ERR_DROP, "Pic >= MAX_IMAGES");
			if (cl.configstrings[CS_IMAGES+value])
			{
				SCR_AddDirtyPoint (x, y);
				SCR_AddDirtyPoint (x+23, y+23);
				re.DrawPic (x, y, cl.configstrings[CS_IMAGES+value]);
			}
			continue;
		}

		if (!strcmp(token, "client"))
		{	// draw a deathmatch client block
			int		score, ping, time;

			token = COM_Parse (&s);
			x = viddef.width/2 - 160 + atoi(token);
			token = COM_Parse (&s);
			y = viddef.height/2 - 120 + atoi(token);
			SCR_AddDirtyPoint (x, y);
			SCR_AddDirtyPoint (x+159, y+31);

			token = COM_Parse (&s);
			value = atoi(token);
			if (value >= MAX_CLIENTS || value < 0)
				Com_Error (ERR_DROP, "client >= MAX_CLIENTS");
			ci = &cl.clientinfo[value];

			token = COM_Parse (&s);
			score = atoi(token);

			token = COM_Parse (&s);
			ping = atoi(token);

			token = COM_Parse (&s);
			time = atoi(token);

			DrawAltString (x+32, y, ci->name);
#if defined (__APPLE__) || defined (MACOSX)
			Con_DrawString (x+32, y+8,  "Score: ");
#else
			DrawString (x+32, y+8,  "Score: ");
#endif /* __APPLE__ || MACOSX */
			DrawAltString (x+32+7*8, y+8,  va("%i", score));
#if defined (__APPLE__) || defined (MACOSX)
			Con_DrawString (x+32, y+16, va("Ping:  %i", ping));
			Con_DrawString (x+32, y+24, va("Time:  %i", time));
#else
			DrawString (x+32, y+16, va("Ping:  %i", ping));
			DrawString (x+32, y+24, va("Time:  %i", time));
#endif /* __APPLE__ || MACOSX */

			if (!ci->icon)
				ci = &cl.baseclientinfo;
			re.DrawPic (x, y, ci->iconname);
			continue;
		}

		if (!strcmp(token, "ctf"))
		{	// draw a ctf client block
			int		score, ping;
			char	block[80];

			token = COM_Parse (&s);
			x = viddef.width/2 - 160 + atoi(token);
			token = COM_Parse (&s);
			y = viddef.height/2 - 120 + atoi(token);
			SCR_AddDirtyPoint (x, y);
			SCR_AddDirtyPoint (x+159, y+31);

			token = COM_Parse (&s);
			value = atoi(token);
			if (value >= MAX_CLIENTS || value < 0)
				Com_Error (ERR_DROP, "client >= MAX_CLIENTS");
			ci = &cl.clientinfo[value];

			token = COM_Parse (&s);
			score = atoi(token);

			token = COM_Parse (&s);
			ping = atoi(token);
			if (ping > 999)
				ping = 999;

#if defined (__APPLE__) || defined (MACOSX)
			snprintf(block, 80, "%3d %3d %-12.12s", score, ping, ci->name);
#else
			sprintf(block, "%3d %3d %-12.12s", score, ping, ci->name);
#endif /* __APPLE__ || MACOSX */

			if (value == cl.playernum)
				DrawAltString (x, y, block);
			else
#if defined (__APPLE__) || defined (MACOSX)
				Con_DrawString (x, y, block);
#else
				DrawString (x, y, block);
#endif /* __APPLE__ ||ÊMACOSX */
			continue;
		}

		if (!strcmp(token, "picn"))
		{	// draw a pic from a name
			token = COM_Parse (&s);
			SCR_AddDirtyPoint (x, y);
			SCR_AddDirtyPoint (x+23, y+23);
			re.DrawPic (x, y, token);
			continue;
		}

		if (!strcmp(token, "num"))
		{	// draw a number
			token = COM_Parse (&s);
			width = atoi(token);
			token = COM_Parse (&s);
			value = cl.frame.playerstate.stats[atoi(token)];
			SCR_DrawField (x, y, 0, width, value);
			continue;
		}

		if (!strcmp(token, "hnum"))
		{	// health number
			int		color;

			width = 3;
			value = cl.frame.playerstate.stats[STAT_HEALTH];
			if (value > 25)
				color = 0;	// green
			else if (value > 0)
				color = (cl.frame.serverframe>>2) & 1;		// flash
			else
				color = 1;

			if (cl.frame.playerstate.stats[STAT_FLASHES] & 1)
				re.DrawPic (x, y, "field_3");

			SCR_DrawField (x, y, color, width, value);
			continue;
		}
예제 #2
0
파일: cl_screen.c 프로젝트: tmcb/yquake2
void
SCR_ExecuteLayoutString(char *s)
{
	int x, y;
	int value;
	char *token;
	int width;
	int index;
	clientinfo_t *ci;

	if ((cls.state != ca_active) || !cl.refresh_prepped)
	{
		return;
	}

	if (!s[0])
	{
		return;
	}

	x = 0;
	y = 0;

	while (s)
	{
		token = COM_Parse(&s);

		if (!strcmp(token, "xl"))
		{
			token = COM_Parse(&s);
			x = (int)strtol(token, (char **)NULL, 10);
			continue;
		}

		if (!strcmp(token, "xr"))
		{
			token = COM_Parse(&s);
			x = viddef.width + (int)strtol(token, (char **)NULL, 10);
			continue;
		}

		if (!strcmp(token, "xv"))
		{
			token = COM_Parse(&s);
			x = viddef.width / 2 - 160 + (int)strtol(token, (char **)NULL, 10);
			continue;
		}

		if (!strcmp(token, "yt"))
		{
			token = COM_Parse(&s);
			y = (int)strtol(token, (char **)NULL, 10);
			continue;
		}

		if (!strcmp(token, "yb"))
		{
			token = COM_Parse(&s);
			y = viddef.height + (int)strtol(token, (char **)NULL, 10);
			continue;
		}

		if (!strcmp(token, "yv"))
		{
			token = COM_Parse(&s);
			y = viddef.height / 2 - 120 + (int)strtol(token, (char **)NULL, 10);
			continue;
		}

		if (!strcmp(token, "pic"))
		{
			/* draw a pic from a stat number */
			token = COM_Parse(&s);
			index = (int)strtol(token, (char **)NULL, 10);

			if ((index < 0) || (index >= sizeof(cl.frame.playerstate.stats)))
			{
				Com_Error(ERR_DROP, "bad stats index %d (0x%x)", index, index);
			}

			value = cl.frame.playerstate.stats[index];

			if (value >= MAX_IMAGES)
			{
				Com_Error(ERR_DROP, "Pic >= MAX_IMAGES");
			}

			if (cl.configstrings[CS_IMAGES + value])
			{
				SCR_AddDirtyPoint(x, y);
				SCR_AddDirtyPoint(x + 23, y + 23);
				Draw_Pic(x, y, cl.configstrings[CS_IMAGES + value]);
			}

			continue;
		}

		if (!strcmp(token, "client"))
		{
			/* draw a deathmatch client block */
			int score, ping, time;

			token = COM_Parse(&s);
			x = viddef.width / 2 - 160 + (int)strtol(token, (char **)NULL, 10);
			token = COM_Parse(&s);
			y = viddef.height / 2 - 120 + (int)strtol(token, (char **)NULL, 10);
			SCR_AddDirtyPoint(x, y);
			SCR_AddDirtyPoint(x + 159, y + 31);

			token = COM_Parse(&s);
			value = (int)strtol(token, (char **)NULL, 10);

			if ((value >= MAX_CLIENTS) || (value < 0))
			{
				Com_Error(ERR_DROP, "client >= MAX_CLIENTS");
			}

			ci = &cl.clientinfo[value];

			token = COM_Parse(&s);
			score = (int)strtol(token, (char **)NULL, 10);

			token = COM_Parse(&s);
			ping = (int)strtol(token, (char **)NULL, 10);

			token = COM_Parse(&s);
			time = (int)strtol(token, (char **)NULL, 10);

			DrawAltString(x + 32, y, ci->name);
			DrawString(x + 32, y + 8, "Score: ");
			DrawAltString(x + 32 + 7 * 8, y + 8, va("%i", score));
			DrawString(x + 32, y + 16, va("Ping:  %i", ping));
			DrawString(x + 32, y + 24, va("Time:  %i", time));

			if (!ci->icon)
			{
				ci = &cl.baseclientinfo;
			}

			Draw_Pic(x, y, ci->iconname);
			continue;
		}

		if (!strcmp(token, "ctf"))
		{
			/* draw a ctf client block */
			int score, ping;
			char block[80];

			token = COM_Parse(&s);
			x = viddef.width / 2 - 160 + (int)strtol(token, (char **)NULL, 10);
			token = COM_Parse(&s);
			y = viddef.height / 2 - 120 + (int)strtol(token, (char **)NULL, 10);
			SCR_AddDirtyPoint(x, y);
			SCR_AddDirtyPoint(x + 159, y + 31);

			token = COM_Parse(&s);
			value = (int)strtol(token, (char **)NULL, 10);

			if ((value >= MAX_CLIENTS) || (value < 0))
			{
				Com_Error(ERR_DROP, "client >= MAX_CLIENTS");
			}

			ci = &cl.clientinfo[value];

			token = COM_Parse(&s);
			score = (int)strtol(token, (char **)NULL, 10);

			token = COM_Parse(&s);
			ping = (int)strtol(token, (char **)NULL, 10);

			if (ping > 999)
			{
				ping = 999;
			}

			sprintf(block, "%3d %3d %-12.12s", score, ping, ci->name);

			if (value == cl.playernum)
			{
				DrawAltString(x, y, block);
			}

			else
			{
				DrawString(x, y, block);
			}

			continue;
		}

		if (!strcmp(token, "picn"))
		{
			/* draw a pic from a name */
			token = COM_Parse(&s);
			SCR_AddDirtyPoint(x, y);
			SCR_AddDirtyPoint(x + 23, y + 23);
			Draw_Pic(x, y, (char *)token);
			continue;
		}

		if (!strcmp(token, "num"))
		{
			/* draw a number */
			token = COM_Parse(&s);
			width = (int)strtol(token, (char **)NULL, 10);
			token = COM_Parse(&s);
			value = cl.frame.playerstate.stats[(int)strtol(token, (char **)NULL, 10)];
			SCR_DrawField(x, y, 0, width, value);
			continue;
		}

		if (!strcmp(token, "hnum"))
		{
			/* health number */
			int color;

			width = 3;
			value = cl.frame.playerstate.stats[STAT_HEALTH];

			if (value > 25)
			{
				color = 0;  /* green */
			}
			else if (value > 0)
			{
				color = (cl.frame.serverframe >> 2) & 1; /* flash */
			}
			else
			{
예제 #3
0
static void JoinServer_InfoDraw( void )
{
    char key[MAX_INFO_KEY];
    char value[MAX_INFO_VALUE];
    const char *info;
    int x = s_joinserver_server_list.width + 40;
    int y = 80;
    int index;
    serverStatus_t *server;
    playerStatus_t *player;
    int i;

    // Never draw on low resolutions
    if( viddef.width < 512 )
        return;

    index = s_joinserver_server_list.curvalue;
    if( index < 0 || index >= MAX_MENU_SERVERS )
        return;

    server = &localServers[sortedSList[index]];

    DrawAltString( x, y, "Name            Score Ping");
    y += 8;
    DrawAltString( x, y, "--------------- ----- ----");
    y += 10;

    if( !server->numPlayers ) {
        DrawAltString( x, y, "No players");
        y += 8;
    }
    else
    {
        for( i=0, player=server->players ; i<server->numPlayers ; i++, player++ ) {
            DrawString( x, y, va( "%-15s %5i %4i\n", player->name, player->score, player->ping ));
            y += 8;
        }
    }

    y+=8;
    DrawAltString( x, y, "Server info");
    y += 8;
    DrawAltString( x, y, "--------------------------");
    y += 10;

    info = (const char *)server->infostring;
    while( *info ) {
        Info_NextPair( &info, key, value );

        if(!key[0] || !value[0])
            break;

        if( strlen( key ) > 15 ) {
            strcpy( key + 12, "..." );
        }

        DrawString( x, y, va( "%-8s", key ));
        DrawString( x + 16 * 8, y, va( "%-16s", value ));
        y += 8;
    }

}
예제 #4
0
void Menu_Draw ( menuframework_t *menu )
{
	char scratch[MAX_QPATH];
	static int yaw;
//	int maxframe = 29;
	entity_t entity;
	int i;
	menucommon_t *item;
	refdef_t refdef;

	// Draw rotating Quake II Symbol
	memset( &refdef, 0, sizeof( refdef ) );
	memset( &entity, 0, sizeof( entity ) );

	refdef.x = 0;
	refdef.y = 0;
	refdef.width = viddef.width;
	refdef.height = viddef.height;
	refdef.fov_x = 35;
	refdef.fov_y = CalcFov( refdef.fov_x, refdef.width, refdef.height );
	refdef.time = cls.realtime * 0.001;
	refdef.areabits = NULL;
	refdef.num_entities = 1;
	//refdef.lightstyles = 5;			// Gentle Pulse
	refdef.lightstyles = 63;			// Testing (FULLBRIGHT)
	refdef.rdflags = RDF_NOWORLDMODEL;
	refdef.blend[0] = 1.0;
	refdef.blend[1] = 1.0;
	refdef.blend[2] = 1.0;
	refdef.blend[3] = 0.0;
	refdef.dlights = NULL;
	refdef.num_dlights = 0;
	refdef.num_particles = 0;
	refdef.particles = NULL;
	VectorSet(refdef.viewangles, 1.0, 0.0, 0.0);
	VectorClear(refdef.vieworg);

	//if (!strcmp(vid_ref->string, "soft"))
	//	Com_sprintf( scratch, sizeof( scratch ), "models/items/quaddama/tris.md2");
	//else
		Com_sprintf( scratch, sizeof( scratch ), "models/MenuModel/quad.md2");

	entity.model = re.RegisterModel( scratch );
	//entity.Model_Type = 0;
	entity.flags = RF_MINLIGHT | RF_DEPTHHACK | RF_FULLBRIGHT | RF_GLOW | RF_NOSHADOW;
	entity.origin[0] = 80;
	entity.origin[1] = 0;
	entity.origin[2] = -18;	// -18 compensates for the float height of the model
	VectorCopy( entity.origin, entity.oldorigin );
	entity.frame = 0;
	entity.oldframe = 0;
	entity.backlerp = 0.0;
	entity.angles[1] = yaw++;
	if ( ++yaw > 360 )
		yaw -= 360;

	refdef.entities = &entity;

	// Fog the scene
	//refdef.blend[0] = 0.55;
	//refdef.blend[1] = 0.55;
	//refdef.blend[2] = 0.55;
	//refdef.blend[3] = 0.55;

	if (cl_3dmenubg->value)
	{
		// Draw scene
		MenuRefdefActive = 1;
		re.RenderFrame( &refdef );
		//Menu_DrawBackground("q2bg.tga");
	}

	// Draw the menu version information
	if (cl_menustamp->value > 0)
	{
		/*
		1 - Regular string
		2 - Regular string plus drop shadow (green... not effective)
		3 - All green string
		*/
		if (cl_menustamp->value == 1)
		{
			// Draw the text
			Menu_DrawString (viddef.width - (strlen(MENUSTAMP) * FONTSIZE) - (FONTSIZE * 3), viddef.height - FONTSIZE, MENUSTAMP);
		}
		else if (cl_menustamp->value == 2)
		{
			// Draw the drop shadow (we need black characters)
			DrawAltString (viddef.width - (strlen(MENUSTAMP) * FONTSIZE) - (FONTSIZE * 3) - 1, viddef.height - FONTSIZE, MENUSTAMP);

			// Draw the text
			Menu_DrawString (viddef.width - (strlen(MENUSTAMP) * FONTSIZE) - (FONTSIZE * 3), viddef.height - FONTSIZE - 1, MENUSTAMP);
		}
		else if (cl_menustamp->value == 3)
		{
			// Draw the text
			DrawAltString (viddef.width - (strlen(MENUSTAMP) * FONTSIZE) - (FONTSIZE * 3), viddef.height - FONTSIZE, MENUSTAMP);
		}
	}

	// Menu drawing prevention hack for main menu
	if ((menu->x == -1) && (menu->y == -1))
		return;

	/*
	** draw contents
	*/
	for ( i = 0; i < menu->nitems; i++ )
	{
		switch ( ( ( menucommon_t * ) menu->items[i] )->type )
		{
		case MTYPE_FIELD:
			Field_Draw( ( menufield_t * ) menu->items[i] );
			break;
		case MTYPE_SLIDER:
			Slider_Draw( ( menuslider_t * ) menu->items[i] );
			break;
		case MTYPE_LIST:
			MenuList_Draw( ( menulist_t * ) menu->items[i] );
			break;
		case MTYPE_SPINCONTROL:
			SpinControl_Draw( ( menulist_t * ) menu->items[i] );
			break;
		case MTYPE_ACTION:
			Action_Draw( ( menuaction_t * ) menu->items[i] );
			break;
		case MTYPE_SEPARATOR:
			Separator_Draw( ( menuseparator_t * ) menu->items[i] );
			break;
		}
	}

	item = Menu_ItemAtCursor( menu );

	if ( item && item->cursordraw )
	{
		item->cursordraw( item );
	}
	else if ( menu->cursordraw )
	{
		menu->cursordraw( menu );
	}
	else if ( item && item->type != MTYPE_FIELD )
	{
		if ( item->flags & QMF_LEFT_JUSTIFY )
		{
			Draw_Char( menu->x + item->x - 24 + item->cursor_offset, menu->y + item->y, 12 + ( ( int ) ( Sys_Milliseconds()/250 ) & 1 ) );
		}
		else
		{
			Draw_Char( menu->x + item->cursor_offset, menu->y + item->y, 12 + ( ( int ) ( Sys_Milliseconds()/250 ) & 1 ) );
		}
	}

	if ( item )
	{
		if ( item->statusbarfunc )
			item->statusbarfunc( ( void * ) item );
		else if ( item->statusbar )
			Menu_DrawStatusBar( item->statusbar );
		else
			Menu_DrawStatusBar( menu->statusbar );

	}
	else
	{
		Menu_DrawStatusBar( menu->statusbar );
	}
}