//=============================================================================
// ChallengeHUD
// Heads up display
//=============================================================================
class ChallengeHUD expands UnrealHUD
	localized
	config;

#exec TEXTURE IMPORT NAME=MArrowR FILE=..\BOTPACK\TEXTURES\HUD\Arrow-R32.PCX GROUP="Icons" MIPS=OFF

var bool bStartUpMessage;
var string[255] ReceivedMessage;
var string[20] ReceivedName;
var ZoneInfo ReceivedZone;
var float ReceivedTime;
var Font HUDFont;
var texture TutIconTex;
var bool TutIcon, DoTutIcon;
var int TutIconX, TutIconY;
var float TutIconBlink;
var bool bForceScores;

// Identify Strings
var localized string[32] IdentifyCallsign;

simulated function DisplayProgressMessage( canvas Canvas )
{
	local int TempX, TempY;

	TempX = Canvas.ClipX;
	TempY = Canvas.ClipY;
	Canvas.SetOrigin(Max(0,Canvas.ClipX/2-160),Max(0,Canvas.ClipY/2-100));
	Canvas.SetClip(320,200);
	Canvas.SetPos(0,0);
	Canvas.Style = 1;	

	Canvas.DrawColor.R = 255;
	Canvas.DrawColor.G = 255;
	Canvas.DrawColor.B = 255;
	Canvas.SetPos(0, 0.25 * Canvas.ClipY);
	Canvas.bCenter = true;
	Canvas.Font = Canvas.MedFont;
	Canvas.DrawText(PlayerPawn(Owner).ProgressMessage, false);
	Canvas.SetPos(0, 0.25 * Canvas.ClipY + 12);
	Canvas.DrawText(PlayerPawn(Owner).ProgressMessageTwo, false);
	Canvas.bCenter = false;
	HUDSetup(canvas);	
	Canvas.ClipX = TempX;
	Canvas.ClipY = TempY;
}

simulated function PreRender( canvas Canvas )
{
	if (PlayerPawn(Owner).Weapon != None)
		PlayerPawn(Owner).Weapon.PreRender(Canvas);
}

simulated function PostRender( canvas Canvas )
{
	local PlayerPawn PP;

	if (PlayerPawn(Owner).Weapon != None)
		PlayerPawn(Owner).Weapon.PostRender(Canvas);

	HUDSetup(canvas);

	if ( PlayerPawn(Owner) != None )
	{
		if ( PlayerPawn(Owner).bShowMenu )
		{
			DisplayMenu(Canvas);
			return;
		}
		if (( PlayerPawn(Owner).bShowScores ) || ( bForceScores ))
		{
			if ( (PlayerPawn(Owner).Scoring == None) && (PlayerPawn(Owner).ScoringType != None) )
				PlayerPawn(Owner).Scoring = Spawn(PlayerPawn(Owner).ScoringType, PlayerPawn(Owner));
			if ( PlayerPawn(Owner).Scoring != None )
			{ 
				PlayerPawn(Owner).Scoring.ShowScores(Canvas);
				if (!bForceScores)
					return;
			}
		}
		else if ( (PlayerPawn(Owner).Weapon != None) && (Level.LevelAction == LEVACT_None) )
		{
			PlayerPawn(Owner).Weapon.PostRender(Canvas);
			if ( !PlayerPawn(Owner).Weapon.bOwnsCrossHair )
				DrawCrossHair(Canvas, 0.5 * Canvas.ClipX - 8, 0.5 * Canvas.ClipY - 8);
		}

		if ( bStartUpMessage && (Level.TimeSeconds < 5) )
		{
			bStartUpMessage = false;
			PlayerPawn(Owner).SetProgressTime(7);
		}
		if ( PlayerPawn(Owner).ProgressTimeOut > Level.TimeSeconds )
			DisplayProgressMessage(Canvas);
	}

	if (HudMode==5) 
	{
		DrawInventory(Canvas, Canvas.ClipX-96, 0,False);		
		Return;
	}
	if (Canvas.ClipX<320) HudMode = 4;

	if ( !Owner.IsA('Spectator') )
	{
		// Draw Armor
		if (HudMode<2) DrawArmor(Canvas, 0, 0,False);
		else if (HudMode==3 || HudMode==2) DrawArmor(Canvas, 0, Canvas.ClipY-32,False);
		else if (HudMode==4) DrawArmor(Canvas, Canvas.ClipX-64, Canvas.ClipY-64,True);
		
		// Draw Ammo
		if (HudMode!=4) DrawAmmo(Canvas, Canvas.ClipX-48-64, Canvas.ClipY-32);
		else DrawAmmo(Canvas, Canvas.ClipX-48, Canvas.ClipY-32);
		
		// Draw Health
		if (HudMode<2) DrawHealth(Canvas, 0, Canvas.ClipY-32);
		else if (HudMode==3||HudMode==2) DrawHealth(Canvas, Canvas.ClipX-128, Canvas.ClipY-32);
		else if (HudMode==4) DrawHealth(Canvas, Canvas.ClipX-64, Canvas.ClipY-32);
			
		// Display Inventory
		if (HudMode<2) DrawInventory(Canvas, Canvas.ClipX-96, 0,False);
		else if (HudMode==3) DrawInventory(Canvas, Canvas.ClipX-96, Canvas.ClipY-64,False);
		else if (HudMode==4) DrawInventory(Canvas, Canvas.ClipX-64, Canvas.ClipY-64,True);
		else if (HudMode==2) DrawInventory(Canvas, Canvas.ClipX/2-64, Canvas.ClipY-32,False);	

		// Display Frag count
		if ( (Level.Game == None) || Level.Game.IsA('DeathMatchGame') ) 
		{
			if (HudMode<3) DrawFragCount(Canvas, Canvas.ClipX-32,Canvas.ClipY-64);
			else if (HudMode==3) DrawFragCount(Canvas, 0,Canvas.ClipY-64);
			else if (HudMode==4) DrawFragCount(Canvas, 0,Canvas.ClipY-32);
		}
	}

	// Display Identification Info
	DrawIdentifyInfo(Canvas, 0, Canvas.ClipY - 64.0);

	// Display MOTD
	if (MOTDFadeOutTime != 0.0)
		DrawMOTD(Canvas);

	// Training Arrow
	if (TutIcon)
	{
		Canvas.Style = 2;
		Canvas.SetPos(Canvas.ClipX + TutIconX, Canvas.ClipY + TutIconY);
		Canvas.DrawIcon(TutIconTex, 1.0);
		Canvas.Style = 1;
	}
}

simulated function Tick(float DeltaTime)
{
	Super.Tick(DeltaTime);

	if (!DoTutIcon)
	{
		TutIcon = False;
		return;
	}

	TutIconBlink += DeltaTime;
	if (TutIconBlink >= 0.5)
	{
		TutIcon = !TutIcon;
		TutIconBlink = 0.0;
	}
}

simulated function DrawTutIcon(texture Icon, int X, int Y)
{
	TutIconTex = Icon;
	DoTutIcon = True;
	TutIcon = True;
	TutIconX = X;
	TutIconY = Y;
}

simulated function StopTutIcon()
{
	DoTutIcon = False;
}

defaultproperties
{
     bStartUpMessage=True
     HUDFont=Font'UnrealI.WhiteFont'
	 IdentifyCallsign="Callsign"
     HudMode=1
     MainMenuType=Class'Botpack.ChallengeMainMenu'
}
