123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105 |
- #region File Description
- //-----------------------------------------------------------------------------
- // PauseMenuScreen.cs
- //
- // Microsoft XNA Community Game Platform
- // Copyright (C) Microsoft Corporation. All rights reserved.
- //-----------------------------------------------------------------------------
- #endregion
- #region Using Statements
- #if IPHONE
- using Microsoft.Xna.Framework;
- #else
- using Microsoft.Xna.Framework;
- #endif
- #endregion
- namespace Microsoft.Xna.Samples.GameStateManagement
- {
- /// <summary>
- /// The pause menu comes up over the top of the game,
- /// giving the player options to resume or quit.
- /// </summary>
- class PauseMenuScreen : MenuScreen
- {
- #region Initialization
- /// <summary>
- /// Constructor.
- /// </summary>
- public PauseMenuScreen()
- : base("Paused")
- {
- // Flag that there is no need for the game to transition
- // off when the pause menu is on top of it.
- IsPopup = true;
- // Create our menu entries.
- MenuEntry resumeGameMenuEntry = new MenuEntry("Resume Game");
- MenuEntry quitGameMenuEntry = new MenuEntry("Quit Game");
-
- // Hook up menu event handlers.
- resumeGameMenuEntry.Selected += OnCancel;
- quitGameMenuEntry.Selected += QuitGameMenuEntrySelected;
- // Add entries to the menu.
- MenuEntries.Add(resumeGameMenuEntry);
- MenuEntries.Add(quitGameMenuEntry);
- }
- #endregion
- #region Handle Input
- /// <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 user selects ok on the "are you sure
- /// you want to quit" message box. This uses the loading screen to
- /// transition from the game back to the main menu screen.
- /// </summary>
- void ConfirmQuitMessageBoxAccepted(object sender, PlayerIndexEventArgs e)
- {
- LoadingScreen.Load(ScreenManager, false, null, new BackgroundScreen(),
- new MainMenuScreen());
- }
- #endregion
- #region Draw
- /// <summary>
- /// Draws the pause menu screen. This darkens down the gameplay screen
- /// that is underneath us, and then chains to the base MenuScreen.Draw.
- /// </summary>
- public override void Draw(GameTime gameTime)
- {
- ScreenManager.FadeBackBufferToBlack(TransitionAlpha * 2 / 3);
- base.Draw(gameTime);
- }
- #endregion
- }
- }
|