static float CG_OwnerDrawWidth (int ownerDraw, float scale, int fontIndex) { const fontInfo_t *font; const char *s; if (fontIndex <= 0) { font = &cgDC.Assets.textFont; } else { font = &cgDC.Assets.extraFonts[fontIndex]; } switch (ownerDraw) { case CG_GAME_TYPE: return CG_Text_Width(CG_GameTypeString(), scale, 0, font); case CG_GAME_STATUS: return CG_Text_Width(CG_GetGameStatusText(), scale, 0, font); break; case CG_KILLER: return CG_Text_Width(CG_GetKillerText(), scale, 0, font); break; case CG_RED_NAME: //return CG_Text_Width(cg_redTeamName.string, scale, 0, font); return CG_Text_Width(cgs.redTeamName, scale, 0, font); break; case CG_BLUE_NAME: //return CG_Text_Width(cg_blueTeamName.string, scale, 0, font); return CG_Text_Width(cgs.blueTeamName, scale, 0, font); break; case UI_KEYBINDSTATUS: if (Display_KeyBindPending()) { s = "Waiting for new key... Press ESCAPE to cancel"; } else { s = "Press ENTER or CLICK to change, Press BACKSPACE to clear"; } return CG_Text_Width(s, scale, 0, font); break; default: Com_Printf("CG_OwnerDrawWidth() unknown ownerDraw %d\n", ownerDraw); break; } return 0; }
static void CG_DrawGameStatus(rectDef_t *rect, float scale, vector4 *color, qhandle_t shader, int textStyle ) { CG_Text_Paint(rect->x, rect->y + rect->h, scale, color, CG_GetGameStatusText(), 0, 0, textStyle); }
/* ================= CG_DrawQ3Scoreboard Draw the normal in-game scoreboard ================= */ qboolean CG_DrawQ3Scoreboard( void ) { int x, y, w, i, n1, n2; float *fadeColor, fade; char *s; int maxClients; int lineHeight; int topBorderSize, bottomBorderSize; // don't draw anything if the menu or console is up if ( cg_paused.integer ) { cg.deferredPlayerLoading = 0; return qfalse; } if ( cgs.gametype == GT_SINGLE_PLAYER && cg.predictedPlayerState.pm_type == PM_INTERMISSION ) { cg.deferredPlayerLoading = 0; return qfalse; } // don't draw scoreboard during death while warmup up if ( cg.warmup && !cg.showScores && cg.time > cg.scoreFadeTime + FADE_TIME ) { return qfalse; } //#if 0 if ( cg.showScores || cg.predictedPlayerState.pm_type == PM_DEAD || cg.predictedPlayerState.pm_type == PM_INTERMISSION ) { fadeColor = colorWhite; } else { fadeColor = CG_FadeColor( cg.scoreFadeTime, FADE_TIME ); if ( !fadeColor ) { // next time scoreboard comes up, don't print killer cg.deferredPlayerLoading = 0; cg.killerName[0] = 0; return qfalse; } } //#endif //fadeColor = colorWhite; fade = fadeColor[3]; //#if 0 // request more scores regularly if ( cg.scoresRequestTime + 2000 < cg.time ) { cg.scoresRequestTime = cg.time; trap_SendClientCommand( "score" ); } //CG_Printf( "scoresRequestTime = %i\n", cg.scoresRequestTime ); //CG_Printf( "scoreFadeTime = %i, fade = %f\n", cg.scoreFadeTime, fade ); //#endif // fragged by ... line if ( !cg.warmup ) { if ( cg.killerName[0] ) { s = va( "Fragged by %s", cg.killerName ); y = 40; if ( cg_highResFonts.integer ) { float scale = 0.35; int h; w = CG_Text_Width(s, scale, 0); h = CG_Text_Height(s, scale, 0); x = (SCREEN_WIDTH - w) / 2; CG_Text_Paint( x, y + h, scale, fadeColor, s, 0, 0, ITEM_TEXTSTYLE_SHADOWED, SCR_CENTER ); } else { w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH; x = ( SCREEN_WIDTH - w ) / 2; CG_DrawBigString( x, y, s, fade, SCR_CENTER ); } } // current rank { s = CG_GetGameStatusText(); if ( s[0] ) { y = 60; if ( cg_highResFonts.integer ) { float scale = 0.35f; int h; w = CG_Text_Width(s, scale, 0); h = CG_Text_Height(s, scale, 0); x = (SCREEN_WIDTH - w) / 2; CG_Text_Paint( x, y + h, scale, fadeColor, s, 0, 0, ITEM_TEXTSTYLE_SHADOWED, SCR_CENTER ); } else { w = CG_DrawStrlen( s ) * BIGCHAR_WIDTH; x = ( SCREEN_WIDTH - w ) / 2; CG_DrawBigString( x, y, s, fade, SCR_CENTER ); } } } } // scoreboard y = SB_HEADER; CG_DrawColorPic( SB_SCORE_X + (SB_RATING_WIDTH / 2), y, 64, 32, cgs.media.scoreboardScore, SCR_CENTER, fadeColor ); CG_DrawColorPic( SB_PING_X - (SB_RATING_WIDTH / 2), y, 64, 32, cgs.media.scoreboardPing, SCR_CENTER, fadeColor ); CG_DrawColorPic( SB_TIME_X - (SB_RATING_WIDTH / 2), y, 64, 32, cgs.media.scoreboardTime, SCR_CENTER, fadeColor ); CG_DrawColorPic( SB_NAME_X - (SB_RATING_WIDTH / 2), y, 64, 32, cgs.media.scoreboardName, SCR_CENTER, fadeColor ); y = SB_TOP; // If there are more than SB_MAXCLIENTS_NORMAL, use the interleaved scores if ( cg.numScores > SB_MAXCLIENTS_NORMAL ) { maxClients = SB_MAXCLIENTS_INTER; lineHeight = SB_INTER_HEIGHT; topBorderSize = 8; bottomBorderSize = 16; } else { maxClients = SB_MAXCLIENTS_NORMAL; lineHeight = SB_NORMAL_HEIGHT; topBorderSize = 16; bottomBorderSize = 16; } localClient = qfalse; if ( gt[cgs.gametype].teams ) { float team_opacity = 0.33f; // // teamplay scoreboard // y += lineHeight/2; if ( cg.teamScores[0] >= cg.teamScores[1] ) { n1 = CG_TeamScoreCount( TEAM_RED, maxClients ); CG_DrawTeamBackground( 0, y - topBorderSize, SCREEN_WIDTH, n1 * lineHeight + bottomBorderSize, team_opacity, TEAM_RED, SCR_NONE ); CG_TeamScoreboard( y, TEAM_RED, fade, maxClients, lineHeight ); y += (n1 * lineHeight) + BIGCHAR_HEIGHT; maxClients -= n1; n2 = CG_TeamScoreCount( TEAM_BLUE, maxClients ); CG_DrawTeamBackground( 0, y - topBorderSize, SCREEN_WIDTH, n2 * lineHeight + bottomBorderSize, team_opacity, TEAM_BLUE, SCR_NONE ); CG_TeamScoreboard( y, TEAM_BLUE, fade, maxClients, lineHeight ); y += (n2 * lineHeight) + BIGCHAR_HEIGHT; maxClients -= n2; } else { n1 = CG_TeamScoreCount( TEAM_BLUE, maxClients ); CG_DrawTeamBackground( 0, y - topBorderSize, SCREEN_WIDTH, n1 * lineHeight + bottomBorderSize, team_opacity, TEAM_BLUE, SCR_NONE ); CG_TeamScoreboard( y, TEAM_BLUE, fade, maxClients, lineHeight ); y += (n1 * lineHeight) + BIGCHAR_HEIGHT; maxClients -= n1; n2 = CG_TeamScoreCount( TEAM_RED, maxClients ); CG_DrawTeamBackground( 0, y - topBorderSize, SCREEN_WIDTH, n2 * lineHeight + bottomBorderSize, team_opacity, TEAM_RED, SCR_NONE ); CG_TeamScoreboard( y, TEAM_RED, fade, maxClients, lineHeight ); y += (n2 * lineHeight) + BIGCHAR_HEIGHT; maxClients -= n2; } /* n1 = CG_TeamScoreCount( TEAM_SPECTATOR, maxClients ); CG_TeamScoreboard( y, TEAM_SPECTATOR, fade, maxClients, lineHeight ); */ n1 = CG_TeamScoreboard( y, TEAM_SPECTATOR, fade, maxClients, lineHeight ); y += (n1 * lineHeight) + BIGCHAR_HEIGHT; } else { // // free for all scoreboard // /* n1 = CG_TeamScoreCount( TEAM_SPECTATOR, maxClients ); CG_TeamScoreboard( y, TEAM_FREE, fade, maxClients, lineHeight ); y += (n1 * lineHeight) + BIGCHAR_HEIGHT; n2 = CG_TeamScoreCount( TEAM_SPECTATOR, maxClients ); CG_TeamScoreboard( y, TEAM_SPECTATOR, fade, maxClients - n1, lineHeight ); y += (n2 * lineHeight) + BIGCHAR_HEIGHT; */ n1 = CG_TeamScoreboard( y, TEAM_FREE, fade, maxClients, lineHeight ); y += (n1 * lineHeight) + BIGCHAR_HEIGHT; n2 = CG_TeamScoreboard( y, TEAM_SPECTATOR, fade, maxClients - n1, lineHeight ); y += (n2 * lineHeight) + BIGCHAR_HEIGHT; } if (!localClient) { // draw local client at the bottom for ( i = 0 ; i < cg.numScores ; i++ ) { if ( cg.scores[i].client == cg.snap->ps.clientNum ) { CG_DrawClientScore( y, &cg.scores[i], fadeColor, fade, lineHeight == SB_NORMAL_HEIGHT ); break; } } } // load any models that have been deferred if ( ++cg.deferredPlayerLoading > 10 ) { CG_LoadDeferredPlayers(); } return qtrue; }