codemp/cgame/cg_info.c File Reference

#include "cg_local.h"

Go to the source code of this file.

Defines

#define MAX_LOADING_PLAYER_ICONS   16
#define MAX_LOADING_ITEM_ICONS   26
#define UI_INFOFONT   (UI_BIGFONT)

Functions

void CG_LoadBar (void)
void CG_LoadingString (const char *s)
void CG_LoadingItem (int itemNum)
void CG_LoadingClient (int clientNum)
void CG_DrawInformation (void)


Define Documentation

#define MAX_LOADING_ITEM_ICONS   26
 

Definition at line 8 of file cg_info.c.

#define MAX_LOADING_PLAYER_ICONS   16
 

Definition at line 7 of file cg_info.c.

#define UI_INFOFONT   (UI_BIGFONT)
 

Definition at line 109 of file cg_info.c.

Referenced by CG_DrawInformation().


Function Documentation

void CG_DrawInformation void   ) 
 

Definition at line 110 of file cg_info.c.

References atoi(), cg, CG_ConfigString(), CG_DrawPic(), CG_GetStringEdString(), CG_LoadBar(), cgs, colorWhite, CS_MESSAGE, CS_MOTD, CS_SERVERINFO, CS_SYSTEMINFO, forceMasteryLevels, cgs_t::gametype, GT_CTF, GT_CTY, GT_DUEL, GT_FFA, GT_HOLOCRON, GT_JEDIMASTER, GT_POWERDUEL, GT_SIEGE, GT_SINGLE_PLAYER, GT_TEAM, Info_ValueForKey(), cg_t::infoScreenText, NULL, NUM_FORCE_MASTERY_LEVELS, Q_CleanStr(), Q_strncpyz(), qhandle_t, SCREEN_HEIGHT, SCREEN_WIDTH, trap_Cvar_VariableStringBuffer(), trap_R_RegisterShaderNoMip(), trap_R_SetColor(), trap_SP_GetStringTextString(), UI_CENTER, UI_DrawProportionalString(), UI_DROPSHADOW, UI_INFOFONT, and va().

Referenced by CG_DrawActive(), and CG_DrawActiveFrame().

