//=============================================================================
// UnrealOptionsMenu
//=============================================================================
class UnrealOptionsMenu expands UnrealMenu;

function bool ProcessYes()
{
	if ( Selection == 4 )
		PlayerOwner.InvertMouse(True);
	else if ( Selection == 5 )
		PlayerOwner.SnapView(True);
	else if ( Selection == 6 )
		PlayerOwner.AlwaysMouseLook(True);
	else if ( Selection == 7 )
		PlayerOwner.StairLook(True);
	else 
		return false;

	return true;
}

function bool ProcessNo()
{
	if ( Selection == 4 )
		PlayerOwner.InvertMouse(False);
	else if ( Selection == 5 )
		PlayerOwner.SnapView(False);
	else if ( Selection == 6 )
		PlayerOwner.AlwaysMouseLook(False);
	else if ( Selection == 7 )
		PlayerOwner.StairLook(False);
	else 
		return false;

	return true;
}

function bool ProcessLeft()
{
	if ( Selection == 3 )
		PlayerOwner.SetSensitivity(FMax(1,PlayerOwner.MouseSensitivity - 1));
	else if ( Selection == 4 )
		PlayerOwner.InvertMouse(!PlayerOwner.bInvertMouse);
	else if ( Selection == 5 )
		PlayerOwner.SnapView(!PlayerOwner.bSnapToLevel);
	else if ( Selection == 6 )
		PlayerOwner.AlwaysMouseLook(!PlayerOwner.bAlwaysMouseLook);
	else if ( Selection == 7 )
		PlayerOwner.StairLook(!PlayerOwner.bLookUpStairs);
	else if ( Selection == 8 )
		PlayerOwner.ChangeCrossHair();
	else if ( Selection == 9 )
	{
		if ( PlayerOwner.Handedness == 1 )
			PlayerOwner.SetHand("Right");
		else if ( PlayerOwner.Handedness == 0 )
			PlayerOwner.SetHand("Left");
		else
			PlayerOwner.SetHand("Center");
	}
	else if ( Selection == 10 )
	{
		if ( PlayerOwner.DodgeClickTime > 0 )
			PlayerOwner.DodgeClickTime(-1);
		else
			PlayerOwner.DodgeClickTime(PlayerOwner.Default.DodgeClickTime);
	}
	else if ( Selection == 13 )
		PlayerOwner.myHUD.ChangeHUD(-1);
	else if ( Selection == 14 )
		PlayerOwner.SetBob(PlayerOwner.Bob - 0.001);
	else 
		return false;

	return true;
}

function bool ProcessRight()
{
	if ( Selection == 3 )
		PlayerOwner.SetSensitivity(PlayerOwner.MouseSensitivity + 1);
	else if ( Selection == 4 )
		PlayerOwner.InvertMouse(!PlayerOwner.bInvertMouse);
	else if ( Selection == 5 )
		PlayerOwner.SnapView(!PlayerOwner.bSnapToLevel);
	else if ( Selection == 6 )
		PlayerOwner.AlwaysMouseLook(!PlayerOwner.bAlwaysMouseLook);
	else if ( Selection == 7 )
		PlayerOwner.StairLook(!PlayerOwner.bLookUpStairs);
	else if ( Selection == 8 )
		PlayerOwner.MyHUD.ChangeCrossHair(-1);
	else if ( Selection == 9 )
	{
		if ( PlayerOwner.Handedness == -1 )
			PlayerOwner.SetHand("Left");
		else if ( PlayerOwner.Handedness == 0 )
			PlayerOwner.SetHand("Right");
		else
			PlayerOwner.SetHand("Center");
	}
	else if ( Selection == 10 )
	{
		if ( PlayerOwner.DodgeClickTime > 0 )
			PlayerOwner.DodgeClickTime(-1);
		else
			PlayerOwner.DodgeClickTime(PlayerOwner.Default.DodgeClickTime);
	}
	else if ( Selection == 13 )
		PlayerOwner.myHUD.ChangeHUD(1);
	else if ( Selection == 14 )
		PlayerOwner.SetBob(PlayerOwner.Bob + 0.001);
	else
		return false;

	return true;
}

function bool ProcessSelection()
{
	local Menu ChildMenu;

	if ( Selection == 4 )
		PlayerOwner.InvertMouse(!PlayerOwner.bInvertMouse);
	else if ( Selection == 5 )
		PlayerOwner.SnapView(!PlayerOwner.bSnapToLevel);
	else if ( Selection == 6 )
		PlayerOwner.AlwaysMouseLook(!PlayerOwner.bAlwaysMouseLook);
	else if ( Selection == 7 )
		PlayerOwner.StairLook(!PlayerOwner.bLookUpStairs);
	else if ( Selection == 8 )
		PlayerOwner.ChangeCrossHair();
	else if ( Selection == 9 )
	{
		if ( PlayerOwner.Handedness == 1 )
			PlayerOwner.SetHand("Right");
		else if ( PlayerOwner.Handedness == 0 )
			PlayerOwner.SetHand("Left");
		else
			PlayerOwner.SetHand("Center");
	}
	else if ( Selection == 10 )
	{
		if ( PlayerOwner.DodgeClickTime > 0 )
			PlayerOwner.DodgeClickTime(-1);
		else
			PlayerOwner.DodgeClickTime(PlayerOwner.Default.DodgeClickTime);
	}
	else if ( Selection == 13 )
		PlayerOwner.myHUD.ChangeHUD(1);
	else if ( Selection == 11 )
		ChildMenu = spawn(class'UnrealMenu', owner);
	else if ( Selection == 12 )
		ChildMenu = spawn(class'UnrealWeaponMenu', owner);
	else
		return false;

	if ( ChildMenu != None )
	{
		HUD(Owner).MainMenu = ChildMenu;
		ChildMenu.ParentMenu = self;
		ChildMenu.PlayerOwner = PlayerOwner;
	}
	return true;
}

