/* =============== Sbar_DrawFrags =============== */ void Sbar_DrawFrags (void) { int i, k, l; int top, bottom; int x, y, f; int xofs; char num[12]; scoreboard_t *s; if (cl.maxclients == 1) // mankrip return; // mankrip Sbar_SortFrags (); // draw the text l = scoreboardlines <= 4 ? scoreboardlines : 4; x = 23; xofs = 202; y = 200 - SBAR_HEIGHT + 23; // mankrip - edited for (i=0 ; i<l ; i++) { k = fragsort[i]; s = &cl.scores[k]; if (!s->name[0]) continue; // draw background top = s->colors & 0xf0; bottom = (s->colors & 15)<<4; top = Sbar_ColorForMap (top); bottom = Sbar_ColorForMap (bottom); //qb: fixme - needs its own special function for scalable hud... // M_Draw_Fill (xofs - (xofs *scr_2d_scale_h)/4 + 220, y - (y * scr_2d_scale_v)/2 + 228, 28, 4, top); //qb: adjust for scaling - mankrip - edited //M_Draw_Fill (xofs - (xofs *scr_2d_scale_h)/4 + 220, y - (y * scr_2d_scale_v)/2 + 232, 28, 3, bottom); //qb: adjust for scaling - mankrip - edited // draw number f = s->frags; sprintf (num, "%3i",f); Sbar_DrawCharacter ( (x+1)*8 , -24, num[0]); Sbar_DrawCharacter ( (x+2)*8 , -24, num[1]); Sbar_DrawCharacter ( (x+3)*8 , -24, num[2]); if (k == cl.viewentity - 1) { Sbar_DrawCharacter (x*8+2, -24, 16); Sbar_DrawCharacter ( (x+4)*8-4, -24, 17); } x+=4; } }
/* =============== Sbar_DrawFrags =============== */ void Sbar_DrawFrags(void) { int i, k, l; int top, bottom; int x, y, f; char num[12]; player_info_t *s; Sbar_SortFrags(false); // draw the text l = scoreboardlines <= 4 ? scoreboardlines : 4; x = 23; // xofs = (vid.width - 320)>>1; y = vid.height - SBAR_HEIGHT - 23; for (i = 0; i < l; i++) { k = fragsort[i]; s = &cl.players[k]; if (!s->name[0]) continue; if (s->spectator) continue; // draw background top = Sbar_ColorForMap(s->topcolor); bottom = Sbar_ColorForMap(s->bottomcolor); // Draw_Fill (xofs + x*8 + 10, y, 28, 4, top); // Draw_Fill (xofs + x*8 + 10, y+4, 28, 3, bottom); Draw_Fill(x * 8 + 10, y, 28, 4, top); Draw_Fill(x * 8 + 10, y + 4, 28, 3, bottom); // draw number f = s->frags; sprintf(num, "%3i", f); Sbar_DrawCharacter((x + 1) * 8, -24, num[0]); Sbar_DrawCharacter((x + 2) * 8, -24, num[1]); Sbar_DrawCharacter((x + 3) * 8, -24, num[2]); if (k == cl.playernum) { Sbar_DrawCharacter(x * 8 + 2, -24, 16); Sbar_DrawCharacter((x + 4) * 8 - 4, -24, 17); } x += 4; } }
/* =============== Sbar_UpdateScoreboard =============== */ void Sbar_UpdateScoreboard (void) { int i, k; int top, bottom; scoreboard_t *s; Sbar_SortFrags (); // draw the text memset (scoreboardtext, 0, sizeof(scoreboardtext)); for (i=0 ; i<scoreboardlines; i++) { k = fragsort[i]; s = &cl.scores[k]; sprintf (&scoreboardtext[i][1], "%3i %s", s->frags, s->name); top = s->colors & 0xf0; bottom = (s->colors & 15) <<4; scoreboardtop[i] = Sbar_ColorForMap (top); scoreboardbottom[i] = Sbar_ColorForMap (bottom); } }
/* ================== Sbar_DeathmatchOverlay ping time frags name ================== */ void Sbar_DeathmatchOverlay(int start) { const qpic_t *pic; int i, k, l; int top, bottom; int x, y, f; char num[12]; player_info_t *s; int total; int minutes; int p; int teamplay; char team[5]; int skip = 10; if (largegame) skip = 8; // request new ping times every two second if (realtime - cl.last_ping_request > 2) { cl.last_ping_request = realtime; MSG_WriteByte(&cls.netchan.message, clc_stringcmd); MSG_WriteString(&cls.netchan.message, "pings"); } teamplay = atoi(Info_ValueForKey(cl.serverinfo, "teamplay")); scr_copyeverything = 1; scr_fullupdate = 0; if (!start) { pic = Draw_CachePic("gfx/ranking.lmp"); Draw_Pic(160 - pic->width / 2, 0, pic); } // scores Sbar_SortFrags(true); // draw the text l = scoreboardlines; if (start) y = start; else y = 24; if (teamplay) { x = 4; // 0 40 64 104 152 192 Draw_String(x, y, "ping pl time frags team name"); y += 8; // Draw_String ( x , y, "---- -- ---- ----- ---- ----------------"); Draw_String(x, y, "\x1d\x1e\x1e\x1f \x1d\x1f \x1d\x1e\x1e\x1f \x1d\x1e\x1e\x1e\x1f \x1d\x1e\x1e\x1f \x1d\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1f"); y += 8; } else { x = 16; // 0 40 64 104 152 Draw_String(x, y, "ping pl time frags name"); y += 8; // Draw_String ( x , y, "---- -- ---- ----- ----------------"); Draw_String(x, y, "\x1d\x1e\x1e\x1f \x1d\x1f \x1d\x1e\x1e\x1f \x1d\x1e\x1e\x1e\x1f \x1d\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1e\x1f"); y += 8; } for (i = 0; i < l && y <= vid.height - 10; i++) { k = fragsort[i]; s = &cl.players[k]; if (!s->name[0]) continue; // draw ping p = s->ping; if (p < 0 || p > 999) p = 999; sprintf(num, "%4i", p); Draw_String(x, y, num); // draw pl p = s->pl; sprintf(num, "%3i", p); if (p > 25) Draw_Alt_String(x + 32, y, num); else Draw_String(x + 32, y, num); if (s->spectator) { Draw_String(x + 40, y, "(spectator)"); // draw name if (teamplay) Draw_String(x + 152 + 40, y, s->name); else Draw_String(x + 152, y, s->name); y += skip; continue; } // draw time if (cl.intermission) total = cl.completed_time - s->entertime; else total = realtime - s->entertime; minutes = (int)total / 60; sprintf(num, "%4i", minutes); Draw_String(x + 64, y, num); // draw background top = Sbar_ColorForMap(s->topcolor); bottom = Sbar_ColorForMap(s->bottomcolor); if (largegame) Draw_Fill(x + 104, y + 1, 40, 3, top); else Draw_Fill(x + 104, y, 40, 4, top); Draw_Fill(x + 104, y + 4, 40, 4, bottom); // draw number f = s->frags; sprintf(num, "%3i", f); Draw_Character(x + 112, y, num[0]); Draw_Character(x + 120, y, num[1]); Draw_Character(x + 128, y, num[2]); if (k == cl.playernum) { Draw_Character(x + 104, y, 16); Draw_Character(x + 136, y, 17); } // team if (teamplay) { team[4] = 0; strncpy(team, Info_ValueForKey(s->userinfo, "team"), 4); Draw_String(x + 152, y, team); } // draw name if (teamplay) Draw_String(x + 152 + 40, y, s->name); else Draw_String(x + 152, y, s->name); y += skip; } if (y >= vid.height - 10) // we ran over the screen size, squish largegame = true; }
/* ================== 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; } }
/* ================== 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; } }
/* ================== Sbar_DeathmatchOverlay ================== */ void Sbar_DeathmatchOverlay (void) { int i, k, l; int top, bottom; int x, y, f; char num[12]; float oldsbarscale; //qb: do it big scoreboard_t *s; //qb: big and sort of lazy.. oldsbarscale = sbar_scale.value; sbar_scale.value = 1.0; scr_2d_scale_h = vid.width * sbar_scale.value / (200.0 * 1.8); scr_2d_scale_v = vid.height / (MIN_VID_HEIGHT/sbar_scale.value); scr_copyeverything = 1; scr_fullupdate = 0; M_DrawPlaque ("gfx/ranking.lmp", false); // mankrip // scores Sbar_SortFrags (); // draw the text l = scoreboardlines; x = 80; // mankrip - edited y = 36; //qb: also edited, was 36 - mankrip - edited for (i=0 ; i<l ; i++) { k = fragsort[i]; s = &cl.scores[k]; if (!s->name[0]) continue; // draw background top = s->colors & 0xf0; bottom = (s->colors & 15)<<4; top = Sbar_ColorForMap (top); bottom = Sbar_ColorForMap (bottom); M_Draw_Fill (x+20, y + 1 , 40, 4, top); M_Draw_Fill (x+20, y + 1 + 4, 40, 4, bottom); // draw number f = s->frags; sprintf (num, "%3i",f); M_DrawCharacter ( x+8 , y, num[0], true); M_DrawCharacter ( x+16 , y, num[1], true); M_DrawCharacter ( x+24 , y, num[2], true); if (k == cl.viewentity - 1) M_DrawCharacter ( x - 8, y, 12, true); #if 0 { int total; int n, minutes, tens, units; // draw time total = cl.completed_time - s->entertime; minutes = (int)total/60; n = total - minutes*60; tens = n/10; units = n%10; sprintf (num, "%3i:%i%i", minutes, tens, units); Draw_String ( x+48 , y, num); } #endif // draw name Draw_String (x+64, y, s->name, true); y += 10; } sbar_scale.value =oldsbarscale; scr_2d_scale_h = vid.width * sbar_scale.value / (200.0 * nativeaspect); if (scr_2d_scale_h < 1) scr_2d_scale_h = 1; scr_2d_scale_v = vid.height / (200.0/sbar_scale.value); if (scr_2d_scale_v < 1) scr_2d_scale_v = 1; }