00110                                 {
00111         const char      *s;
00112         const char      *info;
00113         const char      *sysInfo;
00114         int                     y;
00115         int                     value, valueNOFP;
00116         qhandle_t       levelshot;
00117         char            buf[1024];
00118         int                     iPropHeight = 18;       // I know, this is total crap, but as a post release asian-hack....  -Ste
00119         
00120         info = CG_ConfigString( CS_SERVERINFO );
00121         sysInfo = CG_ConfigString( CS_SYSTEMINFO );
00122 
00123         s = Info_ValueForKey( info, "mapname" );
00124         levelshot = trap_R_RegisterShaderNoMip( va( "levelshots/%s", s ) );
00125         if ( !levelshot ) {
00126                 levelshot = trap_R_RegisterShaderNoMip( "menu/art/unknownmap_mp" );
00127         }
00128         trap_R_SetColor( NULL );
00129         CG_DrawPic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, levelshot );
00130 
00131         CG_LoadBar();
00132 
00133         // draw the icons of things as they are loaded
00134 //      CG_DrawLoadingIcons();
00135 
00136         // the first 150 rows are reserved for the client connection
00137         // screen to write into
00138         if ( cg.infoScreenText[0] ) {
00139                 const char *psLoading = CG_GetStringEdString("MENUS", "LOADING_MAPNAME");
00140                 UI_DrawProportionalString( 320, 128-32, va(/*"Loading... %s"*/ psLoading, cg.infoScreenText),
00141                         UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );              
00142         } else {
00143                 const char *psAwaitingSnapshot = CG_GetStringEdString("MENUS", "AWAITING_SNAPSHOT");
00144                 UI_DrawProportionalString( 320, 128-32, /*"Awaiting snapshot..."*/psAwaitingSnapshot,
00145                         UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );                      
00146         }
00147 
00148         // draw info string information
00149 
00150         y = 180-32;
00151 
00152         // don't print server lines if playing a local game
00153         trap_Cvar_VariableStringBuffer( "sv_running", buf, sizeof( buf ) );
00154         if ( !atoi( buf ) ) {
00155                 // server hostname
00156                 Q_strncpyz(buf, Info_ValueForKey( info, "sv_hostname" ), 1024);
00157                 Q_CleanStr(buf);
00158                 UI_DrawProportionalString( 320, y, buf,
00159                         UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00160                 y += iPropHeight;
00161 
00162                 // pure server
00163                 s = Info_ValueForKey( sysInfo, "sv_pure" );
00164                 if ( s[0] == '1' ) {
00165                         const char *psPure = CG_GetStringEdString("MP_INGAME", "PURE_SERVER");
00166                         UI_DrawProportionalString( 320, y, psPure,
00167                                 UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00168                         y += iPropHeight;
00169                 }
00170 
00171                 // server-specific message of the day
00172                 s = CG_ConfigString( CS_MOTD );
00173                 if ( s[0] ) {
00174                         UI_DrawProportionalString( 320, y, s,
00175                                 UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00176                         y += iPropHeight;
00177                 }
00178 
00179                 {       // display global MOTD at bottom (mirrors ui_main UI_DrawConnectScreen
00180                         char motdString[1024];
00181                         trap_Cvar_VariableStringBuffer( "cl_motdString", motdString, sizeof( motdString ) );
00182 
00183                         if (motdString[0])
00184                         {
00185                                 UI_DrawProportionalString( 320, 425, motdString,
00186                                         UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00187                         }
00188                 }
00189 
00190                 // some extra space after hostname and motd
00191                 y += 10;
00192         }
00193 
00194         // map-specific message (long map name)
00195         s = CG_ConfigString( CS_MESSAGE );
00196         if ( s[0] ) {
00197                 UI_DrawProportionalString( 320, y, s,
00198                         UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00199                 y += iPropHeight;
00200         }
00201 
00202         // cheats warning
00203         s = Info_ValueForKey( sysInfo, "sv_cheats" );
00204         if ( s[0] == '1' ) {
00205                 UI_DrawProportionalString( 320, y, CG_GetStringEdString("MP_INGAME", "CHEATSAREENABLED"),
00206                         UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00207                 y += iPropHeight;
00208         }
00209 
00210         // game type
00211         switch ( cgs.gametype ) {
00212         case GT_FFA:
00213                         s = CG_GetStringEdString("MENUS", "FREE_FOR_ALL");//"Free For All";
00214 //              s = "Free For All";
00215                 break;
00216         case GT_HOLOCRON:
00217                         s = CG_GetStringEdString("MENUS", "HOLOCRON_FFA");//"Holocron FFA";
00218 //              s = "Holocron FFA";
00219                 break;
00220         case GT_JEDIMASTER:
00221                         s = CG_GetStringEdString("MENUS", "SAGA");//"Jedi Master";??
00222 
00223 //              s = "Jedi Master";
00224                 break;
00225         case GT_SINGLE_PLAYER:
00226                         s = CG_GetStringEdString("MENUS", "SAGA");//"Team FFA";
00227 
00228                 //s = "Single Player";
00229                 break;
00230         case GT_DUEL:
00231                         s = CG_GetStringEdString("MENUS", "DUEL");//"Team FFA";
00232                 //s = "Duel";
00233                 break;
00234         case GT_POWERDUEL:
00235                         s = CG_GetStringEdString("MENUS", "POWERDUEL");//"Team FFA";
00236                 //s = "Power Duel";
00237                 break;
00238         case GT_TEAM:
00239                         s = CG_GetStringEdString("MENUS", "TEAM_FFA");//"Team FFA";
00240 
00241                 //s = "Team FFA";
00242                 break;
00243         case GT_SIEGE:
00244                         s = CG_GetStringEdString("MENUS", "SIEGE");//"Siege";
00245 
00246                 //s = "Siege";
00247                 break;
00248         case GT_CTF:
00249                         s = CG_GetStringEdString("MENUS", "CAPTURE_THE_FLAG");//"Capture the Flag";
00250 
00251                 //s = "Capture The Flag";
00252                 break;
00253         case GT_CTY:
00254                         s = CG_GetStringEdString("MENUS", "CAPTURE_THE_YSALIMARI");//"Capture the Ysalamiri";
00255 
00256                 //s = "Capture The Ysalamiri";
00257                 break;
00258         default:
00259                         s = CG_GetStringEdString("MENUS", "SAGA");//"Team FFA";
00260 
00261                 //s = "Unknown Gametype";
00262                 break;
00263         }
00264         UI_DrawProportionalString( 320, y, s,
00265                 UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00266         y += iPropHeight;
00267                 
00268         if (cgs.gametype != GT_SIEGE)
00269         {
00270                 value = atoi( Info_ValueForKey( info, "timelimit" ) );
00271                 if ( value ) {
00272                         UI_DrawProportionalString( 320, y, va( "%s %i", CG_GetStringEdString("MP_INGAME", "TIMELIMIT"), value ),
00273                                 UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00274                         y += iPropHeight;
00275                 }
00276 
00277                 if (cgs.gametype < GT_CTF ) {
00278                         value = atoi( Info_ValueForKey( info, "fraglimit" ) );
00279                         if ( value ) {
00280                                 UI_DrawProportionalString( 320, y, va( "%s %i", CG_GetStringEdString("MP_INGAME", "FRAGLIMIT"), value ),
00281                                         UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00282                                 y += iPropHeight;
00283                         }
00284 
00285                         if (cgs.gametype == GT_DUEL || cgs.gametype == GT_POWERDUEL)
00286                         {
00287                                 value = atoi( Info_ValueForKey( info, "duel_fraglimit" ) );
00288                                 if ( value ) {
00289                                         UI_DrawProportionalString( 320, y, va( "%s %i", CG_GetStringEdString("MP_INGAME", "WINLIMIT"), value ),
00290                                                 UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00291                                         y += iPropHeight;
00292                                 }
00293                         }
00294                 }
00295         }
00296 
00297         if (cgs.gametype >= GT_CTF) {
00298                 value = atoi( Info_ValueForKey( info, "capturelimit" ) );
00299                 if ( value ) {
00300                         UI_DrawProportionalString( 320, y, va( "%s %i", CG_GetStringEdString("MP_INGAME", "CAPTURELIMIT"), value ),
00301                                 UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00302                         y += iPropHeight;
00303                 }
00304         }
00305 
00306         if (cgs.gametype >= GT_TEAM)
00307         {
00308                 value = atoi( Info_ValueForKey( info, "g_forceBasedTeams" ) );
00309                 if ( value ) {
00310                         UI_DrawProportionalString( 320, y, CG_GetStringEdString("MP_INGAME", "FORCEBASEDTEAMS"),
00311                                 UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00312                         y += iPropHeight;
00313                 }
00314         }
00315 
00316     if (cgs.gametype != GT_SIEGE)
00317         {
00318                 valueNOFP = atoi( Info_ValueForKey( info, "g_forcePowerDisable" ) );
00319 
00320                 value = atoi( Info_ValueForKey( info, "g_maxForceRank" ) );
00321                 if ( value && !valueNOFP && (value < NUM_FORCE_MASTERY_LEVELS) ) {
00322                         char fmStr[1024]; 
00323 
00324                         trap_SP_GetStringTextString("MP_INGAME_MAXFORCERANK",fmStr, sizeof(fmStr));
00325 
00326                         UI_DrawProportionalString( 320, y, va( "%s %s", fmStr, CG_GetStringEdString("MP_INGAME", forceMasteryLevels[value]) ),
00327                                 UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00328                         y += iPropHeight;
00329                 }
00330                 else if (!valueNOFP)
00331                 {
00332                         char fmStr[1024];
00333                         trap_SP_GetStringTextString("MP_INGAME_MAXFORCERANK",fmStr, sizeof(fmStr));
00334 
00335                         UI_DrawProportionalString( 320, y, va( "%s %s", fmStr, (char *)CG_GetStringEdString("MP_INGAME", forceMasteryLevels[7]) ),
00336                                 UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00337                         y += iPropHeight;
00338                 }
00339 
00340                 if (cgs.gametype == GT_DUEL || cgs.gametype == GT_POWERDUEL)
00341                 {
00342                         value = atoi( Info_ValueForKey( info, "g_duelWeaponDisable" ) );
00343                 }
00344                 else
00345                 {
00346                         value = atoi( Info_ValueForKey( info, "g_weaponDisable" ) );
00347                 }
00348                 if ( cgs.gametype != GT_JEDIMASTER && value ) {
00349                         UI_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "SABERONLYSET") ),
00350                                 UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00351                         y += iPropHeight;
00352                 }
00353 
00354                 if ( valueNOFP ) {
00355                         UI_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "NOFPSET") ),
00356                                 UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00357                         y += iPropHeight;
00358                 }
00359         }
00360 
00361         // Display the rules based on type
00362                 y += iPropHeight;
00363         switch ( cgs.gametype ) {
00364         case GT_FFA:                                    
00365                 UI_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_FFA_1")),
00366                         UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00367                 y += iPropHeight;
00368                 break;
00369         case GT_HOLOCRON:
00370                 UI_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_HOLO_1")),
00371                         UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00372                 y += iPropHeight;
00373                 UI_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_HOLO_2")),
00374                         UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00375                 y += iPropHeight;
00376                 break;
00377         case GT_JEDIMASTER:
00378                 UI_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_JEDI_1")),
00379                         UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00380                 y += iPropHeight;
00381                 UI_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_JEDI_2")),
00382                         UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00383                 y += iPropHeight;
00384                 break;
00385         case GT_SINGLE_PLAYER:
00386                 break;
00387         case GT_DUEL:
00388                 UI_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_DUEL_1")),
00389                         UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00390                 y += iPropHeight;
00391                 UI_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_DUEL_2")),
00392                         UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00393                 y += iPropHeight;
00394                 break;
00395         case GT_POWERDUEL:
00396                 UI_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_POWERDUEL_1")),
00397                         UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00398                 y += iPropHeight;
00399                 UI_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_POWERDUEL_2")),
00400                         UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00401                 y += iPropHeight;
00402                 break;
00403         case GT_TEAM:
00404                 UI_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_TEAM_1")),
00405                         UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00406                 y += iPropHeight;
00407                 UI_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_TEAM_2")),
00408                         UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00409                 y += iPropHeight;
00410                 break;
00411         case GT_SIEGE:
00412                 break;
00413         case GT_CTF:
00414                 UI_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_CTF_1")),
00415                         UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00416                 y += iPropHeight;
00417                 UI_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_CTF_2")),
00418                         UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00419                 y += iPropHeight;
00420                 break;
00421         case GT_CTY:
00422                 UI_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_CTY_1")),
00423                         UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00424                 y += iPropHeight;
00425                 UI_DrawProportionalString( 320, y, va( "%s", (char *)CG_GetStringEdString("MP_INGAME", "RULES_CTY_2")),
00426                         UI_CENTER|UI_INFOFONT|UI_DROPSHADOW, colorWhite );
00427                 y += iPropHeight;
00428                 break;
00429         default:
00430                 break;
00431         }
00432 }

void CG_LoadBar void   ) 
 

Definition at line 439 of file cg_info.c.

References cg, CG_DrawPic(), cgs, colorWhite, cgMedia_t::loadBarLED, cgMedia_t::loadBarLEDCap, cgMedia_t::loadBarLEDSurround, cg_t::loadLCARSStage, cgs_t::media, and trap_R_SetColor().

Referenced by CG_DrawInformation().

00440 {
00441         const int numticks = 9, tickwidth = 40, tickheight = 8;
00442         const int tickpadx = 20, tickpady = 12;
00443         const int capwidth = 8;
00444         const int barwidth = numticks*tickwidth+tickpadx*2+capwidth*2, barleft = ((640-barwidth)/2);
00445         const int barheight = tickheight + tickpady*2, bartop = 480-barheight;
00446         const int capleft = barleft+tickpadx, tickleft = capleft+capwidth, ticktop = bartop+tickpady;
00447 
00448         trap_R_SetColor( colorWhite );
00449         // Draw background
00450         CG_DrawPic(barleft, bartop, barwidth, barheight, cgs.media.loadBarLEDSurround);
00451 
00452         // Draw left cap (backwards)
00453         CG_DrawPic(tickleft, ticktop, -capwidth, tickheight, cgs.media.loadBarLEDCap);
00454 
00455         // Draw bar
00456         CG_DrawPic(tickleft, ticktop, tickwidth*cg.loadLCARSStage, tickheight, cgs.media.loadBarLED);
00457 
00458         // Draw right cap
00459         CG_DrawPic(tickleft+tickwidth*cg.loadLCARSStage, ticktop, capwidth, tickheight, cgs.media.loadBarLEDCap);
00460 }

void CG_LoadingClient int  clientNum  ) 
 

Definition at line 53 of file cg_info.c.

References CG_ConfigString(), CG_LoadingString(), CS_PLAYERS, Info_ValueForKey(), MAX_QPATH, Q_CleanStr(), and Q_strncpyz().

00053                                        {
00054         const char              *info;
00055         char                    personality[MAX_QPATH];
00056 
00057         info = CG_ConfigString( CS_PLAYERS + clientNum );
00058 
00059 /*
00060         char                    model[MAX_QPATH];
00061         char                    iconName[MAX_QPATH];
00062         char                    *skin;
00063         if ( loadingPlayerIconCount < MAX_LOADING_PLAYER_ICONS ) {
00064                 Q_strncpyz( model, Info_ValueForKey( info, "model" ), sizeof( model ) );
00065                 skin = Q_strrchr( model, '/' );
00066                 if ( skin ) {
00067                         *skin++ = '\0';
00068                 } else {
00069                         skin = "default";
00070                 }
00071 
00072                 Com_sprintf( iconName, MAX_QPATH, "models/players/%s/icon_%s.tga", model, skin );
00073                 
00074                 loadingPlayerIcons[loadingPlayerIconCount] = trap_R_RegisterShaderNoMip( iconName );
00075                 if ( !loadingPlayerIcons[loadingPlayerIconCount] ) {
00076                         Com_sprintf( iconName, MAX_QPATH, "models/players/characters/%s/icon_%s.tga", model, skin );
00077                         loadingPlayerIcons[loadingPlayerIconCount] = trap_R_RegisterShaderNoMip( iconName );
00078                 }
00079                 if ( !loadingPlayerIcons[loadingPlayerIconCount] ) {
00080                         Com_sprintf( iconName, MAX_QPATH, "models/players/%s/icon_%s.tga", DEFAULT_MODEL, "default" );
00081                         loadingPlayerIcons[loadingPlayerIconCount] = trap_R_RegisterShaderNoMip( iconName );
00082                 }
00083                 if ( loadingPlayerIcons[loadingPlayerIconCount] ) {
00084                         loadingPlayerIconCount++;
00085                 }
00086         }
00087 */
00088         Q_strncpyz( personality, Info_ValueForKey( info, "n" ), sizeof(personality) );
00089         Q_CleanStr( personality );
00090 
00091         /*
00092         if( cgs.gametype == GT_SINGLE_PLAYER ) {
00093                 trap_S_RegisterSound( va( "sound/player/announce/%s.wav", personality ));
00094         }
00095         */
00096 
00097         CG_LoadingString( personality );
00098 }

void CG_LoadingItem int  itemNum  ) 
 

Definition at line 32 of file cg_info.c.

References bg_itemlist, CG_GetStringEdString(), CG_LoadingString(), gitem_s::classname, gitem_t, Q_strupr(), and strcpy().

00032                                    {
00033         gitem_t         *item;
00034         char    upperKey[1024];
00035 
00036         item = &bg_itemlist[itemNum];
00037 
00038         if (!item->classname || !item->classname[0])
00039         {
00040         //      CG_LoadingString( "Unknown item" );
00041                 return;
00042         }
00043 
00044         strcpy(upperKey, item->classname);
00045         CG_LoadingString( CG_GetStringEdString("SP_INGAME",Q_strupr(upperKey)) );
00046 }

void CG_LoadingString const char *  s  ) 
 

Definition at line 21 of file cg_info.c.

References cg, cg_t::infoScreenText, Q_strncpyz(), and trap_UpdateScreen().

Referenced by CG_Init(), CG_LoadingClient(), and CG_LoadingItem().

00021                                        {
00022         Q_strncpyz( cg.infoScreenText, s, sizeof( cg.infoScreenText ) );
00023 
00024         trap_UpdateScreen();
00025 }