/* ================= CG_DrawTimer ================= */ static float CG_DrawTimer(float y) { char *s; int w, w2; vec4_t color = { 0.625f, 0.625f, 0.6f, 1.0f }; int tens; char *rt = (cgs.gametype != GT_WOLF_LMS && (cgs.clientinfo[cg.clientNum].team != TEAM_SPECTATOR || cg.snap->ps.pm_flags & PMF_FOLLOW) && cg_drawReinforcementTime.integer > 0) ? va("^F%d%s", CG_CalculateReinfTime(qfalse), ((cgs.timelimit <= 0.0f) ? "" : " ")) : ""; int x; int msec = (cgs.timelimit * 60.f * 1000.f) - (cg.time - cgs.levelStartTime); int seconds = msec / 1000; int mins = seconds / 60; seconds -= mins * 60; tens = seconds / 10; seconds -= tens * 10; if (cgs.gamestate != GS_PLAYING) { s = va("^7%s", CG_TranslateString("WARMUP")); // don't draw reinforcement time in warmup mode // ^* color[3] = fabs(sin(cg.time * 0.002)); } else if (msec < 0 && cgs.timelimit > 0.0f) { s = "^N0:00"; color[3] = fabs(sin(cg.time * 0.002)); } else { if (cgs.timelimit <= 0.0f) { s = va("%s", rt); } else { s = va("%s^7%i:%i%i", rt, mins, tens, seconds); // ^* } color[3] = 1.f; } // spawntimer seconds = msec / 1000; if (cg_spawnTimer_set.integer != -1 && cg_spawnTimer_period.integer > 0) { s = va("^1%d %s", cg_spawnTimer_period.integer + (seconds - cg_spawnTimer_set.integer) % cg_spawnTimer_period.integer, s); } // end spawntimer w = CG_Text_Width_Ext(s, 0.19f, 0, &cgs.media.limboFont1); w2 = (UPPERRIGHT_W > w) ? UPPERRIGHT_W : w; x = Ccg_WideX(UPPERRIGHT_X) - w2 - 2; CG_FillRect(x, y, w2 + 5, 12 + 2, HUD_Background); CG_DrawRect_FixedBorder(x, y, w2 + 5, 12 + 2, 1, HUD_Border); CG_Text_Paint_Ext(x + ((w2 - w) / 2) + 2, y + 11, 0.19f, 0.19f, color, s, 0, 0, 0, &cgs.media.limboFont1); return y + 12 + 4; }
/* ================== CG_DrawSnapshot ================== */ static float CG_DrawSnapshot(float y) { char *s = va("t:%i sn:%i cmd:%i", cg.snap->serverTime, cg.latestSnapshotNum, cgs.serverCommandSequence); int w = CG_Text_Width_Ext(s, 0.19f, 0, &cgs.media.limboFont1); int w2 = (UPPERRIGHT_W > w) ? UPPERRIGHT_W : w; int x = Ccg_WideX(UPPERRIGHT_X) - w2 - 2; CG_FillRect(x, y, w2 + 5, 12 + 2, HUD_Background); CG_DrawRect_FixedBorder(x, y, w2 + 5, 12 + 2, 1, HUD_Border); CG_Text_Paint_Ext(x + ((w2 - w) / 2) + 2, y + 11, 0.19f, 0.19f, HUD_Text, s, 0, 0, 0, &cgs.media.limboFont1); return y + 12 + 4; }
static int WM_DrawInfoLine( int x, int y, float fade ) { int w, defender, winner; const char *s; vec4_t tclr = { 0.6f, 0.6f, 0.6f, 1.0f }; if ( cg.snap->ps.pm_type != PM_INTERMISSION ) { return y; } w = 360; // CG_DrawPic( 320 - w/2, y, w, INFO_LINE_HEIGHT, trap_R_RegisterShaderNoMip( "ui/assets/mp_line_strip.tga" ) ); s = CG_ConfigString( CS_MULTI_INFO ); defender = atoi( Info_ValueForKey( s, "defender" ) ); s = CG_ConfigString( CS_MULTI_MAPWINNER ); winner = atoi( Info_ValueForKey( s, "winner" ) ); if ( cgs.currentRound ) { // first round s = va( CG_TranslateString( "CLOCK IS NOW SET TO %s!" ), WM_TimeToString( cgs.nextTimeLimit * 60.f * 1000.f ) ); } else { // second round if ( !defender ) { if ( winner != defender ) s = "ALLIES SUCCESSFULLY BEAT THE CLOCK!"; else s = "ALLIES COULDN'T BEAT THE CLOCK!"; } else { if ( winner != defender ) s = "AXIS SUCCESSFULLY BEAT THE CLOCK!"; else s = "AXIS COULDN'T BEAT THE CLOCK!"; } s = CG_TranslateString( s ); } CG_FillRect( 320 - w/2, y, w, 20, clrUiBar ); CG_DrawRect_FixedBorder( 320 - w/2, y, w, 20, 1, colorBlack ); w = CG_Text_Width_Ext( s, 0.25f, 0, &cgs.media.limboFont1 ); CG_Text_Paint_Ext( 320 - w*0.5f, y + 15, 0.25f, 0.25f, tclr, s, 0, 0, 0, &cgs.media.limboFont1 ); // CG_DrawSmallString( 320 - w/2, ( y + INFO_LINE_HEIGHT / 2 ) - SMALLCHAR_HEIGHT / 2, s, fade ); return y + INFO_LINE_HEIGHT + 6; }
static void CG_DrawSkillBar(float x, float y, float w, float h, int skill) { int i; float blockheight = (h - 4) / (float)(NUM_SKILL_LEVELS - 1); float draw_y = y + h - blockheight; vec4_t colour; float x1, y1, w1, h1; for (i = 0; i < NUM_SKILL_LEVELS - 1; i++) { if (i >= skill) { Vector4Set(colour, 1.f, 1.f, 1.f, .15f); } else { Vector4Set(colour, 0.f, 0.f, 0.f, .4f); } CG_FillRect(x, draw_y, w, blockheight, colour); if (i < skill) { x1 = x; y1 = draw_y; w1 = w; h1 = blockheight; CG_AdjustFrom640(&x1, &y1, &w1, &h1); trap_R_DrawStretchPic(x1, y1, w1, h1, 0, 0, 1.f, 0.5f, cgs.media.limboStar_roll); } CG_DrawRect_FixedBorder(x, draw_y, w, blockheight, 1, colorBlack); draw_y -= (blockheight + 1); } }
static int WM_TeamScoreboard( int x, int y, team_t team, float fade, int maxrows ) { vec4_t hcolor; float tempx, tempy; int height, width; int i; int count = 0; vec4_t tclr = { 0.6f, 0.6f, 0.6f, 1.0f }; height = SMALLCHAR_HEIGHT * maxrows; width = INFO_PLAYER_WIDTH + INFO_CLASS_WIDTH + INFO_SCORE_WIDTH + INFO_LATENCY_WIDTH; CG_FillRect( x-5, y-2, width+5, 21, clrUiBack ); CG_FillRect( x-5, y-2, width+5, 21, clrUiBar ); Vector4Set( hcolor, 0, 0, 0, fade ); CG_DrawRect_FixedBorder( x-5, y-2, width+5, 21, 1, colorBlack ); // draw header if( cg_gameType.integer == GT_WOLF_LMS ) { char *s; if ( team == TEAM_AXIS ) { s = va( "%s [%d] (%d %s)", CG_TranslateString( "AXIS" ), cg.teamScores[0], cg.teamPlayers[team], CG_TranslateString("PLAYERS") ); s = va( "%s ^3%s", s, cg.teamFirstBlood == TEAM_AXIS ? CG_TranslateString("FIRST BLOOD") : "" ); CG_Text_Paint_Ext( x, y + 13, 0.25f, 0.25f, tclr, s, 0, 0, 0, &cgs.media.limboFont1 ); } else if ( team == TEAM_ALLIES ) { s = va( "%s [%d] (%d %s)", CG_TranslateString( "ALLIES" ), cg.teamScores[1], cg.teamPlayers[team], CG_TranslateString("PLAYERS") ); s = va( "%s ^3%s", s, cg.teamFirstBlood == TEAM_ALLIES ? CG_TranslateString("FIRST BLOOD") : "" ); CG_Text_Paint_Ext( x, y + 13, 0.25f, 0.25f, tclr, s, 0, 0, 0, &cgs.media.limboFont1 ); } } else { if ( team == TEAM_AXIS ) { CG_Text_Paint_Ext( x, y + 13, 0.25f, 0.25f, tclr, va( "%s [%d] (%d %s)", CG_TranslateString( "AXIS" ), cg.teamScores[0], cg.teamPlayers[team], CG_TranslateString("PLAYERS") ), 0, 0, 0, &cgs.media.limboFont1 ); } else if ( team == TEAM_ALLIES ) { CG_Text_Paint_Ext( x, y + 13, 0.25f, 0.25f, tclr, va( "%s [%d] (%d %s)", CG_TranslateString( "ALLIES" ), cg.teamScores[1], cg.teamPlayers[team], CG_TranslateString("PLAYERS") ), 0, 0, 0, &cgs.media.limboFont1 ); } } y += SMALLCHAR_HEIGHT + 3; // save off y val tempy = y; // draw color bands for ( i = 0; i <= maxrows; i++ ) { if ( i % 2 == 0 ) VectorSet( hcolor, (80.f/255.f), (80.f/255.f), (80.f/255.f) ); // LIGHT BLUE else VectorSet( hcolor, (0.f/255.f), (0.f/255.f), (0.f/255.f) ); // DARK BLUE hcolor[3] = fade * 0.3; CG_FillRect( x-5, y, width+5, SMALLCHAR_HEIGHT+1, hcolor ); trap_R_SetColor( colorBlack ); CG_DrawTopBottom( x-5, y, width+5, SMALLCHAR_HEIGHT+1, 1 ); trap_R_SetColor( NULL ); y += SMALLCHAR_HEIGHT; } hcolor[3] = 1; y = tempy; tempx = x; CG_FillRect( x-5, y-1, width+5, 18, clrUiBack ); //CG_FillRect( x-5, y-1, width+5, 18, clrUiBar ); trap_R_SetColor( colorBlack ); CG_DrawTopBottom( x-5, y-1, width+5, 18, 1 ); trap_R_SetColor( NULL ); // draw player info headings CG_DrawSmallString( tempx, y, CG_TranslateString( "Name" ), fade ); tempx += INFO_PLAYER_WIDTH; CG_DrawSmallString( tempx, y, CG_TranslateString( "Class" ), fade ); tempx += INFO_CLASS_WIDTH; if( cgs.gametype == GT_WOLF_LMS ) { CG_DrawSmallString( tempx, y, CG_TranslateString( "Score" ), fade ); tempx += INFO_SCORE_WIDTH; } else { CG_DrawSmallString( tempx + 1 * SMALLCHAR_WIDTH, y, CG_TranslateString( "XP" ), fade ); tempx += INFO_XP_WIDTH; } CG_DrawSmallString( tempx, y, CG_TranslateString( "Ping" ), fade ); tempx += INFO_LATENCY_WIDTH; if( cgs.gametype != GT_WOLF_LMS ) { CG_DrawPicST( tempx + 2, y, INFO_LIVES_WIDTH - 4, 16, 0.f, 0.f, 0.5f, 1.f, team == TEAM_ALLIES ? cgs.media.hudAlliedHelmet : cgs.media.hudAxisHelmet ); tempx += INFO_LIVES_WIDTH; } y += SMALLCHAR_HEIGHT; // draw player info VectorSet( hcolor, 1, 1, 1 ); hcolor[3] = fade; cg.teamPlayers[team] = 0; // JPW NERVE for ( i = 0; i < cg.numScores; i++ ) { if ( team != cgs.clientinfo[ cg.scores[i].client ].team ) continue; cg.teamPlayers[team]++; } count = 0; for( i = 0; i < cg.numScores && count < maxrows; i++ ) { if( team != cgs.clientinfo[ cg.scores[i].client ].team ) { continue; } if( cg.teamPlayers[team] > maxrows ) { WM_DrawClientScore_Small( x, y, &cg.scores[i], hcolor, fade ); y += MINICHAR_HEIGHT; } else { WM_DrawClientScore( x, y, &cg.scores[i], hcolor, fade ); y += SMALLCHAR_HEIGHT; } count++; } // draw spectators y += SMALLCHAR_HEIGHT; for ( i = 0; i < cg.numScores; i++ ) { if ( cgs.clientinfo[ cg.scores[i].client ].team != TEAM_SPECTATOR ) continue; if ( team == TEAM_AXIS && ( i % 2 ) ) continue; if ( team == TEAM_ALLIES && ( ( i + 1 ) % 2 ) ) continue; WM_DrawClientScore( x, y, &cg.scores[i], hcolor, fade ); y += SMALLCHAR_HEIGHT; } return y; }
int WM_DrawObjectives( int x, int y, int width, float fade ) { const char *s, *str; int tempy, rows; int msec, mins, seconds, tens; // JPW NERVE vec4_t tclr = { 0.6f, 0.6f, 0.6f, 1.0f }; if ( cg.snap->ps.pm_type == PM_INTERMISSION ) { const char *s, *buf, *shader = NULL, *flagshader = NULL, *nameshader = NULL; // Moved to CG_DrawIntermission /* static int doScreenshot = 0, doDemostop = 0; // OSP - End-of-level autoactions if(!cg.demoPlayback) { if(!cg.latchVictorySound) { if(cg_autoAction.integer & AA_SCREENSHOT) { doScreenshot = cg.time + 1000; } if(cg_autoAction.integer & AA_STATSDUMP) { CG_dumpStats_f(); } if((cg_autoAction.integer & AA_DEMORECORD) && (cgs.gametype == GT_WOLF_STOPWATCH && cgs.currentRound != 1)) { doDemostop = cg.time + 5000; // stats should show up within 5 seconds } } if(doScreenshot > 0 && doScreenshot < cg.time) { CG_autoScreenShot_f(); doScreenshot = 0; } if(doDemostop > 0 && doDemostop < cg.time) { trap_SendConsoleCommand("stoprecord\n"); doDemostop = 0; } } */ rows = 8; y += SMALLCHAR_HEIGHT * ( rows - 1 ); s = CG_ConfigString( CS_MULTI_MAPWINNER ); buf = Info_ValueForKey( s, "winner" ); if ( atoi( buf ) == -1 ) str = "ITS A TIE!"; else if ( atoi( buf ) ) { str = "ALLIES"; // shader = "ui/assets/portraits/allies_win"; flagshader = "ui/assets/portraits/allies_win_flag.tga"; nameshader = "ui/assets/portraits/text_allies.tga"; /* if ( !cg.latchVictorySound ) { cg.latchVictorySound = qtrue; trap_S_StartLocalSound( trap_S_RegisterSound( "sound/music/allies_win.wav", qtrue ), CHAN_LOCAL_SOUND ); // FIXME: stream }*/ } else { str = "AXIS"; // shader = "ui/assets/portraits/axis_win"; flagshader = "ui/assets/portraits/axis_win_flag.tga"; nameshader = "ui/assets/portraits/text_axis.tga"; /* if ( !cg.latchVictorySound ) { cg.latchVictorySound = qtrue; trap_S_StartLocalSound( trap_S_RegisterSound( "sound/music/axis_win.wav", qtrue ), CHAN_LOCAL_SOUND ); // FIXME: stream }*/ } y += SMALLCHAR_HEIGHT * ( ( rows - 2 ) / 2 ); if ( flagshader ) { CG_DrawPic( 100, 10, 210, 136, trap_R_RegisterShaderNoMip( flagshader ) ); CG_DrawPic( 325, 10, 210, 136, trap_R_RegisterShaderNoMip( flagshader ) ); } if ( shader ) CG_DrawPic( 229, 10, 182, 136, trap_R_RegisterShaderNoMip( shader ) ); if ( nameshader ) { CG_DrawPic( 140, 50, 127, 64, trap_R_RegisterShaderNoMip( nameshader ) ); CG_DrawPic( 365, 50, 127, 64, trap_R_RegisterShaderNoMip( "ui/assets/portraits/text_win.tga" ) ); } return y; } // JPW NERVE -- mission time & reinforce time else { tempy = y; rows = 1; CG_FillRect( x-5, y-2, width+5, 21, clrUiBack ); CG_FillRect( x-5, y-2, width+5, 21, clrUiBar ); CG_DrawRect_FixedBorder( x-5, y-2, width+5, 21, 1, colorBlack ); y += SMALLCHAR_HEIGHT * ( rows - 1 ); if( cgs.timelimit > 0.0f ) { msec = ( cgs.timelimit * 60.f * 1000.f ) - ( cg.time - cgs.levelStartTime ); seconds = msec / 1000; mins = seconds / 60; seconds -= mins * 60; tens = seconds / 10; seconds -= tens * 10; } else { mins = tens = seconds = 0; } if( cgs.gamestate != GS_PLAYING ) { s = va("%s %s", CG_TranslateString("MISSION TIME:"), CG_TranslateString("WARMUP")); } else if ( msec < 0 && cgs.timelimit > 0.0f ) { if ( cgs.gamestate == GS_WAITING_FOR_PLAYERS ) s = va( "%s %s", CG_TranslateString( "MISSION TIME:" ), CG_TranslateString( "GAME STOPPED" ) ); else s = va( "%s %s", CG_TranslateString( "MISSION TIME:" ), CG_TranslateString( "SUDDEN DEATH" ) ); } else { s = va( "%s %2.0f:%i%i", CG_TranslateString( "MISSION TIME:" ), (float)mins, tens, seconds ); // float cast to line up with reinforce time } CG_Text_Paint_Ext( x, y + 13, 0.25f, 0.25f, tclr, s, 0, 0, 0, &cgs.media.limboFont1 ); if( cgs.gametype != GT_WOLF_LMS ) { if(cgs.clientinfo[cg.snap->ps.clientNum].team == TEAM_AXIS || cgs.clientinfo[cg.snap->ps.clientNum].team == TEAM_ALLIES) { msec = CG_CalculateReinfTime( qfalse ) * 1000; } else // no team (spectator mode) msec = 0; if (msec) { seconds = msec / 1000; mins = seconds / 60; seconds -= mins * 60; tens = seconds / 10; seconds -= tens * 10; s = va( "%s %2.0f:%i%i", CG_TranslateString( "REINFORCE TIME:" ), (float)mins, tens, seconds ); CG_Text_Paint_Ext( 640 - 20 - CG_Text_Width_Ext( s, 0.25f, 0, &cgs.media.limboFont1 ), y + 13, 0.25f, 0.25f, tclr, s, 0, 0, 0, &cgs.media.limboFont1 ); } } // NERVE - SMF if ( cgs.gametype == GT_WOLF_STOPWATCH ) { int w; s = va( "%s %i", CG_TranslateString( "STOPWATCH ROUND" ), cgs.currentRound + 1 ); w = CG_Text_Width_Ext( s, 0.25f, 0, &cgs.media.limboFont1 ); CG_Text_Paint_Ext( x + 300 - w*0.5f, y + 13, 0.25f, 0.25f, tclr, s, 0, 0, 0, &cgs.media.limboFont1 ); } else if( cgs.gametype == GT_WOLF_LMS ) { int w; s = va( "%s %i %s %i-%i", CG_TranslateString( "ROUND" ), cgs.currentRound + 1, CG_TranslateString( "SCORE" ), cg.teamWonRounds[1], cg.teamWonRounds[0] ); w = CG_Text_Width_Ext( s, 0.25f, 0, &cgs.media.limboFont1 ); CG_Text_Paint_Ext( x + 300 - w*0.5f, y + 13, 0.25f, 0.25f, tclr, s, 0, 0, 0, &cgs.media.limboFont1 ); } else if( cgs.gametype == GT_WOLF_CAMPAIGN ) { int w; s = va( "MAP %i of %i", cgs.currentCampaignMap + 1, cgs.campaignData.mapCount ); w = CG_Text_Width_Ext( s, 0.25f, 0, &cgs.media.limboFont1 ); CG_Text_Paint_Ext( x + 300 - w*0.5f, y + 13, 0.25f, 0.25f, tclr, s, 0, 0, 0, &cgs.media.limboFont1 ); } y += SMALLCHAR_HEIGHT * 2; } // jpw return y; }
// CHRUKER: b035 - Added absolute maximum rows static int WM_TeamScoreboard(int x, int y, team_t team, float fade, int maxrows, int absmaxrows) { vec4_t hcolor; float tempx, tempy; int height, width; int i; int count = 0; qboolean use_mini_chars = qfalse; // CHRUKER: b035 - Needed to check if using mini chars vec4_t tclr = { 0.6f, 0.6f, 0.6f, 1.0f }; height = SMALLCHAR_HEIGHT * maxrows; width = INFO_PLAYER_WIDTH + INFO_CLASS_WIDTH + INFO_SCORE_WIDTH + INFO_LATENCY_WIDTH; CG_FillRect(x - 5, y - 2, width + 5, 21, clrUiBack); CG_FillRect(x - 5, y - 2, width + 5, 21, clrUiBar); Vector4Set(hcolor, 0, 0, 0, fade); CG_DrawRect_FixedBorder(x - 5, y - 2, width + 5, 21, 1, colorBlack); // draw header if(cg_gameType.integer == GT_WOLF_LMS) { char *s; if(team == TEAM_AXIS) { s = va("%s [%d] (%d %s)", CG_TranslateString("AXIS"), cg.teamScores[0], cg.teamPlayers[team], CG_TranslateString("PLAYERS")); s = va("%s ^3%s", s, cg.teamFirstBlood == TEAM_AXIS ? CG_TranslateString("FIRST BLOOD") : ""); CG_Text_Paint_Ext(x, y + 13, 0.25f, 0.25f, tclr, s, 0, 0, 0, &cgs.media.limboFont1); } else if(team == TEAM_ALLIES) { s = va("%s [%d] (%d %s)", CG_TranslateString("ALLIES"), cg.teamScores[1], cg.teamPlayers[team], CG_TranslateString("PLAYERS")); s = va("%s ^3%s", s, cg.teamFirstBlood == TEAM_ALLIES ? CG_TranslateString("FIRST BLOOD") : ""); CG_Text_Paint_Ext(x, y + 13, 0.25f, 0.25f, tclr, s, 0, 0, 0, &cgs.media.limboFont1); } } else { if(team == TEAM_AXIS) { CG_Text_Paint_Ext(x, y + 13, 0.25f, 0.25f, tclr, va("%s [%d] (%d %s)", CG_TranslateString("AXIS"), cg.teamScores[0], cg.teamPlayers[team], CG_TranslateString("PLAYERS")), 0, 0, 0, &cgs.media.limboFont1); } else if(team == TEAM_ALLIES) { CG_Text_Paint_Ext(x, y + 13, 0.25f, 0.25f, tclr, va("%s [%d] (%d %s)", CG_TranslateString("ALLIES"), cg.teamScores[1], cg.teamPlayers[team], CG_TranslateString("PLAYERS")), 0, 0, 0, &cgs.media.limboFont1); } } y += SMALLCHAR_HEIGHT + 3; tempx = x; // CHRUKER: b076 - Adjusted y coordinate, and changed to use DrawBottom instead of DrawTopBottom CG_FillRect(x - 5, y, width + 5, 18, clrUiBack); trap_R_SetColor(colorBlack); CG_DrawBottom_NoScale(x - 5, y, width + 5, 18, 1); trap_R_SetColor(NULL); // draw player info headings CG_DrawSmallString(tempx, y, CG_TranslateString("Name"), fade); tempx += INFO_PLAYER_WIDTH; CG_DrawSmallString(tempx, y, CG_TranslateString("Class"), fade); tempx += INFO_CLASS_WIDTH; if(cgs.gametype == GT_WOLF_LMS) { CG_DrawSmallString(tempx, y, CG_TranslateString("Score"), fade); tempx += INFO_SCORE_WIDTH; } else { CG_DrawSmallString(tempx + 1 * SMALLCHAR_WIDTH, y, CG_TranslateString("XP"), fade); tempx += INFO_XP_WIDTH; } CG_DrawSmallString(tempx, y, CG_TranslateString("Ping"), fade); tempx += INFO_LATENCY_WIDTH; if(cgs.gametype != GT_WOLF_LMS) { CG_DrawPicST(tempx + 2, y, INFO_LIVES_WIDTH - 4, 16, 0.f, 0.f, 0.5f, 1.f, team == TEAM_ALLIES ? cgs.media.hudAlliedHelmet : cgs.media.hudAxisHelmet); tempx += INFO_LIVES_WIDTH; } // CHRUKER: b076 - The math says char height + 2 * border width (1 pixel) y += SMALLCHAR_HEIGHT + 2; cg.teamPlayers[team] = 0; // JPW NERVE for(i = 0; i < cg.numScores; i++) { if(team != cgs.clientinfo[cg.scores[i].client].team) { continue; } cg.teamPlayers[team]++; } // CHRUKER: b035 - Adjust maxrows if ( cg.teamPlayers[team] > maxrows ) { maxrows = absmaxrows; use_mini_chars = qtrue; } // save off y val tempy = y; // draw color bands for ( i = 0; i < maxrows; i++ ) { if ( i % 2 == 0 ) { VectorSet( hcolor, (80.f/255.f), (80.f/255.f), (80.f/255.f) ); // LIGHT BLUE } else { VectorSet( hcolor, (0.f/255.f), (0.f/255.f), (0.f/255.f) ); // DARK BLUE } hcolor[3] = fade * 0.3; if (use_mini_chars) { // CHRUKER: b076 - Adjusted y height, and changed to DrawBottom instead of DrawTopBottom CG_FillRect( x-5, y, width+5, MINICHAR_HEIGHT, hcolor ); trap_R_SetColor( colorBlack ); CG_DrawBottom_NoScale( x-5, y, width+5, MINICHAR_HEIGHT, 1 ); trap_R_SetColor( NULL ); y += MINICHAR_HEIGHT; } else { // CHRUKER: b076 - Adjusted y height, and changed to DrawBottom instead of DrawTopBottom CG_FillRect( x-5, y, width+5, SMALLCHAR_HEIGHT, hcolor ); trap_R_SetColor( colorBlack ); CG_DrawBottom_NoScale( x-5, y, width+5, SMALLCHAR_HEIGHT, 1 ); trap_R_SetColor( NULL ); y += SMALLCHAR_HEIGHT; } } hcolor[3] = 1; y = tempy; // draw player info VectorSet( hcolor, 1, 1, 1 ); hcolor[3] = fade; count = 0; for(i = 0; i < cg.numScores && count < maxrows; i++) { if(team != cgs.clientinfo[cg.scores[i].client].team) { continue; } // CHRUKER: b035 - Using the flag instead if(use_mini_chars) { WM_DrawClientScore_Small(x, y, &cg.scores[i], hcolor, fade); y += MINICHAR_HEIGHT; } else { WM_DrawClientScore(x, y, &cg.scores[i], hcolor, fade); y += SMALLCHAR_HEIGHT; } count++; } // draw spectators // CHRUKER: b035 - Missing support for mini char height scoreboard background if (use_mini_chars) { y += MINICHAR_HEIGHT; } else { y += SMALLCHAR_HEIGHT; } for(i = 0; i < cg.numScores; i++) { if(cgs.clientinfo[cg.scores[i].client].team != TEAM_SPECTATOR) { continue; } if(team == TEAM_AXIS && (i % 2)) { continue; } if(team == TEAM_ALLIES && ((i + 1) % 2)) { continue; } // CHRUKER: b034 - Missing support for minichars; b035 - Using the flag instead if(use_mini_chars) { WM_DrawClientScore_Small( x, y, &cg.scores[i], hcolor, fade ); y += MINICHAR_HEIGHT; } else { WM_DrawClientScore( x, y, &cg.scores[i], hcolor, fade ); y += SMALLCHAR_HEIGHT; } } return y; }
int WM_DrawObjectives(int x, int y, int width, float fade) { const char *s; int rows; if (cg.snap->ps.pm_type == PM_INTERMISSION) { const char *s, *buf, *shader = NULL, *flagshader = NULL, *nameshader = NULL; rows = 8; y += 16 * (rows - 1); s = CG_ConfigString(CS_MULTI_MAPWINNER); buf = Info_ValueForKey(s, "w"); if (atoi(buf) == -1) { // "ITS A TIE!"; } else if (atoi(buf)) { // "ALLIES"; flagshader = "ui/assets/portraits/allies_win_flag.tga"; nameshader = "ui/assets/portraits/text_allies.tga"; } else { // "AXIS"; flagshader = "ui/assets/portraits/axis_win_flag.tga"; nameshader = "ui/assets/portraits/text_axis.tga"; } y += 16 * ((rows - 2) / 2); if (flagshader) { CG_DrawPic(100 + cgs.wideXoffset, 10, 210, 136, trap_R_RegisterShaderNoMip(flagshader)); CG_DrawPic(325 + cgs.wideXoffset, 10, 210, 136, trap_R_RegisterShaderNoMip(flagshader)); } if (shader) { CG_DrawPic(229 + cgs.wideXoffset, 10, 182, 136, trap_R_RegisterShaderNoMip(shader)); } if (nameshader) { CG_DrawPic(140 + cgs.wideXoffset, 50, 127, 64, trap_R_RegisterShaderNoMip(nameshader)); CG_DrawPic(365 + cgs.wideXoffset, 50, 127, 64, trap_R_RegisterShaderNoMip("ui/assets/portraits/text_win.tga")); } return y; } // mission time & reinforce time else { int msec, mins, seconds, tens, w; rows = 1; y += 13; CG_FillRect(x - 5, y - 15, width + 5, 21, clrUiBar); CG_DrawRect_FixedBorder(x - 5, y - 15, width + 5, 21, 1, colorBlack); y += 3 * (rows - 1); if (CG_ConfigString(CS_CONFIGNAME)[0]) { CG_FillRect(x - 5, y + 5, width + 5, 18, clrUiBack); CG_DrawRect_FixedBorder(x - 5, y + 5, width + 5, 18, 1, colorBlack); } if (cgs.timelimit > 0.0f) { msec = (cgs.timelimit * 60.f * 1000.f) - (cg.time - cgs.levelStartTime); seconds = msec / 1000; mins = seconds / 60; seconds -= mins * 60; tens = seconds / 10; seconds -= tens * 10; } else { msec = mins = tens = seconds = 0; } if (cgs.gamestate != GS_PLAYING) { s = va("%s %s", CG_TranslateString("MISSION TIME:"), CG_TranslateString("WARMUP")); } else if (msec < 0 && cgs.timelimit > 0.0f) { if (cgs.gamestate == GS_WAITING_FOR_PLAYERS) { s = va("%s %s", CG_TranslateString("MISSION TIME:"), CG_TranslateString("GAME STOPPED")); } else { s = va("%s %s", CG_TranslateString("MISSION TIME:"), CG_TranslateString("SUDDEN DEATH")); } } else { s = va("%s %2.0f:%i%i", CG_TranslateString("MISSION TIME:"), (float)mins, tens, seconds); // float cast to line up with reinforce time } CG_Text_Paint_Ext(x, y, 0.25f, 0.25f, tclr, s, 0, 0, 0, &cgs.media.limboFont1); if (cg.warmup) { s = va("%s %i", CG_TranslateString("MATCH BEGINS IN:"), (cg.warmup - cg.time) / 1000 + 1); CG_Text_Paint_Ext(SCREEN_WIDTH - 20 - CG_Text_Width_Ext(s, 0.25f, 0, &cgs.media.limboFont1) + cgs.wideXoffset, y, 0.25f, 0.25f, tclr, s, 0, 0, 0, &cgs.media.limboFont1); } else if ((cgs.gamestate == GS_WARMUP && !cg.warmup) || cgs.gamestate == GS_WAITING_FOR_PLAYERS) { s = va(CG_TranslateString("WAITING ON %i %s"), cgs.minclients, cgs.minclients == 1 ? CG_TranslateString("PLAYER") : CG_TranslateString("PLAYERS")); CG_Text_Paint_Ext(SCREEN_WIDTH - 20 - CG_Text_Width_Ext(s, 0.25f, 0, &cgs.media.limboFont1) + cgs.wideXoffset, y, 0.25f, 0.25f, tclr, s, 0, 0, 0, &cgs.media.limboFont1); } else if (cgs.gametype != GT_WOLF_LMS && !cg.warmup) { if (cgs.clientinfo[cg.snap->ps.clientNum].team == TEAM_AXIS || cgs.clientinfo[cg.snap->ps.clientNum].team == TEAM_ALLIES) { msec = CG_CalculateReinfTime(qfalse) * 1000; } else // no team (spectator mode) { msec = 0; } if (msec) { seconds = msec / 1000; mins = seconds / 60; seconds -= mins * 60; tens = seconds / 10; seconds -= tens * 10; s = va("%s %2.0f:%i%i", CG_TranslateString("REINFORCE TIME:"), (float)mins, tens, seconds); CG_Text_Paint_Ext(SCREEN_WIDTH - 20 - CG_Text_Width_Ext(s, 0.25f, 0, &cgs.media.limboFont1) + cgs.wideXoffset, y, 0.25f, 0.25f, tclr, s, 0, 0, 0, &cgs.media.limboFont1); } } switch (cgs.gametype) { case GT_WOLF_STOPWATCH: s = va("%s %i", CG_TranslateString("STOPWATCH ROUND"), cgs.currentRound + 1); w = CG_Text_Width_Ext(s, 0.25f, 0, &cgs.media.limboFont1); CG_Text_Paint_Ext(x + 300 - w * 0.5f, y, 0.25f, 0.25f, tclr, s, 0, 0, 0, &cgs.media.limboFont1); break; case GT_WOLF_LMS: s = va("%s %i %s %i-%i", CG_TranslateString("ROUND"), cgs.currentRound + 1, CG_TranslateString("SCORE"), cg.teamWonRounds[1], cg.teamWonRounds[0]); w = CG_Text_Width_Ext(s, 0.25f, 0, &cgs.media.limboFont1); CG_Text_Paint_Ext(x + 300 - w * 0.5f, y, 0.25f, 0.25f, tclr, s, 0, 0, 0, &cgs.media.limboFont1); break; case GT_WOLF_CAMPAIGN: s = va(CG_TranslateString("MAP %i of %i"), cgs.currentCampaignMap + 1, cgs.campaignData.mapCount); w = CG_Text_Width_Ext(s, 0.25f, 0, &cgs.media.limboFont1); CG_Text_Paint_Ext(x + 300 - w * 0.5f, y, 0.25f, 0.25f, tclr, s, 0, 0, 0, &cgs.media.limboFont1); break; case GT_WOLF_MAPVOTE: s = (cgs.mapVoteMapY ? va(CG_TranslateString("MAP %i of %i"), cgs.mapVoteMapX + 1, cgs.mapVoteMapY) : ""); w = CG_Text_Width_Ext(s, 0.25f, 0, &cgs.media.limboFont1); CG_Text_Paint_Ext(x + 300 - w * 0.5f, y, 0.25f, 0.25f, tclr, s, 0, 0, 0, &cgs.media.limboFont1); break; default: break; } y += 18; if (CG_ConfigString(CS_CONFIGNAME)[0]) { s = va(CG_TranslateString("Config: ^7%s^7"), CG_ConfigString(CS_CONFIGNAME)); CG_Text_Paint_Ext(x, y, 0.24f, 0.28f, tclr, s, 0, 0, ITEM_TEXTSTYLE_SHADOWED, &cgs.media.limboFont2_lo); y += 18; } } return y; }
static int WM_TeamScoreboard(int x, int y, team_t team, float fade, int maxrows, int absmaxrows) { vec4_t hcolor; float tempx, tempy; int i; int count = 0; int width = INFO_TOTAL_WIDTH; qboolean use_mini_chars = qfalse, livesleft = qfalse; const char *buffer = CG_ConfigString(CS_SERVERINFO); const char *str = Info_ValueForKey(buffer, "g_maxlives"); if (str && *str && atoi(str)) { livesleft = qtrue; } if (!livesleft) { str = Info_ValueForKey(buffer, "g_alliedmaxlives"); if (str && *str && atoi(str)) { livesleft = qtrue; } } if (!livesleft) { str = Info_ValueForKey(buffer, "g_axismaxlives"); if (str && *str && atoi(str)) { livesleft = qtrue; } } CG_FillRect(x - 5, y - 2, width + 5, 21, clrUiBack); CG_FillRect(x - 5, y - 2, width + 5, 21, clrUiBar); Vector4Set(hcolor, 0, 0, 0, fade); CG_DrawRect_FixedBorder(x - 5, y - 2, width + 5, 21, 1, colorBlack); // draw header if (cg_gameType.integer == GT_WOLF_LMS) { char *s; if (team == TEAM_AXIS) { s = va("%s [%d] (%d %s)", CG_TranslateString("AXIS"), cg.teamScores[0], cg.teamPlayers[team], CG_TranslateString("PLAYERS")); s = va("%s ^3%s", s, cg.teamFirstBlood == TEAM_AXIS ? CG_TranslateString("FIRST BLOOD") : ""); CG_Text_Paint_Ext(x, y + 13, 0.25f, 0.25f, tclr, s, 0, 0, 0, &cgs.media.limboFont1); } else if (team == TEAM_ALLIES) { s = va("%s [%d] (%d %s)", CG_TranslateString("ALLIES"), cg.teamScores[1], cg.teamPlayers[team], CG_TranslateString("PLAYERS")); s = va("%s ^3%s", s, cg.teamFirstBlood == TEAM_ALLIES ? CG_TranslateString("FIRST BLOOD") : ""); CG_Text_Paint_Ext(x, y + 13, 0.25f, 0.25f, tclr, s, 0, 0, 0, &cgs.media.limboFont1); } } else { if (team == TEAM_AXIS) { CG_Text_Paint_Ext(x, y + 13, 0.25f, 0.25f, tclr, va("%s [%d] (%d %s)", CG_TranslateString("AXIS"), cg.teamScores[0], cg.teamPlayers[team], CG_TranslateString("PLAYERS")), 0, 0, 0, &cgs.media.limboFont1); } else if (team == TEAM_ALLIES) { CG_Text_Paint_Ext(x, y + 13, 0.25f, 0.25f, tclr, va("%s [%d] (%d %s)", CG_TranslateString("ALLIES"), cg.teamScores[1], cg.teamPlayers[team], CG_TranslateString("PLAYERS")), 0, 0, 0, &cgs.media.limboFont1); } } y += 19; tempx = x; CG_FillRect(x - 5, y, width + 5, 18, clrUiBack); trap_R_SetColor(colorBlack); CG_DrawBottom_NoScale(x - 5, y, width + 5, 18, 1); trap_R_SetColor(NULL); // draw player info headings CG_Text_Paint_Ext(tempx, y + 13, 0.24, 0.28, colorWhite, CG_TranslateString("Name"), 0, 0, ITEM_TEXTSTYLE_SHADOWED, &cgs.media.limboFont2_lo); tempx += INFO_PLAYER_WIDTH; // add some extra space when not showing lives in non-LMS if (cg_gameType.integer != GT_WOLF_LMS && !livesleft) { tempx += INFO_LIVES_WIDTH; } CG_Text_Paint_Ext(tempx, y + 13, 0.24, 0.28, colorWhite, CG_TranslateString("C R"), 0, 0, ITEM_TEXTSTYLE_SHADOWED, &cgs.media.limboFont2_lo); tempx += INFO_CLASS_WIDTH; if (cgs.gametype == GT_WOLF_LMS) { CG_Text_Paint_Ext(tempx, y + 13, 0.24, 0.28, colorWhite, CG_TranslateString("Score"), 0, 0, ITEM_TEXTSTYLE_SHADOWED, &cgs.media.limboFont2_lo); tempx += INFO_SCORE_WIDTH; } else { CG_Text_Paint_Ext(tempx + 8, y + 13, 0.24, 0.28, colorWhite, CG_TranslateString("XP"), 0, 0, ITEM_TEXTSTYLE_SHADOWED, &cgs.media.limboFont2_lo); tempx += INFO_XP_WIDTH; } CG_Text_Paint_Ext(tempx, y + 13, 0.24, 0.28, colorWhite, CG_TranslateString("Ping"), 0, 0, ITEM_TEXTSTYLE_SHADOWED, &cgs.media.limboFont2_lo); tempx += INFO_LATENCY_WIDTH; if (cgs.gametype != GT_WOLF_LMS && livesleft) { CG_DrawPicST(tempx + 2, y, INFO_LIVES_WIDTH - 4, 16, 0.f, 0.f, 0.5f, 1.f, team == TEAM_ALLIES ? cgs.media.hudAlliedHelmet : cgs.media.hudAxisHelmet); tempx += INFO_LIVES_WIDTH; } y += 18; cg.teamPlayers[team] = 0; for (i = 0; i < cg.numScores; i++) { if (team != cgs.clientinfo[cg.scores[i].client].team) { continue; } cg.teamPlayers[team]++; } if (cg.teamPlayers[team] > maxrows) { maxrows = absmaxrows; use_mini_chars = qtrue; } // save off y val tempy = y; // draw color bands for (i = 0; i < maxrows; i++) { if (i % 2 == 0) { VectorSet(hcolor, (80.f / 255.f), (80.f / 255.f), (80.f / 255.f)); // LIGHT BLUE } else { VectorSet(hcolor, (0.f / 255.f), (0.f / 255.f), (0.f / 255.f)); // DARK BLUE } hcolor[3] = fade * 0.3; if (use_mini_chars) { CG_FillRect(x - 5, y, width + 5, 12, hcolor); trap_R_SetColor(colorBlack); CG_DrawBottom_NoScale(x - 5, y, width + 5, 12, 1); trap_R_SetColor(NULL); y += 12; } else { CG_FillRect(x - 5, y, width + 5, 16, hcolor); trap_R_SetColor(colorBlack); CG_DrawBottom_NoScale(x - 5, y, width + 5, 16, 1); trap_R_SetColor(NULL); y += 16; } } hcolor[3] = 1; y = tempy; // draw player info VectorSet(hcolor, 1, 1, 1); hcolor[3] = fade; for (i = 0; i < cg.numScores && count < maxrows; i++) { if (team != cgs.clientinfo[cg.scores[i].client].team) { continue; } if (use_mini_chars) { WM_DrawClientScore_Small(x, y, &cg.scores[i], hcolor, fade, livesleft); y += 12; } else { WM_DrawClientScore(x, y, &cg.scores[i], hcolor, fade, livesleft); y += 16; } count++; } // draw spectators if (use_mini_chars) { y += 12; } else { y += 16; } for (i = 0; i < cg.numScores; i++) { if (cgs.clientinfo[cg.scores[i].client].team != TEAM_SPECTATOR) { continue; } if (team == TEAM_AXIS && (i % 2)) { continue; } if (team == TEAM_ALLIES && ((i + 1) % 2)) { continue; } if (use_mini_chars) { WM_DrawClientScore_Small(x, y, &cg.scores[i], hcolor, fade, livesleft); y += 12; } else { WM_DrawClientScore(x, y, &cg.scores[i], hcolor, fade, livesleft); y += 16; } } return y; }
static int WM_DrawInfoLine(int x, int y, float fade) { int w, defender, winner; const char *s; if (cg.snap->ps.pm_type != PM_INTERMISSION) { return y; } w = 360; s = CG_ConfigString(CS_MULTI_INFO); defender = atoi(Info_ValueForKey(s, "d")); // defender s = CG_ConfigString(CS_MULTI_MAPWINNER); winner = atoi(Info_ValueForKey(s, "w")); if (cgs.currentRound) { // first round s = va(CG_TranslateString("CLOCK IS NOW SET TO %s!"), WM_TimeToString(cgs.nextTimeLimit * 60.f * 1000.f)); } else { // second round if (!defender) { if (winner != defender) { s = "ALLIES SUCCESSFULLY BEAT THE CLOCK!"; } else { s = "ALLIES COULDN'T BEAT THE CLOCK!"; } } else { if (winner != defender) { s = "AXIS SUCCESSFULLY BEAT THE CLOCK!"; } else { s = "AXIS COULDN'T BEAT THE CLOCK!"; } } s = CG_TranslateString(s); } CG_FillRect(Ccg_WideX(320) - w / 2, y, w, 20, clrUiBar); CG_DrawRect_FixedBorder(Ccg_WideX(320) - w / 2, y, w, 20, 1, colorBlack); w = CG_Text_Width_Ext(s, 0.25f, 0, &cgs.media.limboFont1); CG_Text_Paint_Ext(Ccg_WideX(320) - w * 0.5f, y + 15, 0.25f, 0.25f, tclr, s, 0, 0, 0, &cgs.media.limboFont1); return y + INFO_LINE_HEIGHT + 6; }
/** * @brief CG_FilledBar */ void CG_FilledBar(float x, float y, float w, float h, float *startColor, float *endColor, const float *bgColor, float frac, int flags) { vec4_t backgroundcolor = { 1, 1, 1, 0.25f }, colorAtPos; // colorAtPos is the lerped color if necessary if (frac > 1) { frac = 1.f; } if (frac < 0) { frac = 0; } if ((flags & BAR_BG) && bgColor) // BAR_BG set, and color specified, use specified bg color { Vector4Copy(bgColor, backgroundcolor); } if (flags & BAR_LERP_COLOR) { Vector4Average(startColor, endColor, frac, colorAtPos); } // background if ((flags & BAR_BG)) { int indent = BAR_BORDERSIZE; // draw background at full size and shrink the remaining box to fit inside with a border. (alternate border may be specified by a BAR_BGSPACING_xx) CG_FillRect(x, y, w, h, backgroundcolor); if (flags & BAR_BGSPACING_X0Y0) // fill the whole box (no border) { } else if (flags & BAR_BGSPACING_X0Y5) // spacing created for weapon heat { indent *= 3; y += indent; h -= (2 * indent); } else // default spacing of 2 units on each side { x += indent; y += indent; w -= (2 * indent); h -= (2 * indent); } } else if ((flags & BAR_BORDER) || (flags & BAR_BORDER_SMALL)) { int indent = (flags & BAR_BORDER_SMALL ? 1 : BAR_BORDERSIZE); CG_DrawRect_FixedBorder(x, y, w, h, indent, bgColor); x += indent; y += indent; w -= indent; h -= (2 * indent); } // adjust for horiz/vertical and draw the fractional box if (flags & BAR_VERT) { if (flags & BAR_LEFT) // TODO: remember to swap colors on the ends here { y += (h * (1 - frac)); } else if (flags & BAR_CENTER) { y += (h * (1 - frac) / 2); } if (flags & BAR_LERP_COLOR) { CG_FillRect(x, y, w, h * frac, colorAtPos); } else { CG_FillRect(x, y, w, h * frac, startColor); } } else { if (flags & BAR_LEFT) // TODO: remember to swap colors on the ends here { x += (w * (1 - frac)); } else if (flags & BAR_CENTER) { x += (w * (1 - frac) / 2); } if (flags & BAR_LERP_COLOR) { CG_FillRect(x, y, w * frac, h, colorAtPos); } else { CG_FillRect(x, y, w * frac, h, startColor); } } }
/* New ETrun draw spectators function * * @author Nico */ static void WM_ETrun_DrawSpectators(int *x, int *y, fontInfo_t *font, s_timerunScores *orderedScores, int numScores) { char *s; int tempx = 0; float fontsize = 0.16f; int i = 0; int mil, min, sec; // Draw "Spectators" s = "Spectators"; tempx = *x + INFO_SPEC_TOTAL_WIDTH / 2 - CG_Text_Width_Ext(s, 0.25f, 0, &cgs.media.limboFont1) / 2; WM_ETrun_print(s, font, 0.25f, tempx, *y, qtrue, 0); WM_ETrun_newlines(1, y, SMALLCHAR_HEIGHT); // Draw player info headings background CG_FillRect(*x, *y, INFO_SPEC_TOTAL_WIDTH, INFO_LINE_HEIGHT, clrUiBack); CG_DrawRect_FixedBorder(*x, *y, INFO_SPEC_TOTAL_WIDTH, INFO_LINE_HEIGHT, 1, colorBlack); *y += INFO_LINE_HEIGHT - 2; // Draw spec info headings tempx = *x; WM_ETrun_print("Name", font, fontsize, tempx, *y, qtrue, 0); tempx += INFO_SPEC_PLAYER_WIDTH; WM_ETrun_print("Following", font, fontsize, tempx, *y, qtrue, 0); tempx += INFO_SPEC_FOLLOWED_PLAYER_WIDTH; WM_ETrun_print("Time", font, fontsize, tempx, *y, qtrue, 0); tempx += INFO_SPEC_SCORE_WIDTH; WM_ETrun_print("Speed", font, fontsize, tempx, *y, qtrue, 0); tempx += INFO_SPEC_SPEED_WIDTH; WM_ETrun_print("Ping", font, fontsize, tempx, *y, qtrue, 0); tempx += INFO_SPEC_LATENCY_WIDTH; for (i = 0; i < numScores; ++i) { qboolean drawFlag = qfalse; // Ignore non-spectators if (orderedScores[i].team != TEAM_SPECTATOR) { continue; } tempx = *x; *y += 4; // Draw background (highlight your line) CG_FillRect(*x, *y, INFO_SPEC_TOTAL_WIDTH, INFO_LINE_HEIGHT, orderedScores[i].clientNum == cg.clientNum ? clrUiYou : clrUiBack); CG_DrawRect_FixedBorder(*x, *y, INFO_SPEC_TOTAL_WIDTH, INFO_LINE_HEIGHT, 1, colorBlack); *y += INFO_LINE_HEIGHT - 2; // Nico, draw country flag if (cg_countryFlags.integer) { if (WM_ETrun_drawCountryFlag(tempx, *y, orderedScores[i].countryCode)) { tempx += 16; drawFlag = qtrue; } } // Nico, draw player name WM_ETrun_print(orderedScores[i].name, font, fontsize, tempx, *y, qtrue, drawFlag == qfalse ? NAME_MAX_LENGHT : NAME_MAX_LENGHT - 3); tempx += drawFlag == qfalse ? INFO_PLAYER_WIDTH : INFO_PLAYER_WIDTH - 16; // Nico, draw followed client name if (orderedScores[i].clientNum != orderedScores[i].followedClient) { s = orderedScores[i].followedClientName; } else { s = "-"; } WM_ETrun_print(s, font, fontsize, tempx, *y, qtrue, NAME_MAX_LENGHT); tempx += INFO_SPEC_FOLLOWED_PLAYER_WIDTH; // Nico, show best time if (orderedScores[i].timerunBestTime) { mil = orderedScores[i].timerunBestTime; min = mil / 60000; mil -= min * 60000; sec = mil / 1000; mil -= sec * 1000; s = va("^7%02d:%02d.%03d", min, sec, mil); } else { s = "-"; } WM_ETrun_print(s, font, fontsize, tempx, *y, qtrue, 0); tempx += INFO_SPEC_SCORE_WIDTH; // Nico, draw best speed WM_ETrun_print(va("%d", orderedScores[i].timerunBestSpeed), font, fontsize, tempx, *y, qtrue, 0); tempx += INFO_SPEC_SPEED_WIDTH; // Nico, draw ping WM_ETrun_print(WM_ETrun_coloredPing(orderedScores[i].ping), font, fontsize, tempx, *y, qtrue, 0); tempx += INFO_SPEC_LATENCY_WIDTH; } }
/* New ETrun draw players function * * @author Nico */ static void WM_ETrun_DrawPlayers(int *x, int *y, fontInfo_t *font, s_timerunScores *orderedScores, int numScores) { char *s; int tempx = 0; float fontsize = 0.16f; int i = 0; int mil, min, sec; char status[MAX_QPATH] = { 0 }; // Draw "Players" s = "Players"; tempx = *x + INFO_TOTAL_WIDTH / 2 - CG_Text_Width_Ext(s, 0.25f, 0, &cgs.media.limboFont1) / 2; WM_ETrun_print(s, font, 0.25f, tempx, *y, qtrue, 0); WM_ETrun_newlines(1, y, SMALLCHAR_HEIGHT); // Draw player info headings background CG_FillRect(*x, *y, INFO_TOTAL_WIDTH, INFO_LINE_HEIGHT, clrUiBack); CG_DrawRect_FixedBorder(*x, *y, INFO_TOTAL_WIDTH, INFO_LINE_HEIGHT, 1, colorBlack); *y += INFO_LINE_HEIGHT - 2; // Draw player info headings tempx = *x; WM_ETrun_print("Name", font, fontsize, tempx, *y, qtrue, 0); tempx += INFO_PLAYER_WIDTH; WM_ETrun_print("Team", font, fontsize, tempx, *y, qtrue, 0); tempx += INFO_TEAM_WIDTH; WM_ETrun_print("Time", font, fontsize, tempx, *y, qtrue, 0); tempx += INFO_SCORE_WIDTH; WM_ETrun_print("Speed", font, fontsize, tempx, *y, qtrue, 0); tempx += INFO_SPEED_WIDTH; WM_ETrun_print("Ping", font, fontsize, tempx, *y, qtrue, 0); tempx += INFO_LATENCY_WIDTH; WM_ETrun_print("Status", font, fontsize, tempx, *y, qtrue, 0); tempx += INFO_STATE_WIDTH; for (i = 0; i < numScores; ++i) { qboolean drawFlag = qfalse; // Ignore spectators if (orderedScores[i].team == TEAM_SPECTATOR) { continue; } tempx = *x; *y += 4; // Draw background (highlight your line) CG_FillRect(*x, *y, INFO_TOTAL_WIDTH, INFO_LINE_HEIGHT, orderedScores[i].clientNum == cg.clientNum ? clrUiYou : clrUiBack); CG_DrawRect_FixedBorder(*x, *y, INFO_TOTAL_WIDTH, INFO_LINE_HEIGHT, 1, colorBlack); *y += INFO_LINE_HEIGHT - 2; // Nico, draw country flag if (cg_countryFlags.integer) { if (WM_ETrun_drawCountryFlag(tempx, *y, orderedScores[i].countryCode)) { tempx += 16; drawFlag = qtrue; } } // Nico, draw player name WM_ETrun_print(orderedScores[i].name, font, fontsize, tempx, *y, qtrue, drawFlag == qfalse ? NAME_MAX_LENGHT : NAME_MAX_LENGHT - 3); tempx += drawFlag == qfalse ? INFO_PLAYER_WIDTH : INFO_PLAYER_WIDTH - 16; // Nico, draw team if (orderedScores[i].team == TEAM_AXIS) { s = "^1Axis"; } else { s = "^4Allies"; } WM_ETrun_print(s, font, fontsize, tempx, *y, qtrue, 0); tempx += INFO_TEAM_WIDTH; // Nico, show best time if (orderedScores[i].timerunBestTime) { mil = orderedScores[i].timerunBestTime; min = mil / 60000; mil -= min * 60000; sec = mil / 1000; mil -= sec * 1000; s = va("^7%02d:%02d.%03d", min, sec, mil); } else { s = "-"; } WM_ETrun_print(s, font, fontsize, tempx, *y, qtrue, 0); tempx += INFO_SCORE_WIDTH; // Nico, draw best speed WM_ETrun_print(va("%d", orderedScores[i].timerunBestSpeed), font, fontsize, tempx, *y, qtrue, 0); tempx += INFO_SPEED_WIDTH; // Nico, draw ping WM_ETrun_print(WM_ETrun_coloredPing(orderedScores[i].ping), font, fontsize, tempx, *y, qtrue, 0); tempx += INFO_LATENCY_WIDTH; // Nico, reset status memset(status, 0, sizeof (status)); // Nico, draw status if (orderedScores[i].timerunStatus == 1) { Q_strcat(status, sizeof (status), "^2R "); } if (orderedScores[i].clientLogged == 1) { Q_strcat(status, sizeof (status), "^7L "); } if (orderedScores[i].clientCGaz == 1) { Q_strcat(status, sizeof (status), "^8C "); } if (orderedScores[i].clientHidden == 1) { Q_strcat(status, sizeof (status), "^9H "); } if (orderedScores[i].speclocked == 1) { Q_strcat(status, sizeof (status), "^bS "); } if (status[0] == '\0') { Q_strncpyz(status, "-", sizeof (status)); } WM_ETrun_print(status, font, fontsize, tempx, *y, qtrue, 0); tempx += INFO_STATE_WIDTH; } WM_ETrun_newlines(2, y, SMALLCHAR_HEIGHT); }
int WM_DrawObjectives(int x, int y, int width, float fade) { const char *s; int rows; if (cg.snap->ps.pm_type == PM_INTERMISSION) { const char *s, *buf, *shader = NULL, *flagshader = NULL, *nameshader = NULL; rows = 8; y += SMALLCHAR_HEIGHT * (rows - 1); s = CG_ConfigString(CS_MULTI_MAPWINNER); buf = Info_ValueForKey(s, "winner"); if (atoi(buf) == -1) { // "ITS A TIE!"; } else if (atoi(buf)) { // "ALLIES"; flagshader = "ui/assets/portraits/allies_win_flag.tga"; nameshader = "ui/assets/portraits/text_allies.tga"; } else { // "AXIS"; flagshader = "ui/assets/portraits/axis_win_flag.tga"; nameshader = "ui/assets/portraits/text_axis.tga"; } y += SMALLCHAR_HEIGHT * ((rows - 2) / 2); if (flagshader) { CG_DrawPic(100 + cgs.wideXoffset, 10, 210, 136, trap_R_RegisterShaderNoMip(flagshader)); CG_DrawPic(325 + cgs.wideXoffset, 10, 210, 136, trap_R_RegisterShaderNoMip(flagshader)); } if (shader) { CG_DrawPic(229 + cgs.wideXoffset, 10, 182, 136, trap_R_RegisterShaderNoMip(shader)); } if (nameshader) { CG_DrawPic(140 + cgs.wideXoffset, 50, 127, 64, trap_R_RegisterShaderNoMip(nameshader)); CG_DrawPic(365 + cgs.wideXoffset, 50, 127, 64, trap_R_RegisterShaderNoMip("ui/assets/portraits/text_win.tga")); } return y; } // mission time & reinforce time else { int msec, mins, seconds, tens; rows = 1; CG_FillRect(x - 5, y - 2, width + 5, 21, clrUiBack); CG_FillRect(x - 5, y - 2, width + 5, 21, clrUiBar); CG_DrawRect_FixedBorder(x - 5, y - 2, width + 5, 21, 1, colorBlack); y += SMALLCHAR_HEIGHT * (rows - 1); if (cgs.timelimit > 0.0f) { msec = (cgs.timelimit * 60.f * 1000.f) - (cg.time - cgs.levelStartTime); seconds = msec / 1000; mins = seconds / 60; seconds -= mins * 60; tens = seconds / 10; seconds -= tens * 10; } else { msec = mins = tens = seconds = 0; } if (cgs.gamestate != GS_PLAYING) { s = va("%s %s", CG_TranslateString("MISSION TIME:"), CG_TranslateString("WARMUP")); } else if (msec < 0 && cgs.timelimit > 0.0f) { if (cgs.gamestate == GS_WAITING_FOR_PLAYERS) { s = va("%s %s", CG_TranslateString("MISSION TIME:"), CG_TranslateString("GAME STOPPED")); } else { s = va("%s %s", CG_TranslateString("MISSION TIME:"), CG_TranslateString("SUDDEN DEATH")); } } else { s = va("%s %2.0f:%i%i", CG_TranslateString("MISSION TIME:"), (float)mins, tens, seconds); // float cast to line up with reinforce time } CG_Text_Paint_Ext(x, y + 13, 0.25f, 0.25f, tclr, s, 0, 0, 0, &cgs.media.limboFont1); // FIXME: do a switch for gametype if (cgs.gametype != GT_WOLF_LMS) { if (cgs.clientinfo[cg.snap->ps.clientNum].team == TEAM_AXIS || cgs.clientinfo[cg.snap->ps.clientNum].team == TEAM_ALLIES) { msec = CG_CalculateReinfTime(qfalse) * 1000; } else // no team (spectator mode) { msec = 0; } if (msec) { seconds = msec / 1000; mins = seconds / 60; seconds -= mins * 60; tens = seconds / 10; seconds -= tens * 10; s = va("%s %2.0f:%i%i", CG_TranslateString("REINFORCE TIME:"), (float)mins, tens, seconds); CG_Text_Paint_Ext(640 - 20 - CG_Text_Width_Ext(s, 0.25f, 0, &cgs.media.limboFont1) + cgs.wideXoffset, y + 13, 0.25f, 0.25f, tclr, s, 0, 0, 0, &cgs.media.limboFont1); } } if (cgs.gametype == GT_WOLF_STOPWATCH) { int w; s = va("%s %i", CG_TranslateString("STOPWATCH ROUND"), cgs.currentRound + 1); w = CG_Text_Width_Ext(s, 0.25f, 0, &cgs.media.limboFont1); CG_Text_Paint_Ext(x + 300 - w * 0.5f, y + 13, 0.25f, 0.25f, tclr, s, 0, 0, 0, &cgs.media.limboFont1); } else if (cgs.gametype == GT_WOLF_LMS) { int w; s = va("%s %i %s %i-%i", CG_TranslateString("ROUND"), cgs.currentRound + 1, CG_TranslateString("SCORE"), cg.teamWonRounds[1], cg.teamWonRounds[0]); w = CG_Text_Width_Ext(s, 0.25f, 0, &cgs.media.limboFont1); CG_Text_Paint_Ext(x + 300 - w * 0.5f, y + 13, 0.25f, 0.25f, tclr, s, 0, 0, 0, &cgs.media.limboFont1); } else if (cgs.gametype == GT_WOLF_CAMPAIGN) { int w; s = va("MAP %i of %i", cgs.currentCampaignMap + 1, cgs.campaignData.mapCount); w = CG_Text_Width_Ext(s, 0.25f, 0, &cgs.media.limboFont1); CG_Text_Paint_Ext(x + 300 - w * 0.5f, y + 13, 0.25f, 0.25f, tclr, s, 0, 0, 0, &cgs.media.limboFont1); } // MAPVOTE else if (cgs.gametype == GT_WOLF_MAPVOTE) { int w; s = (cgs.mapVoteMapY ? va("MAP %i of %i", cgs.mapVoteMapX + 1, cgs.mapVoteMapY) : ""); w = CG_Text_Width_Ext(s, 0.25f, 0, &cgs.media.limboFont1); CG_Text_Paint_Ext(x + 300 - w * 0.5f, y + 13, 0.25f, 0.25f, tclr, s, 0, 0, 0, &cgs.media.limboFont1); } y += SMALLCHAR_HEIGHT * 2; } return y; }
static float CG_DrawFPS(float y) { static int previousTimes[MAX_FPS_FRAMES]; static int previous; static int index; static int oldSamples; char *s; int t = trap_Milliseconds(); // don't use serverTime, because that will be drifting to correct for internet lag changes, timescales, timedemos, etc int frameTime = t - previous; int x, w, w2; int samples = cg_drawFPS.integer; previous = t; if (samples < 4) { samples = 4; } if (samples > MAX_FPS_FRAMES) { samples = MAX_FPS_FRAMES; } if (samples != oldSamples) { index = 0; } oldSamples = samples; previousTimes[index % samples] = frameTime; index++; if (index > samples) { int i, fps; // average multiple frames together to smooth changes out a bit int total = 0; for (i = 0 ; i < samples ; ++i) { total += previousTimes[i]; } total = total ? total : 1; fps = 1000 * samples / total; s = va("%i FPS", fps); } else { s = "estimating"; } w = CG_Text_Width_Ext(s, 0.19f, 0, &cgs.media.limboFont1); w2 = (UPPERRIGHT_W > w) ? UPPERRIGHT_W : w; x = (int)(Ccg_WideX(UPPERRIGHT_X)) - w2 - 2; CG_FillRect(x, y, w2 + 5, 12 + 2, HUD_Background); CG_DrawRect_FixedBorder(x, y, w2 + 5, 12 + 2, 1, HUD_Border); CG_Text_Paint_Ext(x + ((w2 - w) / 2) + 2, y + 11, 0.19f, 0.19f, HUD_Text, s, 0, 0, 0, &cgs.media.limboFont1); return y + 12 + 4; }