// ====================================================================
// R-mini mod Main Menu
// © 2006 by Cenens Tom
// ====================================================================

class GUI_MainMenu extends UT2K4GUIPage;

var automated 	GUIButton	b_Play, b_Join, b_Settings, b_Quit, b_InstantAction;
var bool	AllowClose;

function InitComponent(GUIController MyController, GUIComponent MyOwner)
{
    Super.Initcomponent(MyController, MyOwner);

	MyController.bModAuthor = true;
	MyController.SaveConfig();
}

function bool MyKeyEvent(out byte Key,out byte State,float delta)
{
	if(Key == 0x1B && State == 1)	// Escape pressed
	{
		AllowClose = true;
		return true;
	}
	else
		return false;
}

function bool CanClose(optional Bool bCanceled)
{
	if(AllowClose)
		Controller.OpenMenu(Controller.GetQuitPage());

	return false;
}

function OnClose(optional Bool bCanceled)
{
}

function bool ButtonClick(GUIComponent Sender)
{
    local UT2K4GUIController C;

	C = UT2K4GUIController(Controller);

	if (Sender == b_Play)
        Controller.OpenMenu(Controller.GetMultiplayerPage());

    else if (Sender == b_InstantAction)
    Controller.OpenMenu(Controller.GetInstantActionPage ());

	else if (Sender == b_Join)
        Controller.OpenMenu(Controller.GetServerBrowserPage());

	else if (Sender == b_Settings)
    	Controller.OpenMenu(Controller.GetSettingsPage());

    else if (Sender == b_Quit)
		Controller.OpenMenu(Controller.GetQuitPage());

	return true;
}

defaultproperties
{
     Begin Object Class=GUIButton Name=bPlay
         CaptionAlign=TXTA_Left
         CaptionEffectStyleName="TextButtonEffect"
         Caption="Host Race"
         bUseCaptionHeight=True
         FontScale=FNS_Small
         StyleName="TextButton"
         Hint="Click here to host a race."
         WinTop=0.555417
         WinLeft=0.393750
         WinWidth=0.574135
         WinHeight=0.088333
         TabOrder=3
         bFocusOnWatch=True
         OnClick=GUI_MainMenu.ButtonClick
         OnKeyEvent=bPlay.InternalOnKeyEvent
     End Object
     b_Play=GUIButton'R.GUI_MainMenu.bPlay'

     Begin Object Class=GUIButton Name=bJoin
         CaptionAlign=TXTA_Left
         CaptionEffectStyleName="TextButtonEffect"
         Caption="Join Race"
         bUseCaptionHeight=True
         FontScale=FNS_Small
         StyleName="TextButton"
         Hint="Click here to join a hosted race."
         WinTop=0.651666
         WinLeft=0.406452
         WinWidth=0.226800
         WinHeight=0.088333
         TabOrder=4
         bFocusOnWatch=True
         OnClick=GUI_MainMenu.ButtonClick
         OnKeyEvent=bJoin.InternalOnKeyEvent
     End Object
     b_Join=GUIButton'R.GUI_MainMenu.bJoin'

     Begin Object Class=GUIButton Name=SettingsButton
         CaptionAlign=TXTA_Right
         CaptionEffectStyleName="TextButtonEffect"
         Caption="Options"
         bUseCaptionHeight=True
         FontScale=FNS_Small
         StyleName="TextButton"
         Hint="Change your controls and settings"
         WinTop=0.750512
         WinLeft=0.079688
         WinWidth=0.526767
         WinHeight=0.048333
         TabOrder=5
         bFocusOnWatch=True
         OnClick=GUI_MainMenu.ButtonClick
         OnKeyEvent=SettingsButton.InternalOnKeyEvent
     End Object
     b_Settings=GUIButton'R.GUI_MainMenu.SettingsButton'

     Begin Object Class=GUIButton Name=QuitButton
         CaptionAlign=TXTA_Left
         CaptionEffectStyleName="TextButtonEffect"
         Caption="Exit"
         bUseCaptionHeight=True
         FontScale=FNS_Small
         StyleName="TextButton"
         Hint="Exit R mini-mod"
         WinTop=0.848430
         WinLeft=0.467191
         WinWidth=0.526767
         WinHeight=0.088333
         TabOrder=6
         bFocusOnWatch=True
         OnClick=GUI_MainMenu.ButtonClick
         OnKeyEvent=QuitButton.InternalOnKeyEvent
     End Object
     b_Quit=GUIButton'R.GUI_MainMenu.QuitButton'

     Begin Object Class=GUIButton Name=InstantActionButton
         CaptionAlign=TXTA_Left
         CaptionEffectStyleName="TextButtonEffect"
         Caption="Practice"
         bUseCaptionHeight=True
         FontScale=FNS_Small
         StyleName="TextButton"
         Hint="Practice"
         WinTop=0.465416
         WinLeft=0.414265
         WinWidth=0.226800
         WinHeight=0.088333
         TabOrder=2
         bFocusOnWatch=True
         OnClick=GUI_MainMenu.ButtonClick
         OnKeyEvent=InstantActionButton.InternalOnKeyEvent
     End Object
     b_InstantAction=GUIButton'R.GUI_MainMenu.InstantActionButton'

     AllowClose=True
     bAllowedAsLast=True
     Background=Texture'RGuiTextures.Backgrounds.vpower'
     WinTop=0.000000
     WinHeight=1.000000
}
