Beispiel #1
0
        protected override void OnCancel(PlayerIndex playerIndex)
        {
            const string message = "Are you sure you want to exit this sample?";

            MessageBoxScreen confirmExitMessageBox = new MessageBoxScreen(message);

            confirmExitMessageBox.Accepted += ConfirmExitMessageBoxAccepted;

            ScreenManager.AddScreen(confirmExitMessageBox, playerIndex);
        }
Beispiel #2
0
        /// <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);
        }
Beispiel #3
0
        public override void HandleInput(GameTime gameTime, InputManager input)
        {
            PlayerIndex dummyPlayerIndex;
            if (input.IsMenuCancel(ControllingPlayer, out dummyPlayerIndex))
            {
                ExitScreen();
                return;
            }

            // handle selecting a save game
            if (input.IsMenuSelect(ControllingPlayer, out dummyPlayerIndex) &&
                (mSaveGameDescriptions != null))
            {
                switch (mMode)
                {
                    case SaveLoadScreenMode.Load:
                        if ((mCurrentSlot >= 0) &&
                            (mCurrentSlot < mSaveGameDescriptions.Count) &&
                            (mSaveGameDescriptions[mCurrentSlot] != null))
                        {
                            if (GameResources.GameDossier != null)
                            {
                                MessageBoxScreen messageBoxScreen = new MessageBoxScreen("Are you sure you want to load this game?");
                                messageBoxScreen.Accepted += ConfirmLoadMessageBoxAccepted;
                                ScreenManager.AddScreen(messageBoxScreen, ControllingPlayer);
                            }
                            else
                            {
                                ConfirmLoadMessageBoxAccepted(null, EventArgs.Empty);
                            }
                        }
                        break;

                    case SaveLoadScreenMode.Save:
                        if ((mCurrentSlot >= 0) &&
                            (mCurrentSlot <= mSaveGameDescriptions.Count))
                        {
                            if (mCurrentSlot == mSaveGameDescriptions.Count)
                            {
                                ConfirmSaveMessageBoxAccepted(null, EventArgs.Empty);
                            }
                            else
                            {
                                MessageBoxScreen messageBoxScreen = new MessageBoxScreen("Are you sure you want to overwrite this save game?");
                                messageBoxScreen.Accepted += ConfirmSaveMessageBoxAccepted;
                                ScreenManager.AddScreen(messageBoxScreen, ControllingPlayer);
                            }
                        }
                        break;
                }

            }
            // handle deletion
            else if (input.IsMenuDelete(ControllingPlayer) &&
                (mSaveGameDescriptions != null))
            {
                if ((mCurrentSlot >= 0) &&
                    (mCurrentSlot < mSaveGameDescriptions.Count) &&
                    (mSaveGameDescriptions[mCurrentSlot] != null))
                {
                    MessageBoxScreen messageBoxScreen = new MessageBoxScreen(
                        "Are you sure you want to delete this save game?");
                    messageBoxScreen.Accepted += ConfirmDeleteMessageBoxAccepted;
                    ScreenManager.AddScreen(messageBoxScreen, ControllingPlayer);
                }
            }
            // handle cursor-down
            else if (input.IsMenuDown(ControllingPlayer) &&
                (mSaveGameDescriptions != null))
            {
                int maximumSlot = mSaveGameDescriptions.Count;
                if (mMode == SaveLoadScreenMode.Save)
                {
                    maximumSlot = Math.Min(maximumSlot + 1,
                        MaximumSaveGameDescriptions);
                }
                if (mCurrentSlot < maximumSlot - 1)
                {
                    mCurrentSlot++;
                }
            }
            // handle cursor-up
            else if (input.IsMenuUp(ControllingPlayer) &&
                (mSaveGameDescriptions != null))
            {
                if (mCurrentSlot >= 1)
                {
                    mCurrentSlot--;
                }
            }
        }