// UnrealCTFScoreBoard
//=============================================================================
class UnrealCTFScoreBoard expands UnrealTeamScoreBoard;

#exec TEXTURE IMPORT NAME=BlueFlag FILE=..\BOTPACK\TEXTURES\HUD\i_bscore.PCX GROUP="Icons" MIPS=OFF
#exec TEXTURE IMPORT NAME=GreenFlag FILE=..\BOTPACK\TEXTURES\HUD\i_gscore.PCX GROUP="Icons" MIPS=OFF
#exec TEXTURE IMPORT NAME=RedFlag FILE=..\BOTPACK\TEXTURES\HUD\i_rscore.PCX GROUP="Icons" MIPS=OFF
#exec TEXTURE IMPORT NAME=YellowFlag FILE=..\BOTPACK\TEXTURES\HUD\i_yscore.PCX GROUP="Icons" MIPS=OFF

#exec TEXTURE IMPORT NAME=I_RedBox FILE=..\BOTPACK\TEXTURES\HUD\i_redbox.PCX GROUP="Icons" MIPS=OFF
#exec TEXTURE IMPORT NAME=I_BlueBox FILE=..\BOTPACK\TEXTURES\HUD\i_bluebox.PCX GROUP="Icons" MIPS=OFF

var byte HasFlags[32];

function ShowScores( canvas Canvas )
{
	local PlayerReplicationInfo PRI;
	local int PlayerCount, LoopCountTeam0, LoopCountTeam1, I, XOffset;
	local float XL, YL;
	local CTFFlag Flag;
	local CTFReplicationInfo CTFRI;

	Canvas.Font = Font'WhiteFont';
	
	// Header
	DrawHeader(Canvas);

	// Trailer
	DrawTrailer(Canvas);

	for ( I=0; I<32; I++ )
		Scores[I] = -500;

	foreach AllActors (class'PlayerReplicationInfo', PRI)
	{
		PlayerNames[PlayerCount] = PRI.PlayerName;
		TeamNames[PlayerCount] = PRI.TeamName;
		Scores[PlayerCount] = PRI.Score;
		Teams[PlayerCount] = PRI.Team;
		Pings[PlayerCount] = PRI.Ping;
		if (PRI.HasFlag != None)
			HasFlags[PlayerCount] = 1;
		else
			HasFlags[PlayerCount] = 0;

		PlayerCount++;		
	}
	
	SortScores(PlayerCount);
	
	for ( I=0; I<PlayerCount; I++ )
	{
		if (Teams[I] == 0) {
			XOffset = Canvas.ClipX/8;

			// Player name
			Canvas.DrawColor.R = 200;
			Canvas.DrawColor.G = 0;
			Canvas.DrawColor.B = 0;
			DrawName( Canvas, I, XOffset, LoopCountTeam0 );

			// Player ping
			DrawPing( Canvas, I, XOffset, LoopCountTeam0 );

			// Flag icon
			if (HasFlags[I] != 0)
			{
				Canvas.Style = 2;
				Canvas.SetPos(XOffset - 16, Canvas.ClipY/4 + (LoopCountTeam0 * 16) + 1);
				Canvas.DrawIcon(texture'I_RedBox', 1.0);
				Canvas.Style = 1;
			}

			// Player score
			Canvas.DrawColor.R = 255;
			Canvas.DrawColor.G = 0;
			Canvas.DrawColor.B = 0;
			DrawScore( Canvas, I, XOffset, LoopCountTeam0 );

			LoopCountTeam0++;
		} else {
			XOffset = Canvas.ClipX/2 + Canvas.ClipX/8;

			// Player name
			Canvas.DrawColor.R = 0;
			Canvas.DrawColor.G = 94;
			Canvas.DrawColor.B = 187;
			DrawName( Canvas, I, XOffset, LoopCountTeam1 );

			// Player ping
			DrawPing( Canvas, I, XOffset, LoopCountTeam1 );

			// Flag icon
			if (HasFlags[I] != 0)
			{
				Canvas.Style = 2;
				Canvas.SetPos(XOffset - 16, Canvas.ClipY/4 + (LoopCountTeam1 * 16) + 1);
				Canvas.DrawIcon(texture'I_BlueBox', 1.0);
				Canvas.Style = 1;
			}

			// Player score
			Canvas.DrawColor.R = 0;
			Canvas.DrawColor.G = 128;
			Canvas.DrawColor.B = 255;
			DrawScore( Canvas, I, XOffset, LoopCountTeam1 );

			LoopCountTeam1++;
		}
	}
	foreach AllActors(class'CTFReplicationInfo', CTFRI) {
		Canvas.DrawColor.R = 255;
		Canvas.DrawColor.G = 0;
		Canvas.DrawColor.B = 0;
		Canvas.SetPos(Canvas.ClipX/8, Canvas.ClipY/4 - 16);
		Canvas.StrLen("Red Team: ", XL, YL);
		Canvas.DrawText("Red Team: ", false);
		Canvas.SetPos(Canvas.ClipX/8 + 96, Canvas.ClipY/4 - 16);
		Canvas.DrawText(CTFRI.Team0Score, false);

		Canvas.DrawColor.R = 0;
		Canvas.DrawColor.G = 128;
		Canvas.DrawColor.B = 255;
		Canvas.SetPos(Canvas.ClipX/2 + Canvas.ClipX/8,  Canvas.ClipY/4 - 16);
		Canvas.StrLen("Blue Team: ", XL, YL);
		Canvas.DrawText("Blue Team: ", false);
		Canvas.SetPos(Canvas.ClipX/2 + Canvas.ClipX/8 + 96, Canvas.ClipY/4 - 16);
		Canvas.DrawText(CTFRI.Team1Score, false);
	}


	Canvas.DrawColor.R = 255;
	Canvas.DrawColor.G = 255;
	Canvas.DrawColor.B = 255;
}

defaultproperties
{
}
