Public feed #722689

Anonymous

public text v1 · immutable
Raw Edit
·published 2007-10-02 07:12 UTC
rendered paste body
// Electro - wrote into a seperate function (easier to plugin)
void Sbar_ElectroDeathmatchOverlay (int start)
{
	int				i, k, l;
	int				top, bottom;
	int				x, y;
	int				xofs;
	char			num[128];
	player_info_t	*s;
	int				total;
	int				minutes;
	int				p;
	char			team[5];
	int				skip = 10;

	int				total_columns = 0, rank_width, trans_bottom, n, tens, units, fph, startx, tempx;
	float			brighter;
	char			header[128], teamcolumn[10], pingcolumn[10], plcolumn[10], fphcolumn[10], timecolumn[10], timestring[20];

	extern			void Surmo_Draw_String (int xh, int y, char *str);

#ifndef CLIENTONLY
	// FIXME
	// check number of connections instead?
	if (cl.gametype == GAME_COOP && com_serveractive && !coop.value)
		return;
#endif

	if (largegame)
		skip = 8;

// request new ping times every two second
	if (cls.realtime - cl.last_ping_request > 2)
	{
		cl.last_ping_request = cls.realtime;
		MSG_WriteByte (&cls.netchan.message, clc_stringcmd);
		SZ_Print (&cls.netchan.message, "pings");
	}

	scr_copyeverything = 1;
	scr_fullupdate = 0;

	if (start)
		y = start;
	else
		y = 40;

	rank_width = scoreboard_width(); // Electro - width of the table

	// can toggle columns too
	if (cl.teamplay)
		sprintf (teamcolumn, " Team");
	else
		strcpy (teamcolumn, "");

	if (cl_scoreboard_ping.value)
		sprintf (pingcolumn, " Ping");
	else
		strcpy (pingcolumn, "");

	if (cl_scoreboard_pl.value)
		sprintf (plcolumn, " Pl ");
	else
		strcpy (plcolumn, "");

	if (cl_scoreboard_fph.value)
		sprintf (fphcolumn, " FPH");
	else
		strcpy (fphcolumn, "");

	if (cl_scoreboard_time.value)
		sprintf (timecolumn, "  Time");
	else
		strcpy (timecolumn, "");

	if (cl_scoreboard_align.value == -1)
		xofs = 20; // Electro - left
	else if (cl_scoreboard_align.value == 1)
		xofs = (vid.width - rank_width) - 10; // Electro - right
	else
		xofs = (vid.width - rank_width)/2; // Electro - center (default)

	Draw_Fill (xofs - 11, y-9, rank_width + 2, 1, 0, 1); // Electro - Border - Top
	Draw_Fill (xofs - 10, y-8, rank_width, 9, 1, 0.7f); // Electro - draw heading row

	//sprintf (header, " Ping Pl  FPH  Time Frags Team Name");
	if (cl.teamplay)
		sprintf (header, "%s%s%s%s Frags%s Name", pingcolumn, plcolumn, fphcolumn, timecolumn, teamcolumn);
	else
		sprintf (header, "%s%s%s%s Frags Name", pingcolumn, plcolumn, fphcolumn, timecolumn);

	Draw_String(xofs - 8, y-8, header);

	Draw_Fill (xofs - 11, y+1, rank_width + 2, 1, 0, 1); // Electro - Border - Top (under header)
	y += 2; // Electro - dont go over the black border, move the rest down
	Draw_Fill (xofs - 11, y-10, 1, 10, 0, 1); // Electro - Border - Left
	Draw_Fill ((xofs - 11) + rank_width + 1, y-10, 1, 10, 0, 1); // Electro - Border - Right
	x = xofs;
	startx = x;

	// silly math used to align the players shirt/pants colour bar properly - value changes through-out below
	tempx = xofs+rank_width-(MAX_SCOREBOARDNAME*8)-56; // touching this could prove ugly

	if (!cl_scoreboard_pl.value)
		tempx -= 8;

	if (!cl_scoreboard_time.value)
		tempx -= 8;

	if (!cl_scoreboard_fph.value)
		tempx += 8;

	Sbar_SortFrags (true);	// scores
	l = scoreboardlines;	// draw the text

	for (i=0 ; i<l && y <= vid.height-10 ; i++)
	{
		k = fragsort[i];
		s = &cl.players[k];
		if (!s->name[0])
			continue;

		// Electro - moved this up, we need to use it early
		// draw background
		top = s->topcolor;
		bottom = s->bottomcolor;
		top = Sbar_ColorForMap (top);
		bottom = Sbar_ColorForMap (bottom);

		// render your own row slightly brighter than everyone elses (except spectators)
		if ( (k == cl.playernum) && (!s->spectator) )
			brighter = 0.7f;
		else
			brighter = 0.4f;

		// Electro - render the main background transparencies behind players row
		if ((cl.teamplay) && (!s->spectator))
		{
			// Electro - red vs blue are common teams, force the colours, regardless of enemycolor cvar
			Q_strncpyz(team, Info_ValueForKey(s->userinfo, "team"), sizeof(team));

			if (!(strcmp("red", team)))
				trans_bottom = 72; // forced red
			else if (!(strcmp("blue", team)))
				trans_bottom = 216; // forced blue
			else
				trans_bottom = bottom;

			Draw_Fill (xstart - 10, y, rank_width, skip, trans_bottom);
		}
		else
			Draw_Fill (xofs - 10, y, rank_width, skip, 2, brighter);

		Draw_Fill (xofs - 11, y, 1, skip, 0, 1); // Electro - Border - Left
		Draw_Fill ((xofs - 11) + rank_width + 1, y, 1, skip, 0, 1); // Electro - Border - Right

		// draw ping
		p = s->ping;
		if (p < 0 || p > 999)
			p = 999;

		if (cl_scoreboard_ping.value)
		{
			if (con_rankingscheme.value)
			{
				sprintf (num, "&c668%4i&r", p);
				Surmo_Draw_String(x, y, num);
			}
			else
			{
				sprintf (num, "%4i", p);
				Draw_String(x, y, num);
			}
			x += 32; // move it forward, ready to print next column
		}
		else
			x -= 8; // move x back, so pl can print at x

		// draw pl
		p = s->pl;
		if (cl_scoreboard_pl.value)
		{
			if (con_rankingscheme.value)
			{
				if (p > 25)
					sprintf (num, "&c822%3i&r", p);
				else
					sprintf (num, "&c870%3i&r", p);
				Surmo_Draw_String (x, y, num);
			}
			else
			{
				sprintf (num, "%3i", p);
				if (p > 25)
					Draw_Alt_String (x, y, num);
				else
					Draw_String (x, y, num);
			}
			x += 32;
		}

		if (s->spectator)
		{
			//x -= 16;
			if (con_rankingscheme.value)
				Surmo_Draw_String (x, y, "   &c900(&c910s&c930p&c950e&c852c&c653t&c445a&c336t&c227o&c118r&c009)&r");
			else
				Draw_String (x, y, "(spectator)");

			x += 136; // move across to print the name

			// draw name
			Draw_String (x, y, s->name);

			y += skip;
			x = startx;
			continue;
		}

		// draw time
		if (cl.intermission)
			total = cl.completed_time - s->entertime;
		else
			total = cls.realtime - s->entertime;
		minutes = (int)total/60;

		n = total - minutes*60;
		tens = '0' + n/10;
		units = '0' + n%10;

		// Electro - frags per hour count, cheers again LordHavoc
		fph = total ? (int) ((float) s->frags * 3600.0 / total) : 0;
		if (fph < -999) fph = -999;
		if (fph > 9999) fph = 9999;

		if (cl_scoreboard_time.value)
			sprintf (timestring, "%2i:%c%c ", minutes, tens, units);
		else
			sprintf (timestring, "");

		if (cl_scoreboard_fph.value)
			sprintf (fphcolumn, "%4i ", fph);
		else
			sprintf (fphcolumn, " ");

		// print the shirt/pants colour bars
		if (cl.teamplay)
		{
			Draw_Fill (tempx-40, y, 40, 4, top, 1);
			Draw_Fill (tempx-40, y+4, 40, 4, bottom, 1);
		}
		else
		{
			Draw_Fill (tempx, y, 40, 4, top, 1);
			Draw_Fill (tempx, y+4, 40, 4, bottom, 1);
		}

		// team
		if (cl.teamplay)
		{
			Q_strncpyz (team, Info_ValueForKey(s->userinfo, "team"), sizeof(team));
			sprintf (num, "%s%s%4i %5s %s", fphcolumn, timestring, s->frags, team, s->name);
		}
		else
			sprintf (num, "%s%s%4i  %s", fphcolumn, timestring, s->frags, s->name);

		Draw_String (x, y, num);

		y += skip;
		x = startx;
	}

	Draw_Fill (startx - 11, y - 1, rank_width + 2, 1, 0, 1); // Electro - Border - Bottom

	if (y >= vid.height-10) // we ran over the screen size, squish
		largegame = true;
}