function SaveConfigs()
{
	SaveConfig();
	PlayerOwner.SaveConfig('PlayerPawn');
}

function DrawMenu(canvas Canvas)
{
	local int StartX, StartY, Spacing;

	// Draw Title
	StartX = Max(8, 0.5 * Canvas.ClipX - 96);
	Canvas.Font = Font'LargeFont';
	Canvas.SetPos(StartX, 4 );
	Canvas.DrawText("OPTIONS MENU", False);
		
	Spacing = Clamp(0.04 * Canvas.ClipY, 11, 32);
	StartX = Max(40, 0.5 * Canvas.ClipX - 120);
	StartY = Max(36, 0.5 * (Canvas.ClipY - MenuLength * Spacing - 128));
	Canvas.Font = Font'MedFont';

	// draw text
	Canvas.SetPos(StartX, StartY );
	Canvas.DrawText("Music Volume", False);
	Canvas.SetPos(StartX, StartY + Spacing );
	Canvas.DrawText("Sound Volume", False);
	Canvas.SetPos(StartX, StartY + 2 * Spacing );
	Canvas.DrawText("Mouse Sensitivity:", False);
	Canvas.SetPos(StartX + 160, StartY + 2 * Spacing );
 	Canvas.DrawText(int(PlayerOwner.MouseSensitivity), False);
	Canvas.SetPos(StartX, StartY + 3 * Spacing );
	Canvas.DrawText("Invert Mouse:", False);
	Canvas.SetPos(StartX + 160, StartY + 3 * Spacing );
 	Canvas.DrawText(PlayerOwner.bInvertMouse, False);
	Canvas.SetPos(StartX, StartY + 4 * Spacing );
	Canvas.DrawText("LookSpring:", False);
	Canvas.SetPos(StartX + 160, StartY + 4 * Spacing );
 	Canvas.DrawText(PlayerOwner.bSnapToLevel, False);
	Canvas.SetPos(StartX, StartY + 5 * Spacing );
	Canvas.DrawText("Always MouseLook:", False);
	Canvas.SetPos(StartX + 160, StartY + 5 * Spacing );
 	Canvas.DrawText(PlayerOwner.bAlwaysMouseLook, False);
	Canvas.SetPos(StartX, StartY + 6 * Spacing );
	Canvas.DrawText("Auto-Slope Look", False);
	Canvas.SetPos(StartX + 160 , StartY + 6 * Spacing );
 	Canvas.DrawText(PlayerOwner.bLookUpStairs, False);
	Canvas.SetPos(StartX, StartY + 7 * Spacing );
	Canvas.DrawText("CrossHair", False);
	PlayerOwner.MyHUD.DrawCrossHair(Canvas, StartX + 160, StartY + 7 * Spacing);
	Canvas.SetPos(StartX, StartY + 8 * Spacing );
	Canvas.DrawText("Weapon Hand", False);
	Canvas.SetPos(StartX + 160, StartY + 8 * Spacing );
	if ( PlayerOwner.Handedness == 1 )
		Canvas.DrawText("Left", False);
	else if ( PlayerOwner.Handedness == 0 )
		Canvas.DrawText("Center", False);
	else
		Canvas.DrawText("Right", False);
	Canvas.SetPos(StartX, StartY + 9 * Spacing );
	Canvas.DrawText("Dodging ", False);
	Canvas.SetPos(StartX + 160, StartY + 9 * Spacing );
	if ( PlayerOwner.DodgeClickTime > 0 )
		Canvas.DrawText("Enabled", False);
	else
		Canvas.DrawText("Disabled", False);
	Canvas.SetPos(StartX, StartY + 10 * Spacing );
	Canvas.DrawText("Customize Controls", False);
	Canvas.SetPos(StartX, StartY + 11 * Spacing );
	Canvas.DrawText("Prioritize Weapons", False);
	Canvas.SetPos(StartX, StartY + 12 * Spacing );
	Canvas.DrawText("HUD Configuration", False);
	Canvas.SetPos(StartX + 160, StartY + 12 * Spacing );
 	Canvas.DrawText(PlayerOwner.MyHUD.HudMode, False);
	Canvas.SetPos(StartX, StartY + 13 * Spacing );
	Canvas.DrawText("View Bob", False);
	Canvas.SetPos(StartX + 160, StartY + 13 * Spacing );
	Canvas.DrawText(100 * PlayerOwner.Bob, False);

	// show selection
	Canvas.SetPos( StartX - 20, StartY - Spacing + Spacing * Selection);
	Canvas.DrawText("[]", false);	

	// Draw help panel
	DrawHelpPanel(Canvas, StartY + MenuLength * Spacing);
}

