home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2000 March / maximum-cd-2000-03.iso / Quake3 Game Source / Q3AGameSource.exe / Main / cg_info.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-01-18  |  6.3 KB  |  255 lines

  1. // Copyright (C) 1999-2000 Id Software, Inc.
  2. //
  3. // cg_info.c -- display information while data is being loading
  4.  
  5. #include "cg_local.h"
  6.  
  7. #define MAX_LOADING_PLAYER_ICONS    16
  8. #define MAX_LOADING_ITEM_ICONS        26
  9.  
  10. static int            loadingPlayerIconCount;
  11. static int            loadingItemIconCount;
  12. static qhandle_t    loadingPlayerIcons[MAX_LOADING_PLAYER_ICONS];
  13. static qhandle_t    loadingItemIcons[MAX_LOADING_ITEM_ICONS];
  14.  
  15.  
  16. /*
  17. ===================
  18. CG_DrawLoadingIcons
  19. ===================
  20. */
  21. static void CG_DrawLoadingIcons( void ) {
  22.     int        n;
  23.     int        x, y;
  24.  
  25.     for( n = 0; n < loadingPlayerIconCount; n++ ) {
  26.         x = 16 + n * 78;
  27.         y = 324;
  28.         CG_DrawPic( x, y, 64, 64, loadingPlayerIcons[n] );
  29.     }
  30.  
  31.     for( n = 0; n < loadingItemIconCount; n++ ) {
  32.         y = 400;
  33.         if( n >= 13 ) {
  34.             y += 40;
  35.         }
  36.         x = 16 + n % 13 * 48;
  37.         CG_DrawPic( x, y, 32, 32, loadingItemIcons[n] );
  38.     }
  39. }
  40.  
  41.  
  42. /*
  43. ======================
  44. CG_LoadingString
  45.  
  46. ======================
  47. */
  48. void CG_LoadingString( const char *s ) {
  49.     Q_strncpyz( cg.infoScreenText, s, sizeof( cg.infoScreenText ) );
  50.  
  51.     trap_UpdateScreen();
  52. }
  53.  
  54. /*
  55. ===================
  56. CG_LoadingItem
  57. ===================
  58. */
  59. void CG_LoadingItem( int itemNum ) {
  60.     gitem_t        *item;
  61.  
  62.     item = &bg_itemlist[itemNum];
  63.     
  64.     if ( item->icon && loadingItemIconCount < MAX_LOADING_ITEM_ICONS ) {
  65.         loadingItemIcons[loadingItemIconCount++] = trap_R_RegisterShaderNoMip( item->icon );
  66.     }
  67.  
  68.     CG_LoadingString( item->pickup_name );
  69. }
  70.  
  71. /*
  72. ===================
  73. CG_LoadingClient
  74. ===================
  75. */
  76. void CG_LoadingClient( int clientNum ) {
  77.     const char        *info;
  78.     char            *skin;
  79.     char            personality[MAX_QPATH];
  80.     char            model[MAX_QPATH];
  81.     char            iconName[MAX_QPATH];
  82.  
  83.     info = CG_ConfigString( CS_PLAYERS + clientNum );
  84.  
  85.     Q_strncpyz( model, Info_ValueForKey( info, "model" ), sizeof( model ) );
  86.     skin = Q_strrchr( model, '/' );
  87.     if ( skin ) {
  88.         *skin++ = '\0';
  89.     } else {
  90.         skin = "default";
  91.     }
  92.  
  93.     Com_sprintf( iconName, MAX_QPATH, "models/players/%s/icon_%s.tga", model, skin );
  94.         
  95.     if ( loadingPlayerIconCount < MAX_LOADING_PLAYER_ICONS ) {
  96.         loadingPlayerIcons[loadingPlayerIconCount++] = trap_R_RegisterShaderNoMip( iconName );
  97.     }
  98.  
  99.     Q_strncpyz( personality, Info_ValueForKey( info, "n" ), sizeof(personality) );
  100.     Q_CleanStr( personality );
  101.  
  102.     if( cgs.gametype == GT_SINGLE_PLAYER ) {
  103.         trap_S_RegisterSound( va( "sound/player/announce/%s.wav", personality ) );
  104.     }
  105.  
  106.     CG_LoadingString( personality );
  107. }
  108.  
  109.  
  110. /*
  111. ====================
  112. CG_DrawInformation
  113.  
  114. Draw all the status / pacifier stuff during level loading
  115. ====================
  116. */
  117. void CG_DrawInformation( void ) {
  118.     const char    *s;
  119.     const char    *info;
  120.     const char    *sysInfo;
  121.     int            y;
  122.     int            value;
  123.     qhandle_t    levelshot;
  124.     qhandle_t    detail;
  125.     char        buf[1024];
  126.  
  127.     info = CG_ConfigString( CS_SERVERINFO );
  128.     sysInfo = CG_ConfigString( CS_SYSTEMINFO );
  129.  
  130.     s = Info_ValueForKey( info, "mapname" );
  131.     levelshot = trap_R_RegisterShaderNoMip( va( "levelshots/%s.tga", s ) );
  132.     if ( !levelshot ) {
  133.         levelshot = trap_R_RegisterShaderNoMip( "menu/art/unknownmap" );
  134.     }
  135.     trap_R_SetColor( NULL );
  136.     CG_DrawPic( 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, levelshot );
  137.  
  138.     // blend a detail texture over it
  139.     detail = trap_R_RegisterShader( "levelShotDetail" );
  140.     trap_R_DrawStretchPic( 0, 0, cgs.glconfig.vidWidth, cgs.glconfig.vidHeight, 0, 0, 2.5, 2, detail );
  141.  
  142.     // draw the icons of thiings as they are loaded
  143.     CG_DrawLoadingIcons();
  144.  
  145.     // the first 150 rows are reserved for the client connection
  146.     // screen to write into
  147.     if ( cg.infoScreenText[0] ) {
  148.         UI_DrawProportionalString( 320, 128, va("Loading... %s", cg.infoScreenText),
  149.             UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, colorWhite );
  150.     } else {
  151.         UI_DrawProportionalString( 320, 128, "Awaiting snapshot...",
  152.             UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, colorWhite );
  153.     }
  154.  
  155.     // draw info string information
  156.  
  157.     y = 180;
  158.  
  159.     // don't print server lines if playing a local game
  160.     trap_Cvar_VariableStringBuffer( "sv_running", buf, sizeof( buf ) );
  161.     if ( !atoi( buf ) ) {
  162.         // server hostname
  163.         s = Info_ValueForKey( info, "sv_hostname" );
  164.         UI_DrawProportionalString( 320, y, s,
  165.             UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, colorWhite );
  166.         y += PROP_HEIGHT;
  167.  
  168.         // pure server
  169.         s = Info_ValueForKey( sysInfo, "sv_pure" );
  170.         if ( s[0] == '1' ) {
  171.             UI_DrawProportionalString( 320, y, "Pure Server",
  172.                 UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, colorWhite );
  173.             y += PROP_HEIGHT;
  174.         }
  175.  
  176.         // server-specific message of the day
  177.         s = CG_ConfigString( CS_MOTD );
  178.         if ( s[0] ) {
  179.             UI_DrawProportionalString( 320, y, s,
  180.                 UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, colorWhite );
  181.             y += PROP_HEIGHT;
  182.         }
  183.  
  184.         // some extra space after hostname and motd
  185.         y += 10;
  186.     }
  187.  
  188.     // map-specific message (long map name)
  189.     s = CG_ConfigString( CS_MESSAGE );
  190.     if ( s[0] ) {
  191.         UI_DrawProportionalString( 320, y, s,
  192.             UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, colorWhite );
  193.         y += PROP_HEIGHT;
  194.     }
  195.  
  196.     // cheats warning
  197.     s = Info_ValueForKey( sysInfo, "sv_cheats" );
  198.     if ( s[0] == '1' ) {
  199.         UI_DrawProportionalString( 320, y, "CHEATS ARE ENABLED",
  200.             UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, colorWhite );
  201.         y += PROP_HEIGHT;
  202.     }
  203.  
  204.     // game type
  205.     switch ( cgs.gametype ) {
  206.     case GT_FFA:
  207.         s = "Free For All";
  208.         break;
  209.     case GT_SINGLE_PLAYER:
  210.         s = "Single Player";
  211.         break;
  212.     case GT_TOURNAMENT:
  213.         s = "Tournament";
  214.         break;
  215.     case GT_TEAM:
  216.         s = "Team Deathmatch";
  217.         break;
  218.     case GT_CTF:
  219.         s = "Capture The Flag";
  220.         break;
  221.     default:
  222.         s = "Unknown Gametype";
  223.         break;
  224.     }
  225.     UI_DrawProportionalString( 320, y, s,
  226.         UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, colorWhite );
  227.     y += PROP_HEIGHT;
  228.         
  229.     value = atoi( Info_ValueForKey( info, "timelimit" ) );
  230.     if ( value ) {
  231.         UI_DrawProportionalString( 320, y, va( "timelimit %i", value ),
  232.             UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, colorWhite );
  233.         y += PROP_HEIGHT;
  234.     }
  235.  
  236.     if (cgs.gametype != GT_CTF) {
  237.         value = atoi( Info_ValueForKey( info, "fraglimit" ) );
  238.         if ( value ) {
  239.             UI_DrawProportionalString( 320, y, va( "fraglimit %i", value ),
  240.                 UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, colorWhite );
  241.             y += PROP_HEIGHT;
  242.         }
  243.     }
  244.  
  245.     if (cgs.gametype == GT_CTF) {
  246.         value = atoi( Info_ValueForKey( info, "capturelimit" ) );
  247.         if ( value ) {
  248.             UI_DrawProportionalString( 320, y, va( "capturelimit %i", value ),
  249.                 UI_CENTER|UI_SMALLFONT|UI_DROPSHADOW, colorWhite );
  250.             y += PROP_HEIGHT;
  251.         }
  252.     }
  253. }
  254.  
  255.