#region File Description
//-----------------------------------------------------------------------------
// MainMenuScreen.cs
//
// Microsoft XNA Community Game Platform
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#endregion

#region Using Statements
using System;
using Microsoft.Xna.Framework.Audio;

#endregion

namespace GhostArena5
{
    /// <summary>
    /// The main menu screen is the first thing displayed when the game starts up.
    /// </summary>
    class MainMenuScreen : MenuScreen
    {
        private Cue _titleCue;

        /// <summary>
        /// Constructor fills in the menu contents.
        /// </summary>
        public MainMenuScreen()
        {
            _menuEntries.Add("Play Game");
            _menuEntries.Add("High Scores");
            _menuEntries.Add("Options");
            _menuEntries.Add("Exit");
        }

        public override void Initialize()
        {
            _titleCue = ((Game1)ScreenManager.Game).soundbank.GetCue("title");
            _titleCue.Play();

            base.Initialize();
        }

        /// <summary>
        /// Responds to user menu selections.
        /// </summary>
        protected override void OnSelectEntry(int entryIndex)
        {
            switch (entryIndex)
            {
                case 0:
                    // Play the game.
                    //LoadingScreen.Load(_screenManager, LoadGameplayScreen, true);
                    _screenManager.AddScreen(new DifficultyScreen());
                    break;

                case 1:
                    _screenManager.AddScreen(new HighScoreScreen());
                    break;

                case 2:
                    // Go to the options screen.
                    _screenManager.AddScreen(new OptionsMenuScreen());
                    break;

                case 3:
                    // Exit the sample.
                    OnCancel();
                    break;
            }
        }

        void StartGame(object sender, EventArgs e)
        {
            _screenManager.AddScreen(new GameplayScreen((int)sender));
        }

        /// <summary>
        /// When the user cancels the main menu, ask if they want to exit the sample.
        /// </summary>
        protected override void OnCancel()
        {
            const string message = "Are you sure you want to exit this sample?";

            MessageBoxScreen messageBox = new MessageBoxScreen(message);

            messageBox.Accepted += ExitMessageBoxAccepted;

            _screenManager.AddScreen(messageBox);
        }


        /// <summary>
        /// Event handler for when the user selects ok on the "are you sure
        /// you want to exit" message box.
        /// </summary>
        void ExitMessageBoxAccepted(object sender, EventArgs e)
        {
            _screenManager.Game.Exit();
        }


        /// <summary>
        /// Loading screen callback for activating the gameplay screen.
        /// </summary>
        //void LoadGameplayScreen(object sender, EventArgs e)
        //{
        //    _screenManager.AddScreen(new GameplayScreen());
        //}

    }
}
