예제 #1
0
파일: sbar.c 프로젝트: CatalystG/tyrquake
/*
==================
Sbar_MiniDeathmatchOverlay

frags name
frags team name
displayed to right of status bar if there's room
==================
*/
void
Sbar_MiniDeathmatchOverlay(void)
{
    int i, k;
    int top, bottom;
    int x, y, f;
    char num[12];
    player_info_t *s;
    int teamplay;
    char team[5];
    int numlines;
    char name[16 + 1];
    team_t *tm;

    if (vid.width < 512 || !sb_lines)
	return;			// not enuff room

    teamplay = atoi(Info_ValueForKey(cl.serverinfo, "teamplay"));

    scr_copyeverything = 1;
    scr_fullupdate = 0;

// scores
    Sbar_SortFrags(false);
    if (vid.width >= 640)
	Sbar_SortTeams();

    if (!scoreboardlines)
	return;			// no one there?

// draw the text
    y = vid.height - sb_lines - 1;
    numlines = sb_lines / 8;
    if (numlines < 3)
	return;			// not enough room

    // find us
    for (i = 0; i < scoreboardlines; i++)
	if (fragsort[i] == cl.playernum)
	    break;

    if (i == scoreboardlines)	// we're not there, we are probably a spectator, just display top
	i = 0;
    else			// figure out start
	i = i - numlines / 2;

    if (i > scoreboardlines - numlines)
	i = scoreboardlines - numlines;
    if (i < 0)
	i = 0;

    x = 324;

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

	// draw ping
	top = Sbar_ColorForMap(s->topcolor);
	bottom = Sbar_ColorForMap(s->bottomcolor);

	Draw_Fill(x, y + 1, 40, 3, top);
	Draw_Fill(x, y + 4, 40, 4, bottom);

	// draw number
	f = s->frags;
	sprintf(num, "%3i", f);

	Draw_Character(x + 8, y, num[0]);
	Draw_Character(x + 16, y, num[1]);
	Draw_Character(x + 24, y, num[2]);

	if (k == cl.playernum) {
	    Draw_Character(x, y, 16);
	    Draw_Character(x + 32, y, 17);
	}
	// team
	if (teamplay) {
	    team[4] = 0;
	    strncpy(team, Info_ValueForKey(s->userinfo, "team"), 4);
	    Draw_String(x + 48, y, team);
	}
	// draw name
	name[16] = 0;
	strncpy(name, s->name, 16);
	if (teamplay)
	    Draw_String(x + 48 + 40, y, name);
	else
	    Draw_String(x + 48, y, name);
	y += 8;
    }

    // draw teams if room
    if (vid.width < 640 || !teamplay)
	return;

    // draw seperator
    x += 208;
    for (y = vid.height - sb_lines; y < vid.height - 6; y += 2)
	Draw_Character(x, y, 14);

    x += 16;

    y = vid.height - sb_lines;
    for (i = 0; i < scoreboardteams && y <= vid.height; i++) {
	k = teamsort[i];
	tm = teams + k;

	// draw pings
	team[4] = 0;
	strncpy(team, tm->team, 4);
	Draw_String(x, y, team);

	// draw total
	sprintf(num, "%5i", tm->frags);
	Draw_String(x + 40, y, num);

	if (!strncmp(Info_ValueForKey(cl.players[cl.playernum].userinfo,
				      "team"), tm->team, 16)) {
	    Draw_Character(x - 8, y, 16);
	    Draw_Character(x + 32, y, 17);
	}

	y += 8;
    }

}
예제 #2
0
파일: sbar.c 프로젝트: CatalystG/tyrquake
/*
==================
Sbar_TeamOverlay

team frags
added by Zoid
==================
*/
void
Sbar_TeamOverlay(void)
{
    const qpic_t *pic;
    int i, k;
    int x, y;
    char num[12];
    int teamplay;
    char team[5];
    team_t *tm;
    int plow, phigh, pavg;

// request new ping times every two second
    teamplay = atoi(Info_ValueForKey(cl.serverinfo, "teamplay"));

    if (!teamplay) {
	Sbar_DeathmatchOverlay(0);
	return;
    }

    scr_copyeverything = 1;
    scr_fullupdate = 0;

    pic = Draw_CachePic("gfx/ranking.lmp");
    Draw_Pic(160 - pic->width / 2, 0, pic);

    y = 24;
    x = 36;
    Draw_String(x, y, "low/avg/high team total players");
    y += 8;
//      Draw_String(x, y, "------------ ---- ----- -------");
    Draw_String(x, y,
		"\x1d\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1f \x1d\x1e\x1e\x1f \x1d\x1e\x1e\x1e\x1f \x1d\x1e\x1e\x1e\x1e\x1e\x1f");
    y += 8;

// sort the teams
    Sbar_SortTeams();

// draw the text
    for (i = 0; i < scoreboardteams && y <= vid.height - 10; i++) {
	k = teamsort[i];
	tm = teams + k;

	// draw pings
	plow = tm->plow;
	if (plow < 0 || plow > 999)
	    plow = 999;
	phigh = tm->phigh;
	if (phigh < 0 || phigh > 999)
	    phigh = 999;
	if (!tm->players)
	    pavg = 999;
	else
	    pavg = tm->ptotal / tm->players;
	if (pavg < 0 || pavg > 999)
	    pavg = 999;

	sprintf(num, "%3i/%3i/%3i", plow, pavg, phigh);
	Draw_String(x, y, num);

	// draw team
	team[4] = 0;
	strncpy(team, tm->team, 4);
	Draw_String(x + 104, y, team);

	// draw total
	sprintf(num, "%5i", tm->frags);
	Draw_String(x + 104 + 40, y, num);

	// draw players
	sprintf(num, "%5i", tm->players);
	Draw_String(x + 104 + 88, y, num);

	if (!strncmp(Info_ValueForKey(cl.players[cl.playernum].userinfo,
				      "team"), tm->team, 16)) {
	    Draw_Character(x + 104 - 8, y, 16);
	    Draw_Character(x + 104 + 32, y, 17);
	}

	y += 8;
    }
    y += 8;
    Sbar_DeathmatchOverlay(y);
}
예제 #3
0
파일: sbar.c 프로젝트: RetroPie/tyrquake
/*
==================
Sbar_MiniDeathmatchOverlay

frags name
frags team name
displayed to right of status bar if there's room
==================
*/
void
Sbar_MiniDeathmatchOverlay(void)
{
    int x, y, line, numlines, top, bottom;
    int teamplay;

    /* Don't bother if not enough room */
    if (vid.width < 512 || !sb_lines)
	return;

    teamplay = atoi(Info_ValueForKey(cl.serverinfo, "teamplay"));

    scr_copyeverything = 1;
    scr_fullupdate = 0;

    Sbar_SortFrags(false);
    if (vid.width >= 640)
	Sbar_SortTeams();
    if (!scoreboardlines)
	return;

    /* Check for space to draw the text */
    y = vid.height - sb_lines - 1;
    numlines = sb_lines / 8;
    if (numlines < 3)
	return;

    /* Find client in the scoreboard, if not there (spectator) display top */
    for (line = 0; line < scoreboardlines; line++)
	if (fragsort[line] == cl.playernum)
	    break;
    if (line == scoreboardlines)
	line = 0;

    /* Put the client in the centre of the displayed lines */
    line = qclamp(line - numlines / 2, 0, scoreboardlines - numlines);

    x = 324;
    while (line < scoreboardlines && y < vid.height - 8 + 1) {
	const int playernum = fragsort[line++];
	const player_info_t *player = &cl.players[playernum];
	if (!player->name[0])
	    continue;

	/* draw background */
	top = Sbar_ColorForMap(player->topcolor);
	bottom = Sbar_ColorForMap(player->bottomcolor);
	Draw_Fill(x, y + 1, 40, 3, top);
	Draw_Fill(x, y + 4, 40, 4, bottom);

	/* draw frags */
	char frags[4];
	snprintf(frags, sizeof(frags), "%3d", player->frags);
	Draw_Character(x + 8, y, frags[0]);
	Draw_Character(x + 16, y, frags[1]);
	Draw_Character(x + 24, y, frags[2]);
	if (playernum == cl.playernum) {
	    Draw_Character(x, y, 16);
	    Draw_Character(x + 32, y, 17);
	}

	/* draw team name */
	if (teamplay) {
	    const char *playerteam = Info_ValueForKey(player->userinfo, "team");
	    char short_team[5];
	    snprintf(short_team, sizeof(short_team), "%-4s", playerteam);
	    Draw_String(x + 48, y, short_team);
	}

	/* draw name */
	char name[17];
	snprintf(name, sizeof(name), "%-16s", player->name);
	if (teamplay)
	    Draw_String(x + 48 + 40, y, name);
	else
	    Draw_String(x + 48, y, name);

	y += 8;
    }

    /* draw teams if room */
    if (vid.width < 640 || !teamplay)
	return;

    /* draw seperator */
    x += 208;
    for (y = vid.height - sb_lines; y < vid.height - 6; y += 2)
	Draw_Character(x, y, 14);

    const player_info_t *player = &cl.players[cl.playernum];
    const char *playerteam = Info_ValueForKey(player->userinfo, "team");

    x += 16;
    y = vid.height - sb_lines;
    line = 0;
    while (line < scoreboardteams && y <= vid.height) {
	const team_t *team = teams + teamsort[line++];

	/* draw teamname */
	char short_team[5];
	snprintf(short_team, sizeof(short_team), "%-4s", team->team);
	Draw_String(x, y, short_team);

	/* draw frags */
	char frags[4];
	snprintf(frags, sizeof(frags), "%3d", team->frags);
	Draw_String(x + 40, y, frags);
	if (!strncmp(team->team, playerteam, 16)) {
	    Draw_Character(x - 8, y, 16);
	    Draw_Character(x + 32, y, 17);
	}

	y += 8;
    }
}