UnrealShare
Class UnrealScoreBoard

source: e:\games\UnrealTournament\UnrealShare\Classes\UnrealScoreBoard.uc
Core.Object
   |
   +--Engine.Actor
      |
      +--Engine.Info
         |
         +--Engine.ScoreBoard
            |
            +--UnrealShare.UnrealScoreBoard
Direct Known Subclasses:UnrealTeamScoreBoard

class UnrealScoreBoard
extends Engine.ScoreBoard

//============================================================================= // UnrealScoreBoard //=============================================================================
Variables
 int Pings[16]
 string PlayerNames[16]
 float Scores[16]
 string TeamNames[16]
 byte Teams[16]


Function Summary
 void DrawHeader(Canvas Canvas)
 void DrawName(Canvas Canvas, int I, float XOffset, int LoopCount)
 void DrawPing(Canvas Canvas, int I, float XOffset, int LoopCount)
 void DrawScore(Canvas Canvas, int I, float XOffset, int LoopCount)
 void DrawTrailer(Canvas Canvas)
 void ShowScores(Canvas Canvas)
 void SortScores(int N)
 void Swap(int L, int R)



Source Code


00001	//=============================================================================
00002	// UnrealScoreBoard
00003	//=============================================================================
00004	class UnrealScoreBoard extends ScoreBoard;
00005	
00006	var string PlayerNames[16];
00007	var string TeamNames[16];
00008	var float Scores[16];
00009	var byte Teams[16];
00010	var int Pings[16];
00011	
00012	function DrawHeader( canvas Canvas )
00013	{
00014		local GameReplicationInfo GRI;
00015		local float XL, YL;
00016	
00017		if (Canvas.ClipX > 500)
00018		{
00019			foreach AllActors(class'GameReplicationInfo', GRI)
00020			{
00021				Canvas.bCenter = true;
00022	
00023				Canvas.SetPos(0.0, 32);
00024				Canvas.StrLen("TEST", XL, YL);
00025				if (Level.Netmode != NM_StandAlone)
00026					Canvas.DrawText(GRI.ServerName);
00027				Canvas.SetPos(0.0, 32 + YL);
00028				Canvas.DrawText("Game Type: "$GRI.GameName, true);
00029				Canvas.SetPos(0.0, 32 + 2*YL);
00030				Canvas.DrawText("Map Title: "$Level.Title, true);
00031				Canvas.SetPos(0.0, 32 + 3*YL);
00032				Canvas.DrawText("Author: "$Level.Author, true);
00033				Canvas.SetPos(0.0, 32 + 4*YL);
00034				if (Level.IdealPlayerCount != "")
00035					Canvas.DrawText("Ideal Player Load:"$Level.IdealPlayerCount, true);
00036	
00037				Canvas.bCenter = false;
00038			}
00039		}
00040	}
00041	
00042	function DrawTrailer( canvas Canvas )
00043	{
00044		local int Hours, Minutes, Seconds;
00045		local string HourString, MinuteString, SecondString;
00046		local float XL, YL;
00047	
00048		if (Canvas.ClipX > 500)
00049		{
00050			Seconds = int(Level.TimeSeconds);
00051			Minutes = Seconds / 60;
00052			Hours   = Minutes / 60;
00053			Seconds = Seconds - (Minutes * 60);
00054			Minutes = Minutes - (Hours * 60);
00055	
00056			if (Seconds < 10)
00057				SecondString = "0"$Seconds;
00058			else
00059				SecondString = string(Seconds);
00060	
00061			if (Minutes < 10)
00062				MinuteString = "0"$Minutes;
00063			else
00064				MinuteString = string(Minutes);
00065	
00066			if (Hours < 10)
00067				HourString = "0"$Hours;
00068			else
00069				HourString = string(Hours);
00070	
00071			Canvas.bCenter = true;
00072			Canvas.StrLen("Test", XL, YL);
00073			Canvas.SetPos(0, Canvas.ClipY - YL);
00074			Canvas.DrawText("Elapsed Time: "$HourString$":"$MinuteString$":"$SecondString, true);
00075			Canvas.bCenter = false;
00076		}
00077	
00078		if ((Pawn(Owner) != None) && (Pawn(Owner).Health <= 0))
00079		{
00080			Canvas.bCenter = true;
00081			Canvas.StrLen("Test", XL, YL);
00082			Canvas.SetPos(0, Canvas.ClipY - YL*6);
00083			Canvas.DrawColor.R = 0;
00084			Canvas.DrawColor.G = 255;
00085			Canvas.DrawColor.B = 0;
00086			Canvas.DrawText("You are dead.  Hit [Fire] to respawn!", true);
00087			Canvas.bCenter = false;
00088		}
00089	}
00090	
00091	function DrawName( canvas Canvas, int I, float XOffset, int LoopCount )
00092	{
00093		local int Step;
00094	
00095		if (Canvas.ClipX >= 640)
00096			Step = 16;
00097		else
00098			Step = 8;
00099	
00100		Canvas.SetPos(Canvas.ClipX/4, Canvas.ClipY/4 + (LoopCount * Step));
00101		Canvas.DrawText(PlayerNames[I], false);
00102	}
00103	
00104	function DrawPing( canvas Canvas, int I, float XOffset, int LoopCount )
00105	{
00106		local float XL, YL;
00107		local int Step;
00108	
00109		if (Canvas.ClipX >= 640)
00110			Step = 16;
00111		else
00112			Step = 8;
00113	
00114		if (Level.Netmode == NM_Standalone)
00115			return;
00116	
00117		Canvas.StrLen(Pings[I], XL, YL);
00118		Canvas.SetPos(Canvas.ClipX/4 - XL - 8, Canvas.ClipY/4 + (LoopCount * Step));
00119		Canvas.Font = Font'TinyWhiteFont';
00120		Canvas.DrawColor.R = 255;
00121		Canvas.DrawColor.G = 255;
00122		Canvas.DrawColor.B = 255;
00123		Canvas.DrawText(Pings[I], false);
00124		Canvas.Font = RegFont;
00125		Canvas.DrawColor.R = 0;
00126		Canvas.DrawColor.G = 255;
00127		Canvas.DrawColor.B = 0;
00128	}
00129	
00130	function DrawScore( canvas Canvas, int I, float XOffset, int LoopCount )
00131	{
00132		local int Step;
00133	
00134		if (Canvas.ClipX >= 640)
00135			Step = 16;
00136		else
00137			Step = 8;
00138	
00139		Canvas.SetPos(Canvas.ClipX/4 * 3, Canvas.ClipY/4 + (LoopCount * Step));
00140	
00141		if(Scores[I] >= 100.0)
00142			Canvas.CurX -= 6.0;
00143		if(Scores[I] >= 10.0)
00144			Canvas.CurX -= 6.0;
00145		if(Scores[I] < 0.0)
00146			Canvas.CurX -= 6.0;
00147		Canvas.DrawText(int(Scores[I]), false);
00148	}
00149	
00150	function Swap( int L, int R )
00151	{
00152		local string TempPlayerName, TempTeamName;
00153		local float TempScore;
00154		local byte TempTeam;
00155		local int TempPing;
00156	
00157		TempPlayerName = PlayerNames[L];
00158		TempTeamName = TeamNames[L];
00159		TempScore = Scores[L];
00160		TempTeam = Teams[L];
00161		TempPing = Pings[L];
00162		
00163		PlayerNames[L] = PlayerNames[R];
00164		TeamNames[L] = TeamNames[R];
00165		Scores[L] = Scores[R];
00166		Teams[L] = Teams[R];
00167		Pings[L] = Pings[R];
00168		
00169		PlayerNames[R] = TempPlayerName;
00170		TeamNames[R] = TempTeamName;
00171		Scores[R] = TempScore;
00172		Teams[R] = TempTeam;
00173		Pings[R] = TempPing;
00174	}
00175	
00176	function SortScores(int N)
00177	{
00178		local int I, J, Max;
00179		
00180		for ( I=0; I<N-1; I++ )
00181		{
00182			Max = I;
00183			for ( J=I+1; J<N; J++ )
00184				if (Scores[J] > Scores[Max])
00185					Max = J;
00186			Swap( Max, I );
00187		}
00188	}
00189	
00190	function ShowScores( canvas Canvas )
00191	{
00192		local PlayerReplicationInfo PRI;
00193		local int PlayerCount, LoopCount, I;
00194		local float XL, YL;
00195	
00196		Canvas.Font = RegFont;
00197	
00198		// Header
00199		DrawHeader(Canvas);
00200	
00201		// Trailer
00202		DrawTrailer(Canvas);
00203	
00204		// Wipe everything.
00205		for ( I=0; I<16; I++ )
00206		{
00207			Scores[I] = -500;
00208		}
00209	
00210		Canvas.DrawColor.R = 0;
00211		Canvas.DrawColor.G = 255;
00212		Canvas.DrawColor.B = 0;
00213	
00214		foreach AllActors (class'PlayerReplicationInfo', PRI)
00215			if ( !PRI.bIsSpectator )
00216			{
00217				PlayerNames[PlayerCount] = PRI.PlayerName;
00218				TeamNames[PlayerCount] = PRI.TeamName;
00219				Scores[PlayerCount] = PRI.Score;
00220				Teams[PlayerCount] = PRI.Team;
00221				Pings[PlayerCount] = PRI.Ping;
00222	
00223				PlayerCount++;
00224			}
00225		
00226		SortScores(PlayerCount);
00227		
00228		LoopCount = 0;
00229		
00230		for ( I=0; I<PlayerCount; I++ )
00231		{
00232			// Player name
00233			DrawName(Canvas, I, 0, LoopCount);
00234			
00235			// Player ping
00236			DrawPing(Canvas, I, 0, LoopCount);
00237	
00238			// Player score
00239			DrawScore(Canvas, I, 0, LoopCount);
00240		
00241			LoopCount++;
00242		}
00243	
00244		Canvas.DrawColor.R = 255;
00245		Canvas.DrawColor.G = 255;
00246		Canvas.DrawColor.B = 255;
00247	}
00248	
00249	defaultproperties
00250	{
00251	     RegFont=Font'UnrealShare.WhiteFont'
00252	}

End Source Code