home *** CD-ROM | disk | FTP | other *** search
/ Game Level Design / GLDesign.bin / Software / UnrealEngine2Runtime / UE2Runtime-22262001_Demo.exe / Engine / Classes / ScoreBoard.uc < prev    next >
Text File  |  2003-06-23  |  3KB  |  161 lines

  1. //=============================================================================
  2. // ScoreBoard
  3. //=============================================================================
  4. class ScoreBoard extends Info;
  5.  
  6. var() GameReplicationInfo           GRI;
  7. var() class<HUD> HUDClass;
  8. var bool bDisplayMessages;
  9.  
  10. simulated function PostBeginPlay()
  11. {
  12.     Super.PostBeginPlay();
  13.  
  14.     InitGRI();
  15.     Init();
  16. }
  17.  
  18. function Font GetSmallerFontFor(Canvas Canvas, int offset)
  19. {
  20.     local int i;
  21.  
  22.     for ( i=0; i<8-offset; i++ )
  23.     {
  24.         if ( HUDClass.default.FontScreenWidthMedium[i] <= Canvas.ClipX )
  25.             return HUDClass.static.LoadFontStatic(i+offset);
  26.     }
  27.     return HUDClass.static.LoadFontStatic(8);
  28. }
  29.  
  30. function bool HaveHalfFont(Canvas Canvas, int Offset)
  31. {
  32.     local int i;
  33.  
  34.     for ( i=0; i<9-offset; i++ )
  35.         if ( HUDClass.default.FontScreenWidthSmall[i] <= Canvas.ClipX )
  36.             return true;
  37.     return false;
  38. }
  39.  
  40. function Font GetSmallFontFor(int ScreenWidth, int offset)
  41. {
  42.     local int i;
  43.  
  44.     for ( i=0; i<8-offset; i++ )
  45.     {
  46.         if ( HUDClass.default.FontScreenWidthSmall[i] <= ScreenWidth )
  47.             return HUDClass.static.LoadFontStatic(i+offset);
  48.     }
  49.     return HUDClass.static.LoadFontStatic(8);
  50. }
  51.  
  52. simulated function InitGRI()
  53. {
  54.     GRI = PlayerController(Owner).GameReplicationInfo;
  55. }
  56.  
  57. simulated function string InitTitle()
  58. {
  59.     return Caps(GRI.GameName);
  60. }
  61.  
  62. simulated function Init();
  63.  
  64. simulated event DrawScoreboard( Canvas C )
  65. {
  66.     UpdateGRI();
  67.     UpdateScoreBoard(C);
  68. }
  69.  
  70. function bool UpdateGRI()
  71. {
  72.     if (GRI == None)
  73.     {
  74.         InitGRI();
  75.         if ( GRI == None )
  76.             return false;
  77.     }
  78.     SortPRIArray();
  79.     return true;
  80. }
  81.  
  82. simulated function String FormatTime( int Seconds )
  83. {
  84.     local int Minutes, Hours;
  85.     local String Time;
  86.  
  87.     if( Seconds > 3600 )
  88.     {
  89.         Hours = Seconds / 3600;
  90.         Seconds -= Hours * 3600;
  91.  
  92.         Time = Hours$":";
  93.     }
  94.     Minutes = Seconds / 60;
  95.     Seconds -= Minutes * 60;
  96.  
  97.     if( Minutes >= 10 )
  98.         Time = Time $ Minutes $ ":";
  99.     else
  100.         Time = Time $ "0" $ Minutes $ ":";
  101.  
  102.     if( Seconds >= 10 )
  103.         Time = Time $ Seconds;
  104.     else
  105.         Time = Time $ "0" $ Seconds;
  106.  
  107.     return Time;
  108. }
  109.  
  110. simulated function UpdateScoreBoard(Canvas Canvas);
  111.  
  112. simulated function bool InOrder( PlayerReplicationInfo P1, PlayerReplicationInfo P2 )
  113. {
  114.     if( P1.bOnlySpectator )
  115.     {
  116.         if( P2.bOnlySpectator )
  117.             return true;
  118.         else
  119.             return false;
  120.     }
  121.     else if ( P2.bOnlySpectator )
  122.         return true;
  123.  
  124.     if( P1.Score < P2.Score )
  125.         return false;
  126.     if( P1.Score == P2.Score )
  127.     {
  128.         if ( P1.Deaths > P2.Deaths )
  129.             return false;
  130.         if ( (P1.Deaths == P2.Deaths) && (PlayerController(P2.Owner) != None) && (Viewport(PlayerController(P2.Owner).Player) != None) )
  131.             return false;
  132.     }
  133.     return true;
  134. }
  135.  
  136. simulated function SortPRIArray()
  137. {
  138.     local int i,j;
  139.     local PlayerReplicationInfo tmp;
  140.  
  141.     for (i=0; i<GRI.PRIArray.Length-1; i++)
  142.     {
  143.         for (j=i+1; j<GRI.PRIArray.Length; j++)
  144.         {
  145.             if( !InOrder( GRI.PRIArray[i], GRI.PRIArray[j] ) )
  146.             {
  147.                 tmp = GRI.PRIArray[i];
  148.                 GRI.PRIArray[i] = GRI.PRIArray[j];
  149.                 GRI.PRIArray[j] = tmp;
  150.             }
  151.         }
  152.     }
  153. }
  154.  
  155. function NextStats();
  156.  
  157. defaultproperties
  158. {
  159.     HUDClass=class'HUD'
  160. }
  161.