A popup message box screen, used to display "are you sure?" confirmation messages.
Inheritance: GameScreen
        public override void HandleInput(InputState input)
        {
            base.HandleInput(input);

            for (int i = 0; i < 6; i++)
            {
                if (Settings.players[i].active == false && input.IsPlayerTurnLeft((PlayerNumber)i))
                {
                    Settings.players[i].active = true;
                    Settings.Game.num_players++;
                }
                else if (Settings.players[i].active == true && input.IsPlayerTurnRight((PlayerNumber)i))
                {
                    Settings.players[i].active = false;
                    Settings.Game.num_players--;
                }
            }

            if (Settings.Game.num_players > 1 && input.MenuSelect)
            {
                LoadingScreen.Load(ScreenManager, true, new GamePlayScreen());
                ExitScreen();
            }

            if (input.PauseGame)
            {
                const string message = "Are you sure you want to quit this game?";
                MessageBoxScreen confirmQuitMessageBox = new MessageBoxScreen(message);
                confirmQuitMessageBox.Accepted += ConfirmQuitMessageBoxAccepted;
                ScreenManager.AddScreen(confirmQuitMessageBox);
            }
        }
        /// <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 confirmExitMessageBox = new MessageBoxScreen(message);

            confirmExitMessageBox.Accepted += ConfirmExitMessageBoxAccepted;

            ScreenManager.AddScreen(confirmExitMessageBox);
        }
        /// <summary>
        /// When the user cancels the main menu, ask if they want to exit.
        /// </summary>
        protected override void OnCancel(PlayerIndex playerIndex)
        {
            const string message = "Wollen Sie wirklich davonlaufen?";

            MessageBoxScreen confirmExitMessageBox = new MessageBoxScreen(message);

            confirmExitMessageBox.Accepted += ConfirmExitMessageBoxAccepted;

            ScreenManager.AddScreen(confirmExitMessageBox, playerIndex);
        }
        /// <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 confirmExitMessageBox = new MessageBoxScreen(message);

            confirmExitMessageBox.Accepted += ConfirmExitMessageBoxAccepted;

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

            MessageBoxScreen confirmExitMessageBox = new MessageBoxScreen(message);

            confirmExitMessageBox.Accepted += ConfirmExitMessageBoxAccepted;

            ScreenManager.AddScreen(confirmExitMessageBox, playerIndex);
        }
        /// <summary>
        /// When the user cancels the main menu, ask if they want to exit.
        /// </summary>
        protected override void OnCancel(PlayerIndex playerIndex)
        {
            const string message = "Wollen Sie wirklich davonlaufen?";

            MessageBoxScreen confirmExitMessageBox = new MessageBoxScreen(message);

            confirmExitMessageBox.Accepted += ConfirmExitMessageBoxAccepted;

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

            MessageBoxScreen confirmExitMessageBox = new MessageBoxScreen(message);

            confirmExitMessageBox.Accepted += ConfirmExitMessageBoxAccepted;

            ScreenManager.AddScreen(confirmExitMessageBox, playerIndex);
        }
        /// <summary>
        /// Event handler for when the Quit Game menu entry is selected.
        /// </summary>
        void QuitGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            const string message = "Are you sure you want to quit this game?";

            MessageBoxScreen confirmQuitMessageBox = new MessageBoxScreen(message);

            confirmQuitMessageBox.Accepted += ConfirmQuitMessageBoxAccepted;

            ScreenManager.AddScreen(confirmQuitMessageBox, ControllingPlayer);
        }
        /// <summary>
        /// Event handler for when the Quit Game menu entry is selected.
        /// </summary>
        void QuitGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            const string message = "Are you sure you want to quit this game?";

            MessageBoxScreen confirmQuitMessageBox = new MessageBoxScreen(message);

            confirmQuitMessageBox.Accepted += ConfirmQuitMessageBoxAccepted;

            ScreenManager.AddScreen(confirmQuitMessageBox, ControllingPlayer);
        }
        private void ExitMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            const string message = "Are you sure you want to quit?";

            MessageBoxScreen confirmExitMessageBox = new MessageBoxScreen(message);

            confirmExitMessageBox.Accepted += ConfirmExitMessageBoxAccepted;

            ScreenManager.AddScreen(confirmExitMessageBox, ActivePlayer.PlayerIndex);
        }
        /// <summary>
        /// Когда пользователь закрывает главное меню, спрашивает, хочет ли он выйти из приложения.
        /// </summary>
        protected override void OnCancel(PlayerIndex playerIndex)
        {
            const string message = "Вы точно хотите выйти из приложение?";

            MessageBoxScreen confirmExitMessageBox = new MessageBoxScreen(message);

            confirmExitMessageBox.Accepted += ConfirmExitMessageBoxAccepted;

            ScreenManager.AddScreen(confirmExitMessageBox, playerIndex);
        }
        /// <summary>
        /// Event handler for when the Quit Game menu entry is selected.
        /// </summary>
        void QuitGameMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            const string message = "Sie wollen uns alleine lassen, Commander?";

            MessageBoxScreen confirmQuitMessageBox = new MessageBoxScreen(message);

            confirmQuitMessageBox.Accepted += ConfirmQuitMessageBoxAccepted;

            ScreenManager.AddScreen(confirmQuitMessageBox, ControllingPlayer);
        }
        /// <summary>
        /// Event handler for when the Play Game menu entry is selected.
        /// </summary>
        void PlayMenuEntrySelected(object sender, PlayerIndexEventArgs e)
        {
            const string message = "PlayBack Functionality is not implemented yet.";

            MessageBoxScreen playMessageBox = new MessageBoxScreen(message);
            playMessageBox.Accepted += PlayMessageBoxAccepted;

            ScreenManager.AddScreen(playMessageBox, e.PlayerIndex);
           // LoadingScreen.Load(ScreenManager, true, e.PlayerIndex,
                              // new GameplayScreen());
        }
		/// <summary>
		/// Internal method for leaving the network session. This disposes the 
		/// session, removes the NetworkSessionComponent, and returns the user
		/// to the main menu screen.
		/// </summary>
		void LeaveSession ()
		{
			// Destroy this NetworkSessionComponent.
			Dispose ();

			// If we have a sessionEndMessage string explaining why the session has
			// ended (maybe this was a network disconnect, or perhaps the host kicked
			// us out?) create a message box to display this reason to the user.
			MessageBoxScreen messageBox;

			if (!string.IsNullOrEmpty (sessionEndMessage))
				messageBox = new MessageBoxScreen (sessionEndMessage, false);
			else
				messageBox = null;

			// At this point we want to return the user all the way to the main
			// menu screen. But what if they just joined a session? In that case
			// they went through this flow of screens:
			//
			//  - MainMenuScreen
			//  - CreateOrFindSessionsScreen
			//  - JoinSessionScreen (if joining, skipped if creating a new session)
			//  - LobbyScreeen
			//
			// If we have these previous screens on the history stack, and the user
			// backs out of the LobbyScreen, the right thing is just to pop off the
			// intermediate screens, returning them to the existing MainMenuScreen
			// instance without bothering to reload everything. But if the user is
			// in gameplay, or has been in gameplay and then returned to the lobby,
			// the screen stack will have been emptied.
			//
			// To do the right thing in both cases, we scan through the screen history
			// stack looking for a MainMenuScreen. If we find one, we pop any
			// subsequent screens so as to return back to it, while if we don't
			// find it, we just reset everything via the LoadingScreen.

			GameScreen[] screens = screenManager.GetScreens ();

			// Look for the MainMenuScreen.
			for (int i = 0; i < screens.Length; i++) {
				if (screens [i] is MainMenuScreen) {
					// If we found one, pop everything since then to return back to it.
					for (int j = i + 1; j < screens.Length; j++)
						screens [j].ExitScreen ();

					// Display the why-did-the-session-end message box.
					if (messageBox != null)
						screenManager.AddScreen (messageBox, null);

					return;
				}
			}

			// If we didn't find an existing MainMenuScreen, reload everything.
			// The why-did-the-session-end message box will be displayed after
			// the loading screen has completed.
			LoadingScreen.Load (screenManager, false, null, new BackgroundScreen (), 
							new MainMenuScreen (), 
							messageBox);
		}
        public override void HandleInput(InputState input)
        {
            //base.HandleInput(input);
            PlayerIndex junk;
            for (int i = 0; i < 4; i++)
            {
                //If the player hit A to join
                if (input.IsNewButtonPress(Buttons.A, (PlayerIndex)i, out junk) && !towersmash.players[i])
                {
                    towersmash.players[i] = true;
                }
                    //else if the player hit B to leave
                else if (input.IsNewButtonPress(Buttons.B, (PlayerIndex)i, out junk) && towersmash.players[i])
                {
                    towersmash.players[i] = false;
                }
                //If the player moves up the list
                if (towersmash.players[i] && input.IsNewButtonPress(Buttons.RightShoulder, (PlayerIndex)i, out junk))
                {
                    player_selection[i]++;
                    if (player_selection[i] > character_number)
                        player_selection[i] = 0;
                }
                //If the player moves down the list
                if (towersmash.players[i] && input.IsNewButtonPress(Buttons.LeftShoulder, (PlayerIndex)i, out junk))
                {
                    player_selection[i]--;
                    if (player_selection[i] < 0)
                        player_selection[i] = character_number;
                }
            }
            //If anyone wants to start the game
            if(input.IsNewButtonPress(Buttons.Start, null, out junk))
            {
                towersmash.updatenumberofplayers();
                if (towersmash.numberofplayers > 1)
                {
                    base.OnCancel(junk);
                    LoadingScreen.Load(ScreenManager, true, junk, new pvp(ScreenManager));
                }
                else
                {
                    MessageBoxScreen messagebox = new MessageBoxScreen("Must have at least 2 players ready for battle!");
                    ScreenManager.AddScreen(messagebox, null);
                }
            }
            //If anyone wants to go back to the main menu
            if (input.IsNewButtonPress(Buttons.Back, null, out junk))
            {
                base.OnCancel(junk);
            }

            //Quick hack for me on the keyboard
            if (input.IsNewKeyPress(Keys.Enter, null, out junk))
            {
                towersmash.numberofplayers = 2;
                towersmash.players[0] = true;
                towersmash.players[1] = true;
                towersmash.players[2] = false;
                towersmash.players[3] = false;
                towersmash.characters[0] = playertype.bashy;
                towersmash.characters[1] = playertype.shifty;
                base.OnCancel(junk);
                LoadingScreen.Load(ScreenManager, true, junk, new pvp(ScreenManager));
            }
        }
		/// <summary>
		/// Handle MenuSelect inputs by marking ourselves as ready.
		/// </summary>
		void HandleMenuSelect (LocalNetworkGamer gamer)
		{
			if (!gamer.IsReady) {
				gamer.IsReady = true;
			} else if (gamer.IsHost) {
				// The host has an option to force starting the game, even if not
				// everyone has marked themselves ready. If they press select twice
				// in a row, the first time marks the host ready, then the second
				// time we ask if they want to force start.
				MessageBoxScreen messageBox = new MessageBoxScreen (
						Resources.ConfirmForceStartGame);

				messageBox.Accepted += ConfirmStartGameMessageBoxAccepted;

				ScreenManager.AddScreen (messageBox, gamer.SignedInGamer.PlayerIndex);
			}
		}
		/// <summary>
		/// Public method called when the user wants to leave the network session.
		/// Displays a confirmation message box, then disposes the session, removes
		/// the NetworkSessionComponent, and returns them to the main menu screen.
		/// </summary>
		public static void LeaveSession (ScreenManager screenManager,
					PlayerIndex playerIndex)
		{
			NetworkSessionComponent self = FindSessionComponent (screenManager.Game);

			if (self != null) {
				// Display a message box to confirm the user really wants to leave.
				string message;

				if (self.networkSession.IsHost)
					message = Resources.ConfirmEndSession;
				else
					message = Resources.ConfirmLeaveSession;

				MessageBoxScreen confirmMessageBox = new MessageBoxScreen (message);

				// Hook the messge box ok event to actually leave the session.
				confirmMessageBox.Accepted += delegate
		{
			self.LeaveSession ();
		};

				screenManager.AddScreen (confirmMessageBox, playerIndex);
			}
		}
        /// <summary>
        /// LIVE networking is not supported in trial mode. Rather than just giving
        /// the user an error, this function asks if they want to purchase the full
        /// game, then takes them to Marketplace where they can do that. Once the
        /// Guide is active, the user can either make the purchase, or cancel it.
        /// When the Guide closes, ProfileSignInScreen.Update will notice that
        /// Guide.IsVisible has gone back to false, at which point it will check if
        /// the game is still in trial mode, and either exit the screen or proceed
        /// forward accordingly.
        /// </summary>
        void ShowMarketplace()
        {
            MessageBoxScreen confirmMarketplaceMessageBox =
                                    new MessageBoxScreen(Resources.ConfirmMarketplace);

            confirmMarketplaceMessageBox.Accepted += delegate
            {
                Guide.ShowMarketplace(ControllingPlayer.Value);
            };

            ScreenManager.AddScreen(confirmMarketplaceMessageBox, ControllingPlayer);
        }
		/// <summary>
		/// Event handler for when the asynchronous find network sessions
		/// operation has completed.
		/// </summary>
		void FindSessionsOperationCompleted (object sender,
					OperationCompletedEventArgs e)
		{
			GameScreen nextScreen;

			try			{
				// End the asynchronous find network sessions operation.
				AvailableNetworkSessionCollection availableSessions = 
						NetworkSession.EndFind (e.AsyncResult);

				if (availableSessions.Count == 0) {
					// If we didn't find any sessions, display an error.
					availableSessions.Dispose ();

					nextScreen = new MessageBoxScreen (Resources.NoSessionsFound, false);
				} else {
					// If we did find some sessions, proceed to the JoinSessionScreen.
					nextScreen = new JoinSessionScreen (availableSessions);
				}
			} catch (Exception exception) {
				nextScreen = new NetworkErrorScreen (exception);
			}

			ScreenManager.AddScreen (nextScreen, ControllingPlayer);
		}