Advertisement
Guest User

UnrealShare/UnrealTeamScoreBoard.uc

a guest
Jan 14th, 2016
37
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //=============================================================================
  2. // UnrealTeamScoreBoard
  3. //=============================================================================
  4. class UnrealTeamScoreBoard extends UnrealScoreBoard;
  5.  
  6. var int PlayerCounts[4];
  7. var localized string TeamName[4];
  8. var() color TeamColor[4];
  9. var() color AltTeamColor[4];
  10.  
  11. function DrawName( canvas Canvas, int I, float XOffset, int LoopCount )
  12. {
  13.     local float YOffset;
  14.  
  15.     switch (Teams[I])
  16.     {
  17.     case 0:
  18.         YOffset = Canvas.ClipY/4 + (LoopCount * 16);
  19.         break;
  20.     case 1:
  21.         YOffset = Canvas.ClipY/4 + (LoopCount * 16);
  22.         break;
  23.     case 2:
  24.         YOffset = Canvas.ClipY/4 + (PlayerCounts[0] * 16) + int(PlayerCounts[0] > 0) * 48 + (LoopCount * 16);
  25.         break;
  26.     case 3:
  27.         YOffset = Canvas.ClipY/4 + (PlayerCounts[1] * 16) + int(PlayerCounts[1] > 0) * 48 + (LoopCount * 16);
  28.         break;
  29.     }
  30.  
  31.     Canvas.SetPos(XOffset, YOffset);
  32.     Canvas.DrawText(PlayerNames[I], false);
  33. }
  34.  
  35. function DrawPing( canvas Canvas, int I, float XOffset, int LoopCount )
  36. {
  37.     local float XL, YL;
  38.     local float YOffset;
  39.  
  40.     if (Level.Netmode == NM_Standalone)
  41.         return;
  42.  
  43.     switch (Teams[I])
  44.     {
  45.     case 0:
  46.         YOffset = Canvas.ClipY/4 + (LoopCount * 16);
  47.         break;
  48.     case 1:
  49.         YOffset = Canvas.ClipY/4 + (LoopCount * 16);
  50.         break;
  51.     case 2:
  52.         YOffset = Canvas.ClipY/4 + (PlayerCounts[0] * 16) + int(PlayerCounts[0] > 0) * 48 + (LoopCount * 16);
  53.         break;
  54.     case 3:
  55.         YOffset = Canvas.ClipY/4 + (PlayerCounts[1] * 16) + int(PlayerCounts[1] > 0) * 48 + (LoopCount * 16);
  56.         break;
  57.     }
  58.  
  59.     Canvas.StrLen(Pings[I], XL, YL);
  60.     Canvas.SetPos(XOffset - XL - 8, YOffset);
  61.     Canvas.Font = Font'TinyWhiteFont';
  62.     Canvas.DrawColor.R = 255;
  63.     Canvas.DrawColor.G = 255;
  64.     Canvas.DrawColor.B = 255;
  65.     Canvas.DrawText(Pings[I], false);
  66.     Canvas.Font = RegFont;
  67. }
  68.  
  69. function DrawScore( canvas Canvas, int I, float XOffset, int LoopCount )
  70. {
  71.     local float XL, YL;
  72.     local float YOffset;
  73.  
  74.     switch (Teams[I])
  75.     {
  76.     case 0:
  77.         XOffset = Canvas.ClipX/2 - Canvas.ClipX/8;
  78.         YOffset = Canvas.ClipY/4 + (LoopCount * 16);
  79.         break;
  80.     case 1:
  81.         XOffset = Canvas.ClipX - Canvas.ClipX/8;
  82.         YOffset = Canvas.ClipY/4 + (LoopCount * 16);
  83.         break;
  84.     case 2:
  85.         XOffset = Canvas.ClipX/2 - Canvas.ClipX/8;
  86.         YOffset = Canvas.ClipY/4 + (PlayerCounts[0] * 16) + int(PlayerCounts[0] > 0) * 48 + (LoopCount * 16);
  87.         break;
  88.     case 3:
  89.         XOffset = Canvas.ClipX - Canvas.ClipX/8;
  90.         YOffset = Canvas.ClipY/4 + (PlayerCounts[1] * 16) + int(PlayerCounts[1] > 0) * 48 + (LoopCount * 16);
  91.         break;
  92.     }
  93.  
  94.     Canvas.StrLen(int(Scores[I]), XL, YL);
  95.     XOffset -= XL;
  96.     Canvas.SetPos(XOffset, YOffset);
  97.     Canvas.DrawText(int(Scores[I]), false);
  98. }
  99.  
  100. function ShowScores( canvas Canvas )
  101. {
  102.     local PlayerReplicationInfo PRI;
  103.     local int PlayerCount, I, XOffset;
  104.     local int LoopCountTeam[4];
  105.     local float XL, YL, YOffset;
  106.     local TeamInfo TI;
  107.  
  108.     Canvas.Font = RegFont;
  109.  
  110.     // Header
  111.     DrawHeader(Canvas);
  112.  
  113.     // Trailer
  114.     DrawTrailer(Canvas);
  115.  
  116.     for ( I=0; I<16; I++ )
  117.         Scores[I] = -500;
  118.  
  119.     for ( I=0; I<4; I++ )
  120.         PlayerCounts[I] = 0;
  121.  
  122.     PlayerCount = 0;
  123.     foreach AllActors (class'PlayerReplicationInfo', PRI)
  124.     if ( !PRI.bIsSpectator )
  125.     {
  126.         if (PlayerCount >= 16)
  127.             break;
  128.  
  129.         PlayerNames[PlayerCount] = PRI.PlayerName;
  130.         TeamNames[PlayerCount] = PRI.TeamName;
  131.         Scores[PlayerCount] = PRI.Score;
  132.         Teams[PlayerCount] = PRI.Team;
  133.         Pings[PlayerCount] = PRI.Ping;
  134.  
  135.         PlayerCount++;
  136.         PlayerCounts[PRI.Team]++;
  137.     }
  138.     SortScores(PlayerCount);
  139.  
  140.     for ( I=0; I<PlayerCount; I++ )
  141.     {
  142.         if ( Teams[I] % 2 == 1 )
  143.             XOffset = Canvas.ClipX/8 + Canvas.ClipX/2;
  144.         else
  145.             XOffset = Canvas.ClipX/8;
  146.         Canvas.DrawColor = AltTeamColor[Teams[I]];
  147.  
  148.         // Player name
  149.         DrawName( Canvas, I, XOffset, LoopCountTeam[Teams[I]] );
  150.  
  151.         // Player ping
  152.         DrawPing( Canvas, I, XOffset, LoopCountTeam[Teams[I]] );
  153.  
  154.         // Player score
  155.         Canvas.DrawColor = TeamColor[Teams[I]];
  156.         DrawScore( Canvas, I, XOffset, LoopCountTeam[Teams[I]] );
  157.  
  158.         LoopCountTeam[Teams[I]]++;
  159.     }
  160.  
  161.     foreach AllActors(class'TeamInfo', TI)
  162.     {
  163.         if (PlayerCounts[TI.TeamIndex] > 0)
  164.         {
  165.             if ( TI.TeamIndex % 2 == 1 )
  166.                 XOffset = Canvas.ClipX/8 + Canvas.ClipX/2;
  167.             else
  168.                 XOffset = Canvas.ClipX/8;
  169.             if ( TI.TeamIndex > 1 )
  170.             {
  171.                 if (PlayerCounts[TI.TeamIndex - 2] > 0)
  172.                     YOffset = Canvas.ClipY/4 + PlayerCounts[TI.TeamIndex - 2] * 16 + 32;
  173.                 else
  174.                     YOffset = Canvas.ClipY/4 - 16;
  175.             }
  176.             else
  177.                 YOffset = Canvas.ClipY/4 - 16;
  178.             Canvas.DrawColor = TeamColor[TI.TeamIndex];
  179.             Canvas.SetPos(XOffset, YOffset);
  180.             Canvas.StrLen(TeamName[TI.TeamIndex], XL, YL);
  181.             Canvas.DrawText(TeamName[TI.TeamIndex], false);
  182.             Canvas.SetPos(XOffset + 96, YOffset);
  183.             Canvas.DrawText(int(TI.Score), false);
  184.         }
  185.     }
  186.  
  187.     Canvas.DrawColor.R = 255;
  188.     Canvas.DrawColor.G = 255;
  189.     Canvas.DrawColor.B = 255;
  190. }
  191.  
  192. defaultproperties
  193. {
  194.                 TeamName(0)="Red Team: "
  195.                 TeamName(1)="Blue Team: "
  196.                 TeamName(2)="Green Team: "
  197.                 TeamName(3)="Gold Team: "
  198.                 TeamColor(0)=(R=255)
  199.                 TeamColor(1)=(G=128,B=255)
  200.                 TeamColor(2)=(G=255)
  201.                 TeamColor(3)=(R=255,G=255)
  202.                 AltTeamColor(0)=(R=200)
  203.                 AltTeamColor(1)=(G=94,B=187)
  204.                 AltTeamColor(2)=(G=128)
  205.                 AltTeamColor(3)=(R=255,G=255,B=128)
  206. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement