/* ==================== MissionInformation_Draw ==================== */ void MissionInformation_Draw( centity_t *cent ) { int i,totalY; missionInfo_Updated = qfalse; // This will stop the text from flashing cg.missionInfoFlashTime = 0; // Frame char text[1024]={0}; cgi_SP_GetStringTextString( "INGAME_OBJECTIVES", text, sizeof(text) ); cgi_R_Font_DrawString (96, missionYpos-23, text, colorTable[CT_WHITE], cgs.media.qhFontMedium, -1, 1.0f); int missionYcnt = 0; obj_graphics[0] = obj_graphics[1] = obj_graphics[2] = obj_graphics[3] = qfalse; // Print active objectives cgi_R_SetColor(colorTable[CT_BLUE3]); for (i=0;i<MAX_OBJECTIVES;++i) { if (cent->gent->client->sess.mission_objectives[i].display) { totalY = missionYpos + (18 * (missionYcnt))+9; if (obj_graphics[0]) { totalY += 32 + 4; } if (obj_graphics[1]) { totalY += 32 + 4; } if (obj_graphics[2]) { totalY += 32 + 4; } if (obj_graphics[3]) { totalY += 32 + 4; } // OBJECTIVE_STAT_PENDING CG_DrawPic( 88, totalY, 16, 16, cgs.media.messageObjCircle); // Circle in front if (cent->gent->client->sess.mission_objectives[i].status == OBJECTIVE_STAT_SUCCEEDED) { CG_DrawPic( 88, totalY, 16, 16, cgs.media.messageLitOn); // Center Dot } MissionPrint_Line(CT_BLUE3, i, missionYcnt ); } } if (!missionYcnt) { cgi_SP_GetStringTextString( "INGAME_OBJNONE", text, sizeof(text) ); CG_DrawProportionalString(108, missionYpos, text, CG_SMALLFONT, colorTable[CT_LTBLUE1] ); } }
/* ==================== ObjectivePrint_Line Print a single mission objective ==================== */ static void ObjectivePrint_Line(const int color, const int objectIndex, int &missionYcnt) { char *str,*strBegin; int y,pixelLen,charLen,i; const int maxHoldText = 1024; char holdText[maxHoldText]; char finalText[2048]; qhandle_t graphic; int iYPixelsPerLine = cgi_R_Font_HeightPixels(cgs.media.qhFontMedium, 1.0f); cgi_SP_GetStringTextString( va("OBJECTIVES_%s",objectiveTable[objectIndex].name) , finalText, sizeof(finalText) ); // A hack to be able to count prisoners if (objectIndex==T2_RANCOR_OBJ5) { char value[64]; int currTotal, minTotal; gi.Cvar_VariableStringBuffer("ui_prisonerobj_currtotal",value,sizeof(value)); currTotal = atoi(value); gi.Cvar_VariableStringBuffer("ui_prisonerobj_maxtotal",value,sizeof(value)); minTotal = atoi(value); Q_strncpyz(finalText, va(finalText,currTotal,minTotal), sizeof(finalText)); } pixelLen = cgi_R_Font_StrLenPixels(finalText, cgs.media.qhFontMedium, 1.0f); str = finalText; if (cgi_Language_IsAsian()) { // this is execrable, and should NOT have had to've been done now, but... // extern const char *CG_DisplayBoxedText( int iBoxX, int iBoxY, int iBoxWidth, int iBoxHeight, const char *psText, int iFontHandle, float fScale, const vec4_t v4Color); extern int giLinesOutput; extern float gfAdvanceHack; gfAdvanceHack = 1.0f; // override internal vertical advance y = objectiveStartingYpos + (iYPixelsPerLine * missionYcnt); // Advance line if a graphic has printed for (i=0;i<MAX_OBJ_GRAPHICS;i++) { if (obj_graphics[i]) { y += OBJ_GRAPHIC_SIZE + 4; } } CG_DisplayBoxedText( objectiveStartingXpos, y, objectiveTextBoxWidth, objectiveTextBoxHeight, finalText, // int iBoxX, int iBoxY, int iBoxWidth, int iBoxHeight, const char *psText cgs.media.qhFontMedium, // int iFontHandle, 1.0f, // float fScale, colorTable[color] // const vec4_t v4Color ); gfAdvanceHack = 0.0f; // restore missionYcnt += giLinesOutput; } else { // western... // if (pixelLen < objectiveTextBoxWidth) // One shot - small enough to print entirely on one line { y =objectiveStartingYpos + (iYPixelsPerLine * (missionYcnt)); cgi_R_Font_DrawString ( objectiveStartingXpos, y, str, colorTable[color], cgs.media.qhFontMedium, -1, 1.0f); ++missionYcnt; } // Text is too long, break into lines. else { char holdText2[2]; pixelLen = 0; charLen = 0; holdText2[1] = '\0'; strBegin = str; while( *str ) { holdText2[0] = *str; pixelLen += cgi_R_Font_StrLenPixels(holdText2, cgs.media.qhFontMedium, 1.0f); pixelLen += 2; // For kerning ++charLen; if (pixelLen > objectiveTextBoxWidth ) { //Reached max length of this line //step back until we find a space while ((charLen>10) && (*str != ' ' )) { --str; --charLen; } if (*str==' ') { ++str; // To get past space } assert( charLen<maxHoldText ); // Too big? Q_strncpyz( holdText, strBegin, charLen); holdText[charLen] = '\0'; strBegin = str; pixelLen = 0; charLen = 1; y = objectiveStartingYpos + (iYPixelsPerLine * missionYcnt); CG_DrawProportionalString( objectiveStartingXpos, y, holdText, CG_SMALLFONT, colorTable[color] ); ++missionYcnt; } else if (*(str+1) == '\0') { ++charLen; assert( charLen<maxHoldText ); // Too big? y = objectiveStartingYpos + (iYPixelsPerLine * missionYcnt); Q_strncpyz( holdText, strBegin, charLen); CG_DrawProportionalString( objectiveStartingXpos, y, holdText, CG_SMALLFONT, colorTable[color] ); ++missionYcnt; break; } ++str; } } } if (objectIndex == T3_BOUNTY_OBJ1) { y =objectiveStartingYpos + (iYPixelsPerLine * missionYcnt); if (obj_graphics[1]) { y += OBJ_GRAPHIC_SIZE + 4; } if (obj_graphics[2]) { y += OBJ_GRAPHIC_SIZE + 4; } graphic = cgi_R_RegisterShaderNoMip("textures/system/viewscreen1"); CG_DrawPic( 355, 50, OBJ_GRAPHIC_SIZE, OBJ_GRAPHIC_SIZE, graphic ); obj_graphics[3] = qtrue; } }
void CG_DrawInformation( void ) { const char *s; const char *info; const char *sysInfo; int y; int value, valueNOFP; qhandle_t levelshot; char buf[1024]; int iPropHeight = 18; // I know, this is total crap, but as a post release asian-hack.... -Ste #ifdef WEB_DOWNLOAD char sDownLoading[256]; char sEstimatedTimeLeft[256]; char sTransferRate[256]; char sOf[20]; char sCopied[256]; char sSec[20]; int downloadSize, downloadCount, downloadTime; char dlSizeBuf[64], totalSizeBuf[64], xferRateBuf[64], dlTimeBuf[64]; int xferRate; int leftWidth; int centerPoint = 320; int yStart = 130; float scale = 1.0f; const char *downloadName = cgs.dlname; #endif #ifdef WEB_DOWNLOAD vec4_t colorLtGreyAlpha = {0, 0, 0, .5}; if(cgs.is_downloading!=0) { char motdString[1024]; char dlInfo[MAX_INFO_VALUE]; extern int startt,t; levelshot = trap->R_RegisterShaderNoMip( "menu/art/unknownmap_mp" ); trap->R_SetColor( NULL ); CG_DrawPic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, levelshot ); dlInfo[0] = '\0'; if( CG_GetConfigString( CS_SERVERINFO, dlInfo, sizeof(dlInfo) ) ) { //if ( info = CG_ConfigString( CS_SERVERINFO ) ) { const char *psLoading = CG_GetStringEdString("MENUS", "LOADING_MAPNAME"); CG_DrawProportionalString( 320, 128-32, va( (char *)psLoading, Info_ValueForKey( dlInfo, "mapname" )), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); } else { const char *psAwaitingSnapshot = CG_GetStringEdString("MENUS", "AWAITING_SNAPSHOT"); CG_DrawProportionalString( 320, 128-32, psAwaitingSnapshot, UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); } // don't print server lines if playing a local game trap->Cvar_VariableStringBuffer( "sv_running", buf, sizeof( buf ) ); if ( !atoi( buf ) ) { trap->Cvar_VariableStringBuffer( "cl_motdString", motdString, sizeof( motdString ) ); if (motdString[0]) { CG_DrawProportionalString( 320, 425, motdString, UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); } } CG_FillRect( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, colorLtGreyAlpha ); s = GetCRDelineatedString("MENUS","DOWNLOAD_STUFF", 0); // "Downloading:" Q_strncpyz(sDownLoading,s?s:"", sizeof(sDownLoading)); s = GetCRDelineatedString("MENUS","DOWNLOAD_STUFF", 1); // "Estimated time left:" Q_strncpyz(sEstimatedTimeLeft,s?s:"", sizeof(sEstimatedTimeLeft)); s = GetCRDelineatedString("MENUS","DOWNLOAD_STUFF", 2); // "Transfer rate:" Q_strncpyz(sTransferRate,s?s:"", sizeof(sTransferRate)); s = GetCRDelineatedString("MENUS","DOWNLOAD_STUFF", 3); // "of" Q_strncpyz(sOf,s?s:"", sizeof(sOf)); s = GetCRDelineatedString("MENUS","DOWNLOAD_STUFF", 4); // "copied" Q_strncpyz(sCopied,s?s:"", sizeof(sCopied)); s = GetCRDelineatedString("MENUS","DOWNLOAD_STUFF", 5); // "sec." Q_strncpyz(sSec,s?s:"", sizeof(sSec)); downloadSize = cgs.dltotal; if( downloadSize == 0 ) return; downloadCount = cgs.dlnow; if(!t)t = trap->Milliseconds(); downloadTime = t - startt; leftWidth = 320; trap->R_SetColor(colorWhite); #define Text_PaintCenter(x,y,scale,color,text,adjust,iMenuFont) \ CG_DrawScaledProportionalString(x,y,text,UI_CENTER|UI_BIGFONT|UI_DROPSHADOW,color,scale) Text_PaintCenter(centerPoint, yStart + 112, scale, colorWhite, sDownLoading, 0, iMenuFont); Text_PaintCenter(centerPoint, yStart + 192, scale, colorWhite, sEstimatedTimeLeft, 0, iMenuFont); Text_PaintCenter(centerPoint, yStart + 248, scale, colorWhite, sTransferRate, 0, iMenuFont); if (downloadSize > 0) { s = va("%s (%d%%)", downloadName, (int)((float)downloadCount * 100.0f / downloadSize)); } else { s = downloadName; } Text_PaintCenter(centerPoint, yStart+136, scale, colorWhite, s, 0, iMenuFont); CG_ReadableSize( dlSizeBuf, sizeof dlSizeBuf, downloadCount ); CG_ReadableSize( totalSizeBuf, sizeof totalSizeBuf, downloadSize ); if (downloadCount < 4096 || !downloadTime) { Text_PaintCenter(leftWidth, yStart+216, scale, colorWhite, "estimating", 0, iMenuFont); Text_PaintCenter(leftWidth, yStart+160, scale, colorWhite, va("(%s %s %s %s)", dlSizeBuf, sOf, totalSizeBuf, sCopied), 0, iMenuFont); } else { if ((downloadTime) / 1000) { xferRate = downloadCount / ((downloadTime) / 1000); } else { xferRate = 0; } CG_ReadableSize( xferRateBuf, sizeof xferRateBuf, xferRate ); // Extrapolate estimated completion time if (downloadSize && xferRate) { int n = downloadSize / xferRate; // estimated time for entire d/l in secs // We do it in K (/1024) because we'd overflow around 4MB UI_PrintTime ( dlTimeBuf, sizeof dlTimeBuf, (n - (((downloadCount/1024) * n) / (downloadSize/1024))) * 1000); Text_PaintCenter(leftWidth, yStart+216, scale, colorWhite, dlTimeBuf, 0, iMenuFont); Text_PaintCenter(leftWidth, yStart+160, scale, colorWhite, va("(%s %s %s %s)", dlSizeBuf, sOf, totalSizeBuf, sCopied), 0, iMenuFont); } else { Text_PaintCenter(leftWidth, yStart+216, scale, colorWhite, "estimating", 0, iMenuFont); if (downloadSize) { Text_PaintCenter(leftWidth, yStart+160, scale, colorWhite, va("(%s %s %s %s)", dlSizeBuf, sOf, totalSizeBuf, sCopied), 0, iMenuFont); } else { Text_PaintCenter(leftWidth, yStart+160, scale, colorWhite, va("(%s %s)", dlSizeBuf, sCopied), 0, iMenuFont); } } if (xferRate) { Text_PaintCenter(leftWidth, yStart+272, scale, colorWhite, va("%s/%s", xferRateBuf,sSec), 0, iMenuFont); } } return; } #endif info = CG_ConfigString( CS_SERVERINFO ); sysInfo = CG_ConfigString( CS_SYSTEMINFO ); s = Info_ValueForKey( info, "mapname" ); levelshot = trap->R_RegisterShaderNoMip( va( "levelshots/%s", s ) ); if ( !levelshot ) { levelshot = trap->R_RegisterShaderNoMip( "menu/art/unknownmap_mp" ); } trap->R_SetColor( NULL ); CG_DrawPic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, levelshot ); CG_LoadBar(); // draw the icons of things as they are loaded // CG_DrawLoadingIcons(); // the first 150 rows are reserved for the client connection // screen to write into if ( cg.infoScreenText[0] ) { const char *psLoading = CG_GetStringEdString("MENUS", "LOADING_MAPNAME"); CG_DrawProportionalString( 320, 128-32, va(/*"Loading... %s"*/ psLoading, cg.infoScreenText), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); } else { const char *psAwaitingSnapshot = CG_GetStringEdString("MENUS", "AWAITING_SNAPSHOT"); CG_DrawProportionalString( 320, 128-32, /*"Awaiting snapshot..."*/psAwaitingSnapshot, UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); } // draw info string information y = 180-32; // don't print server lines if playing a local game trap->Cvar_VariableStringBuffer( "sv_running", buf, sizeof( buf ) ); if ( !atoi( buf ) ) { // server hostname Q_strncpyz(buf, Info_ValueForKey( info, "sv_hostname" ), sizeof( buf ) ); Q_CleanStr(buf); CG_DrawProportionalString( 320, y, buf, UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; // pure server s = Info_ValueForKey( sysInfo, "sv_pure" ); if ( s[0] == '1' ) { const char *psPure = CG_GetStringEdString("MP_INGAME", "PURE_SERVER"); CG_DrawProportionalString( 320, y, psPure, UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; } // server-specific message of the day s = CG_ConfigString( CS_MOTD ); if ( s[0] ) { CG_DrawProportionalString( 320, y, s, UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; } { // display global MOTD at bottom (mirrors ui_main UI_DrawConnectScreen char motdString[1024]; trap->Cvar_VariableStringBuffer( "cl_motdString", motdString, sizeof( motdString ) ); if (motdString[0]) { CG_DrawProportionalString( 320, 425, motdString, UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); } } // some extra space after hostname and motd y += 10; } // map-specific message (long map name) s = CG_ConfigString( CS_MESSAGE ); if ( s[0] ) { CG_DrawProportionalString( 320, y, s, UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; } // cheats warning s = Info_ValueForKey( sysInfo, "sv_cheats" ); if ( s[0] == '1' ) { CG_DrawProportionalString( 320, y, CG_GetStringEdString("MP_INGAME", "CHEATSAREENABLED"), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; } // game type s = BG_GetGametypeString( cgs.gametype ); CG_DrawProportionalString( 320, y, s, UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; if (cgs.gametype != GT_SIEGE) { value = atoi( Info_ValueForKey( info, "timelimit" ) ); if ( value ) { CG_DrawProportionalString( 320, y, va( "%s %i", CG_GetStringEdString("MP_INGAME", "TIMELIMIT"), value ), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; } if (cgs.gametype < GT_CTF ) { value = atoi( Info_ValueForKey( info, "fraglimit" ) ); if ( value ) { CG_DrawProportionalString( 320, y, va( "%s %i", CG_GetStringEdString("MP_INGAME", "FRAGLIMIT"), value ), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; } if (cgs.gametype == GT_DUEL || cgs.gametype == GT_POWERDUEL) { value = atoi( Info_ValueForKey( info, "duel_fraglimit" ) ); if ( value ) { CG_DrawProportionalString( 320, y, va( "%s %i", CG_GetStringEdString("MP_INGAME", "WINLIMIT"), value ), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; } } } } if (cgs.gametype >= GT_CTF) { value = atoi( Info_ValueForKey( info, "capturelimit" ) ); if ( value ) { CG_DrawProportionalString( 320, y, va( "%s %i", CG_GetStringEdString("MP_INGAME", "CAPTURELIMIT"), value ), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; } } if (cgs.gametype >= GT_TEAM) { value = atoi( Info_ValueForKey( info, "g_forceBasedTeams" ) ); if ( value ) { CG_DrawProportionalString( 320, y, CG_GetStringEdString("MP_INGAME", "FORCEBASEDTEAMS"), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; } } if (cgs.gametype != GT_SIEGE) { valueNOFP = atoi( Info_ValueForKey( info, "g_forcePowerDisable" ) ); value = atoi( Info_ValueForKey( info, "g_maxForceRank" ) ); if ( value && !valueNOFP && (value < NUM_FORCE_MASTERY_LEVELS) ) { char fmStr[1024]; trap->SE_GetStringTextString("MP_INGAME_MAXFORCERANK",fmStr, sizeof(fmStr)); CG_DrawProportionalString( 320, y, va( "%s %s", fmStr, CG_GetStringEdString("MP_INGAME", forceMasteryLevels[value]) ), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; } else if (!valueNOFP) { char fmStr[1024]; trap->SE_GetStringTextString("MP_INGAME_MAXFORCERANK",fmStr, sizeof(fmStr)); CG_DrawProportionalString( 320, y, va( "%s %s", fmStr, (char *)CG_GetStringEdString("MP_INGAME", forceMasteryLevels[7]) ), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; } if (cgs.gametype == GT_DUEL || cgs.gametype == GT_POWERDUEL) { value = atoi( Info_ValueForKey( info, "g_duelWeaponDisable" ) ); } else { value = atoi( Info_ValueForKey( info, "g_weaponDisable" ) ); } if ( cgs.gametype != GT_JEDIMASTER && value ) { CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "SABERONLYSET") ), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; } if ( valueNOFP ) { CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "NOFPSET") ), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; } } // Display the rules based on type y += iPropHeight; switch ( cgs.gametype ) { case GT_FFA: CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_FFA_1")), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; break; case GT_HOLOCRON: CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_HOLO_1")), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_HOLO_2")), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; break; case GT_JEDIMASTER: CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_JEDI_1")), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_JEDI_2")), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; break; case GT_SINGLE_PLAYER: break; case GT_DUEL: CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_DUEL_1")), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_DUEL_2")), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; break; case GT_POWERDUEL: CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_POWERDUEL_1")), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_POWERDUEL_2")), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; break; case GT_TEAM: CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_TEAM_1")), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_TEAM_2")), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; break; case GT_SIEGE: break; case GT_CTF: CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_CTF_1")), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_CTF_2")), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; break; case GT_CTY: CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_CTY_1")), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_CTY_2")), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; break; default: break; } }
/* ==================== MissionPrint_Line ==================== */ static void MissionPrint_Line(const int color, const int objectIndex, int &missionYcnt) { char *str,*strBegin; int y,pixelLen,charLen; char holdText[1024] ; char finalText[2048]; qhandle_t graphic; cgi_SP_GetStringText( PACKAGE_OBJECTIVES<<8|objectIndex , finalText, sizeof(finalText) ); pixelLen = cgi_R_Font_StrLenPixels(finalText, cgs.media.qhFontMedium, 1.0f); str = finalText; /* CG_DisplayBoxedText(70,50,500,300,finalText, cgs.media.qhFontSmall, 1.0f, colorTable[color] ); */ if (pixelLen < 500) // One shot - small enough to print entirely on one line { y =missionYpos + (18 * (missionYcnt)); if (obj_graphics[0]) { y += 32 + 4; } if (obj_graphics[1]) { y += 32 + 4; } if (obj_graphics[2]) { y += 32 + 4; } CG_DrawProportionalString(108, y,str, CG_SMALLFONT, colorTable[color] ); ++missionYcnt; } // Text is too long, break into lines. else { char holdText2[2]; pixelLen = 0; charLen = 0; holdText2[1] = NULL; strBegin = str; while( *str ) { holdText2[0] = *str; pixelLen += cgi_R_Font_StrLenPixels(holdText2, cgs.media.qhFontMedium, 1.0f); pixelLen += 2; // For kerning ++charLen; if (pixelLen > 500 ) { //Reached max length of this line //step back until we find a space while ((charLen) && (*str != ' ' )) { --str; --charLen; } if (*str==' ') { ++str; // To get past space } Q_strncpyz( holdText, strBegin, charLen); holdText[charLen] = NULL; strBegin = str; pixelLen = 0; charLen = 1; y = missionYpos + (18 * missionYcnt); CG_DrawProportionalString(108, y, holdText, CG_SMALLFONT, colorTable[color] ); ++missionYcnt; } else if (*(str+1) == NULL) { ++charLen; y = missionYpos + (18 * missionYcnt); Q_strncpyz( holdText, strBegin, charLen); CG_DrawProportionalString(108, y, holdText, CG_SMALLFONT, colorTable[color] ); ++missionYcnt; break; } ++str; } } // Special case hack if (objectIndex == DOOM_COMM_OBJ4) { y = missionYpos + (18 * missionYcnt); graphic = cgi_R_RegisterShaderNoMip("textures/system/securitycode"); CG_DrawPic( 320 - (128/2), y+8, 128, 32, graphic ); obj_graphics[0] = qtrue; } else if (objectIndex == KEJIM_POST_OBJ3) { y = missionYpos + (18 * missionYcnt); graphic = cgi_R_RegisterShaderNoMip("textures/system/securitycode_red"); CG_DrawPic( 320 - (32/2), y+8, 32, 32, graphic ); obj_graphics[1] = qtrue; } else if (objectIndex == KEJIM_POST_OBJ4) { y =missionYpos + (18 * missionYcnt); if (obj_graphics[1]) { y += 32 + 4; } graphic = cgi_R_RegisterShaderNoMip("textures/system/securitycode_green"); CG_DrawPic( 320 - (32/2), y+8, 32, 32, graphic ); obj_graphics[2] = qtrue; } else if (objectIndex == KEJIM_POST_OBJ5) { y =missionYpos + (18 * missionYcnt); if (obj_graphics[1]) { y += 32 + 4; } if (obj_graphics[2]) { y += 32 + 4; } graphic = cgi_R_RegisterShaderNoMip("textures/system/securitycode_blue"); CG_DrawPic( 320 - (32/2), y+8, 32, 32, graphic ); obj_graphics[3] = qtrue; } }
void CG_DrawInformation( void ) { const char *s; const char *info; const char *sysInfo; int y; int value, valueNOFP; qhandle_t levelshot; char buf[1024]; int iPropHeight = 18; // I know, this is total crap, but as a post release asian-hack.... -Ste info = CG_ConfigString( CS_SERVERINFO ); sysInfo = CG_ConfigString( CS_SYSTEMINFO ); s = Info_ValueForKey( info, "mapname" ); levelshot = trap->R_RegisterShaderNoMip( va( "levelshots/%s", s ) ); if ( !levelshot ) { levelshot = trap->R_RegisterShaderNoMip( "menu/art/unknownmap_mp" ); } trap->R_SetColor( NULL ); CG_DrawPic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, levelshot ); CG_LoadBar(); // draw the icons of things as they are loaded // CG_DrawLoadingIcons(); // the first 150 rows are reserved for the client connection // screen to write into if ( cg.infoScreenText[0] ) { const char *psLoading = CG_GetStringEdString("MENUS", "LOADING_MAPNAME"); CG_DrawProportionalString( 320, 128-32, va(/*"Loading... %s"*/ psLoading, cg.infoScreenText), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); } else { const char *psAwaitingSnapshot = CG_GetStringEdString("MENUS", "AWAITING_SNAPSHOT"); CG_DrawProportionalString( 320, 128-32, /*"Awaiting snapshot..."*/psAwaitingSnapshot, UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); } // draw info string information y = 180-32; // don't print server lines if playing a local game trap->Cvar_VariableStringBuffer( "sv_running", buf, sizeof( buf ) ); if ( !atoi( buf ) ) { // server hostname Q_strncpyz(buf, Info_ValueForKey( info, "sv_hostname" ), sizeof( buf ) ); Q_CleanStr(buf); CG_DrawProportionalString( 320, y, buf, UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; // pure server s = Info_ValueForKey( sysInfo, "sv_pure" ); if ( s[0] == '1' ) { const char *psPure = CG_GetStringEdString("MP_INGAME", "PURE_SERVER"); CG_DrawProportionalString( 320, y, psPure, UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; } // server-specific message of the day s = CG_ConfigString( CS_MOTD ); if ( s[0] ) { CG_DrawProportionalString( 320, y, s, UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; } { // display global MOTD at bottom (mirrors ui_main UI_DrawConnectScreen char motdString[1024]; trap->Cvar_VariableStringBuffer( "cl_motdString", motdString, sizeof( motdString ) ); if (motdString[0]) { CG_DrawProportionalString( 320, 425, motdString, UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); } } // some extra space after hostname and motd y += 10; } // map-specific message (long map name) s = CG_ConfigString( CS_MESSAGE ); if ( s[0] ) { CG_DrawProportionalString( 320, y, s, UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; } // cheats warning s = Info_ValueForKey( sysInfo, "sv_cheats" ); if ( s[0] == '1' ) { CG_DrawProportionalString( 320, y, CG_GetStringEdString("MP_INGAME", "CHEATSAREENABLED"), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; } // game type s = BG_GetGametypeString( cgs.gametype ); CG_DrawProportionalString( 320, y, s, UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; if (cgs.gametype != GT_SIEGE) { value = atoi( Info_ValueForKey( info, "timelimit" ) ); if ( value ) { CG_DrawProportionalString( 320, y, va( "%s %i", CG_GetStringEdString("MP_INGAME", "TIMELIMIT"), value ), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; } if (cgs.gametype < GT_CTF ) { value = atoi( Info_ValueForKey( info, "fraglimit" ) ); if ( value ) { CG_DrawProportionalString( 320, y, va( "%s %i", CG_GetStringEdString("MP_INGAME", "FRAGLIMIT"), value ), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; } if (cgs.gametype == GT_DUEL || cgs.gametype == GT_POWERDUEL) { value = atoi( Info_ValueForKey( info, "duel_fraglimit" ) ); if ( value ) { CG_DrawProportionalString( 320, y, va( "%s %i", CG_GetStringEdString("MP_INGAME", "WINLIMIT"), value ), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; } } } } if (cgs.gametype >= GT_CTF) { value = atoi( Info_ValueForKey( info, "capturelimit" ) ); if ( value ) { CG_DrawProportionalString( 320, y, va( "%s %i", CG_GetStringEdString("MP_INGAME", "CAPTURELIMIT"), value ), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; } } if (cgs.gametype >= GT_TEAM) { value = atoi( Info_ValueForKey( info, "g_forceBasedTeams" ) ); if ( value ) { CG_DrawProportionalString( 320, y, CG_GetStringEdString("MP_INGAME", "FORCEBASEDTEAMS"), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; } } if (cgs.gametype != GT_SIEGE) { valueNOFP = atoi( Info_ValueForKey( info, "g_forcePowerDisable" ) ); value = atoi( Info_ValueForKey( info, "g_maxForceRank" ) ); if ( value && !valueNOFP && (value < NUM_FORCE_MASTERY_LEVELS) ) { char fmStr[1024]; trap->SE_GetStringTextString("MP_INGAME_MAXFORCERANK",fmStr, sizeof(fmStr)); CG_DrawProportionalString( 320, y, va( "%s %s", fmStr, CG_GetStringEdString("MP_INGAME", forceMasteryLevels[value]) ), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; } else if (!valueNOFP) { char fmStr[1024]; trap->SE_GetStringTextString("MP_INGAME_MAXFORCERANK",fmStr, sizeof(fmStr)); CG_DrawProportionalString( 320, y, va( "%s %s", fmStr, (char *)CG_GetStringEdString("MP_INGAME", forceMasteryLevels[7]) ), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; } if (cgs.gametype == GT_DUEL || cgs.gametype == GT_POWERDUEL) { value = atoi( Info_ValueForKey( info, "g_duelWeaponDisable" ) ); } else { value = atoi( Info_ValueForKey( info, "g_weaponDisable" ) ); } if ( cgs.gametype != GT_JEDIMASTER && value ) { CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "SABERONLYSET") ), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; } if ( valueNOFP ) { CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "NOFPSET") ), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; } } // Display the rules based on type y += iPropHeight; switch ( cgs.gametype ) { case GT_FFA: CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_FFA_1")), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; break; case GT_HOLOCRON: CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_HOLO_1")), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_HOLO_2")), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; break; case GT_JEDIMASTER: CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_JEDI_1")), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_JEDI_2")), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; break; case GT_SINGLE_PLAYER: break; case GT_DUEL: CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_DUEL_1")), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_DUEL_2")), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; break; case GT_POWERDUEL: CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_POWERDUEL_1")), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_POWERDUEL_2")), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; break; case GT_TEAM: CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_TEAM_1")), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_TEAM_2")), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; break; case GT_SIEGE: break; case GT_CTF: CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_CTF_1")), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_CTF_2")), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; break; case GT_CTY: CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_CTY_1")), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; CG_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_CTY_2")), UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite ); y += iPropHeight; break; default: break; } }