home *** CD-ROM | disk | FTP | other *** search
/ Game Level Design / GLDesign.bin / Software / UnrealEngine2Runtime / UE2Runtime-22262001_Demo.exe / Gameplay / Classes / MessageTextureClient.uc < prev    next >
Text File  |  2003-12-11  |  2KB  |  95 lines

  1. class MessageTextureClient extends Info
  2.     placeable;
  3.  
  4. var() ScriptedTexture    MessageTexture;
  5.  
  6. var() localized string ScrollingMessage;
  7. var localized string HisMessage, HerMessage;
  8. var() Font Font;
  9. var() color FontColor;
  10. var() bool bCaps;
  11.  
  12. var string OldText;
  13.  
  14. /* parameters for ScrollingMessage:
  15.  
  16.    %p - local player name
  17.    %h - his/her for local player
  18.    %lp - leading player's name
  19.    %lf - leading player's frags
  20. */
  21.  
  22. simulated function PostNetBeginPlay()
  23. {
  24.     if(MessageTexture != None)
  25.         MessageTexture.Client = Self;
  26.  
  27.     SetTimer(1,true);
  28. }
  29.  
  30. simulated function Timer()
  31. {
  32.     local string Text;
  33.     local PlayerReplicationInfo Leading, PRI;
  34.  
  35.     Text = ScrollingMessage;
  36.  
  37.     if(InStr(Text, "%lf") != -1 || InStr(Text, "%lp") != -1)
  38.     {
  39.         // find the leading player
  40.         Leading = None;
  41.  
  42.         ForEach AllActors(class'PlayerReplicationInfo',PRI)
  43.             if ( !PRI.bIsSpectator && (Leading==None || PRI.Score>Leading.Score) )
  44.                 Leading = PRI;
  45.  
  46.         if(Leading != None)
  47.         {
  48.             Text = Replace(Text, "%lp", Leading.PlayerName);
  49.             Text = Replace(Text, "%lf", string(int(Leading.Score)));
  50.         }
  51.         else
  52.             Text = "";
  53.     }
  54.  
  55.     if(bCaps)
  56.         Text = Caps(Text);
  57.  
  58.     if(Text != OldText)
  59.     {
  60.         OldText = Text;
  61.         MessageTexture.Revision++;
  62.     }
  63. }
  64.  
  65. simulated event RenderTexture(ScriptedTexture Tex)
  66. {
  67.     local int    SizeX,
  68.                 SizeY;
  69.  
  70.     Tex.TextSize(OldText,Font,SizeX,SizeY);
  71.  
  72.     Tex.DrawText( (Tex.USize - SizeX) * 0.5, (Tex.VSize - SizeY) * 0.5, OldText, Font, FontColor );
  73. }
  74.  
  75. simulated function string Replace(string Text, string Match, string Replacement)
  76. {
  77.     local int i;
  78.     
  79.     i = InStr(Text, Match);    
  80.  
  81.     if(i != -1)
  82.         return Left(Text, i) $ Replacement $ Replace(Mid(Text, i+Len(Match)), Match, Replacement);
  83.     else
  84.         return Text;
  85. }
  86.  
  87. defaultproperties
  88. {
  89.     HisMessage="his"
  90.     HerMessage="her"
  91.     RemoteRole=ROLE_SimulatedProxy
  92.     bStatic=False
  93.     bAlwaysRelevant=True
  94.     bNoDelete=True
  95. }