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

namespace GhostArena3D
{
   /// <summary>
   /// The options screen is brought up over the top of the main menu
   /// screen, and gives the user a chance to configure the game
   /// in various hopefully useful ways.
   /// </summary>
   class DifficultyScreen : MenuScreen
   {
      GameType gameType;

      /// <summary>
      /// Constructor populates the menu with empty strings: the real values
      /// are filled in by the Update method to reflect the changing settings.
      /// </summary>
      public DifficultyScreen(GameType type) : base("")
      {
         gameType = type;
      }

      public override void LoadContent()
      {
         DifficultySystem difficultySystem = ((GhostArena3D)ScreenManager.Game).Difficulty;
         string[] names = difficultySystem.GetDifficultyNames();

         foreach (string item in names)
         {
            MenuEntries.Add(new MenuEntry(item));
         }

         MenuEntries.Add(new MenuEntry("Back"));

         base.LoadContent();
      }

      /// <summary>
      /// Responds to user menu selections.
      /// </summary>
      protected override void OnSelectEntry(int entryIndex)
      {
         switch (entryIndex)
         {
            case 0:
            case 1:
            case 2:

               if(gameType == GameType.SINGLE_PLAYER)
               {
                  // Load the game.
                  LoadingScreen.Load(ScreenManager, true, new GameplayScreen(entryIndex, gameType));
               }
               else
               {
                  // Get game lobby screen for the host.
                  ScreenManager.AddScreen(new GameLobbyScreen(entryIndex, gameType, false));
               }

               break;

            case 3:

               // Go back to the main menu.
               ExitScreen();

               break;
         }
      }


      /// <summary>
      /// When the user cancels the options screen, go back to the main menu.
      /// </summary>
      protected override void OnCancel()
      {
         ExitScreen();
      }
   }
}
