//=============================================================================
// UnrealGameOptionsMenu
//=============================================================================
class UnrealGameOptionsMenu expands UnrealMenu;

function bool ProcessLeft()
{
	if ( Selection == 1 )
		Level.Game.SetGameSpeed(FMax(0.5, Level.TimeDilation - 0.1));
	else 
		return false;

	return true;
}

function bool ProcessRight()
{
	if ( Selection == 1 )
		Level.Game.SetGameSpeed(FMin(2.0, Level.TimeDilation + 0.1));
	else 
		return false;

	return true;
}

function bool ProcessSelection()
{
	local Menu ChildMenu;

	if ( Selection == 2 )
		ChildMenu = spawn(class'UnrealMenu', owner);
	else
		return false;

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

function SaveConfigs()
{
	Level.Game.SaveConfig();
}

function int DrawOptions(canvas Canvas, int StartX, int StartY, int Spacing)
{
	// draw text
	Canvas.SetPos(StartX, StartY );
	Canvas.DrawText("Game Speed", False);
	Canvas.SetPos(StartX + 160, StartY );
	Canvas.DrawText(int(100 * Level.Game.GameSpeed)$"%", False);
	Canvas.SetPos(StartX, StartY + Spacing );
	Canvas.DrawText("Advanced Options", False);

	return (StartY + 2 * Spacing);
}

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

	// Draw Title
	Canvas.Font = Font'LargeFont';
	Canvas.SetPos(Max(8, 0.5 * Canvas.ClipX - 144), 4 );
	Canvas.DrawText("GAME OPTIONS MENU", False);

	Spacing = Clamp(0.04 * Canvas.ClipY, 12, 32);
	StartX = Max(40, 0.5 * Canvas.ClipX - 120);
	StartY = Max(40, 0.5 * (Canvas.ClipY - MenuLength * Spacing - 128));
	Canvas.Font = Font'MedFont';

	DrawOptions(Canvas, StartX, StartY, Spacing);		

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

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

