Helper class represents a single entry in a MenuScreen. By default this just draws the entry text string, but it can be customized to display menu entries in different ways. This also provides an event that will be raised when the menu entry is selected.
Exemplo n.º 1
0
        /// <summary>
        /// Constructor fills in the menu contents.
        /// </summary>
        public MainMenuScreen()
            : base("Main Menu")
        {
            // Create our menu entries.
            MenuEntry playGameMenuEntry = new MenuEntry("Play Game");
               // MenuEntry optionsMenuEntry = new MenuEntry("Options");

            //lataaminen
            MenuEntry LoadMenuEntry = new MenuEntry("Load saved game");

            MenuEntry exitMenuEntry = new MenuEntry("Exit");

            // Hook up menu event handlers.
            playGameMenuEntry.Selected += PlayGameMenuEntrySelected;
               // optionsMenuEntry.Selected += OptionsMenuEntrySelected;

            LoadMenuEntry.Selected += LoadMenuEntrySelected;

            exitMenuEntry.Selected += OnCancel;

            // Add entries to the menu.
            MenuEntries.Add(playGameMenuEntry);
            //MenuEntries.Add(optionsMenuEntry);

            MenuEntries.Add(LoadMenuEntry);

            MenuEntries.Add(exitMenuEntry);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public PlayersMenuScreen()
            : base("Players", new Vector2(450, 510))
        {
            // Create our menu entries.
            player1MenuEntry = new MenuEntry(string.Empty);
            player2MenuEntry = new MenuEntry(string.Empty);
            player3MenuEntry = new MenuEntry(string.Empty);
            player4MenuEntry = new MenuEntry(string.Empty);

            SetMenuEntryText();

            MenuEntry backMenuEntry = new MenuEntry("Back");

            // Hook up menu event handlers.
            player1MenuEntry.Selected += Player1MenuEntrySelected;
            player2MenuEntry.Selected += Player2MenuEntrySelected;
            player3MenuEntry.Selected += Player3MenuEntrySelected;
            player4MenuEntry.Selected += Player4MenuEntrySelected;
            backMenuEntry.Selected += OnCancel;

            // Add entries to the menu.
            MenuEntries.Add(player1MenuEntry);
            MenuEntries.Add(player2MenuEntry);
            MenuEntries.Add(player3MenuEntry);
            MenuEntries.Add(player4MenuEntry);
            MenuEntries.Add(backMenuEntry);
        }
Exemplo n.º 3
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public ControlsMenuScreen()
     : base("Controls")
 {
     MenuEntry back = new MenuEntry("");
     back.Selected += OnCancel;
     MenuEntries.Add(back);
 }
        /// <summary>
        /// Constructor fills in the menu contents.
        /// </summary>
        public MainMenuScreen()
            : base("Main Menu")
        {
            // Create our menu entries.
            MenuEntry playGameMenuEntry = new MenuEntry("Play Game");
            //MenuEntry highScoresMenuEntry = new MenuEntry("High Scores");
            //MenuEntry nameEntryMenuEntry = new MenuEntry("Name Entry");
            MenuEntry controlsMenuEntry = new MenuEntry("Instructions");
            MenuEntry optionsMenuEntry = new MenuEntry("Options");
            MenuEntry exitMenuEntry = new MenuEntry("Back To Title Screen");
            MenuEntry returnToArcadeEntry = new MenuEntry("Return To Arcade");

            // Hook up menu event handlers.
            playGameMenuEntry.Selected += PlayGameMenuEntrySelected;
            //highScoresMenuEntry.Selected += HighScoresEntrySelected;
            //nameEntryMenuEntry.Selected += NameSel;
            controlsMenuEntry.Selected += ControlsMenuEntrySelected;
            optionsMenuEntry.Selected += OptionsMenuEntrySelected;
            exitMenuEntry.Selected += OnCancel;
            returnToArcadeEntry.Selected += ReturnToArcadeSelected;

            // Add entries to the menu.
            MenuEntries.Add(playGameMenuEntry);
            //MenuEntries.Add(highScoresMenuEntry);
            //MenuEntries.Add(nameEntryMenuEntry);
            MenuEntries.Add(controlsMenuEntry);
            MenuEntries.Add(optionsMenuEntry);
            MenuEntries.Add(exitMenuEntry);
            MenuEntries.Add(returnToArcadeEntry);

            #if !XBOX
            returnToArcadeEntry.Text = "Return To Windows";
            #endif
        }
        /// <summary>
        /// Конструктор.
        /// </summary>
        public OptionsMenuScreen()
            : base("Options")
        {
            // Создаем пункты входа меню.
            ungulateMenuEntry = new MenuEntry(string.Empty);
            languageMenuEntry = new MenuEntry(string.Empty);
            frobnicateMenuEntry = new MenuEntry(string.Empty);
            elfMenuEntry = new MenuEntry(string.Empty);

            SetMenuEntryText();

            MenuEntry back = new MenuEntry("Back");

            // Подключаем меню обработчика событий.
            ungulateMenuEntry.Selected += UngulateMenuEntrySelected;
            languageMenuEntry.Selected += LanguageMenuEntrySelected;
            frobnicateMenuEntry.Selected += FrobnicateMenuEntrySelected;
            elfMenuEntry.Selected += ElfMenuEntrySelected;
            back.Selected += OnCancel;

            // Добавляем запись в меню.
            MenuEntries.Add(ungulateMenuEntry);
            MenuEntries.Add(languageMenuEntry);
            MenuEntries.Add(frobnicateMenuEntry);
            MenuEntries.Add(elfMenuEntry);
            MenuEntries.Add(back);
        }
 public PressStartScreen()
     : base("")
 {
     MenuEntry startMenuEntry = new MenuEntry("Press Start to continue");
     startMenuEntry.Selected += StartMenuEntrySelected;
     MenuEntries.Add(startMenuEntry);
 }
Exemplo n.º 7
0
        public OptionsScreen()
            : base(String.Empty)
        {
            //Read the sound state from the text file and determine the value of soundOn
            OptionsScreen.soundOn = IsSoundOn();

            IsPopup = true;

            soundOptionMenuEntry = new MenuEntry("");
            creditsOptionMenuEntry =  new MenuEntry("CREDITS");
            backOptionMenuEntry = new MenuEntry("BACK");

            //Add methods to menu entry event handlers
            soundOptionMenuEntry.Selected += SoundOptionSelected;
            creditsOptionMenuEntry.Selected += CreditsOptionSelected;
            backOptionMenuEntry.Selected += BackOptionSelected;

            //Add menu entries to menu entries list
            MenuEntries.Add(soundOptionMenuEntry);
            MenuEntries.Add(creditsOptionMenuEntry);
            MenuEntries.Add(backOptionMenuEntry);

            //Write the sound state to the text file
            OptionsScreen.SaveSound();
        }
        /// <summary>
        /// Constructor fills in the menu contents.
        /// </summary>
        public HighScoreScreen()
            : base("High Scores")
        {
            //HighScores2.GoLoad();
            //HighScores.SaveHighScore();

            scoreEntries = new MenuEntry[HighScores2.loadedHighScoreData.Count];

            //HighScoreData hsd = HighScores.LoadHighScores();
            //HighScores2.loadedHighScoreData.PlayerName = new string[5];

            songNameEntry = new MenuEntry(NarlyGame.currentSong);
            songNameEntry.Selected += OnCancel;
               // MenuEntries.Add(songNameEntry);

            for (int i = 0; i < HighScores2.loadedHighScoreData.Count; i++)
            {
                //HighScores2.loadedHighScoreData.PlayerName[i] = new string('a',3);
                //HighScores2.loadedHighScoreData.PlayerName[i] = "pleasework";

                scoreEntries[i] = new MenuEntry(
                    HighScores2.loadedHighScoreData.PlayerName[i]
                    + " " +
                    HighScores2.loadedHighScoreData.Score[i]);
                scoreEntries[i].Selected += OnCancel;
                MenuEntries.Add(scoreEntries[i]);
            }
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        public OptionsMenuScreen()
            : base("Options")
        {
            // Create our menu entries.
            ungulateMenuEntry = new MenuEntry(string.Empty);
            languageMenuEntry = new MenuEntry(string.Empty);
            frobnicateMenuEntry = new MenuEntry(string.Empty);
            elfMenuEntry = new MenuEntry(string.Empty);

            SetMenuEntryText();

            MenuEntry back = new MenuEntry("Back");

            // Hook up menu event handlers.
            ungulateMenuEntry.Selected += UngulateMenuEntrySelected;
            languageMenuEntry.Selected += LanguageMenuEntrySelected;
            frobnicateMenuEntry.Selected += FrobnicateMenuEntrySelected;
            elfMenuEntry.Selected += ElfMenuEntrySelected;
            back.Selected += OnCancel;

            // Add entries to the menu.
            MenuEntries.Add(ungulateMenuEntry);
            MenuEntries.Add(languageMenuEntry);
            MenuEntries.Add(frobnicateMenuEntry);
            MenuEntries.Add(elfMenuEntry);
            MenuEntries.Add(back);
        }
Exemplo n.º 10
0
        /// <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 controls = new MenuEntry("Controls");
            MenuEntry quitGameMenuEntry = new MenuEntry("Quit Game");
            
            // Hook up menu event handlers.
            resumeGameMenuEntry.Selected += OnCancel;
            controls.Selected += new System.EventHandler<PlayerIndexEventArgs>(controls_Selected);
            controls.Selected += OnCancel;
            
            quitGameMenuEntry.Selected += QuitGameMenuEntrySelected;
            

            // Add entries to the menu.
            MenuEntries.Add(resumeGameMenuEntry);
            MenuEntries.Add(controls);
            MenuEntries.Add(quitGameMenuEntry);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public OptionsMenuScreen()
            : base("Options")
        {
            LoadBoardList();
            isFullScreen = GameStateManagementGame.FullScreen;

            board = new MenuEntry(string.Empty);
            fullScreen = new MenuEntry(string.Empty);
            soundsVolume = new MenuEntry(string.Empty);

            SetMenuEntryText();

            MenuEntry backMenuEntry = new MenuEntry("Back");

            // Hook up menu event handlers.

            board.Selected += BoardMenuEntrySelected;
            fullScreen.Selected += FullScreenSelected;
            soundsVolume.Selected += soundsVolumeSelected;

            backMenuEntry.Selected += OnSave;

            // Add entries to the menu.
            MenuEntries.Add(board);
            MenuEntries.Add(fullScreen);
            MenuEntries.Add(soundsVolume);
            MenuEntries.Add(backMenuEntry);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public OptionsMenuScreen()
            : base("Options")
        {
            // Create our menu entries.
            BloomMenuEntry = new MenuEntry(string.Empty);
            ToonMenuEntry = new MenuEntry(string.Empty);
            SFXMenuEntry = new MenuEntry(string.Empty);
            BGMMenuEntry = new MenuEntry(string.Empty);

            SetBloomEntryText();
            SetToonEntryText();
            SetSFXEntryText();
            SetBGMEntryText();

            MenuEntry back = new MenuEntry("Back");

            // Hook up menu event handlers.
            BloomMenuEntry.Selected +=BloomEntrySelected;
            ToonMenuEntry.Selected += ToonEntrySelected;
            SFXMenuEntry.Selected += SFXMenuEntrySelected;
            BGMMenuEntry.Selected += BGMMenuEntrySelected;
            back.Selected += OnCancel;

            // Add entries to the menu.
            MenuEntries.Add(BloomMenuEntry);
            MenuEntries.Add(ToonMenuEntry);
            MenuEntries.Add(SFXMenuEntry);
            MenuEntries.Add(BGMMenuEntry);
            MenuEntries.Add(back);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Loads content required by the screen, and initializes the displayed menu.
        /// </summary>
        public override void LoadContent()
        {
            safeArea = ScreenManager.SafeArea;
            // Create our menu entries.
            MenuEntry themeGameMenuEntry = new MenuEntry("Deck");
            MenuEntry returnMenuEntry = new MenuEntry("Return");

            // Hook up menu event handlers.
            themeGameMenuEntry.Selected += ThemeGameMenuEntrySelected;
            returnMenuEntry.Selected += OnCancel;

            // Add entries to the menu.
            MenuEntries.Add(themeGameMenuEntry);
            MenuEntries.Add(returnMenuEntry);

            themes.Add("Red", ScreenManager.Game.Content.Load<Texture2D>(
                @"Images\Cards\CardBack_Red"));
            themes.Add("Blue", ScreenManager.Game.Content.Load<Texture2D>(
                @"Images\Cards\CardBack_Blue"));
            background = ScreenManager.Game.Content.Load<Texture2D>(
                @"Images\UI\table");

            card = new AnimatedGameComponent(ScreenManager.Game,
                themes[MainMenuScreen.Theme])
            {
                CurrentPosition = new Vector2(safeArea.Center().X, safeArea.Center().Y - 50)
            };

            ScreenManager.Game.Components.Add(card);

            base.LoadContent();
        }
Exemplo n.º 14
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public EndScreen()
     : base("")
 {
     MenuEntry back = new MenuEntry("");
     back.Selected += BackToMenu;
     MenuEntries.Add(back);
 }
Exemplo n.º 15
0
        /// <summary>
        /// Constructs a menu screen listing the available network sessions.
        /// </summary>
        public JoinSessionScreen(AvailableNetworkSessionCollection availableSessions)
            : base(Resources.JoinSession)
        {
            this.availableSessions = availableSessions;

            foreach (AvailableNetworkSession availableSession in availableSessions)
            {
                // Create menu entries for each available session.
                MenuEntry menuEntry = new AvailableSessionMenuEntry(availableSession);
                menuEntry.Selected += AvailableSessionMenuEntrySelected;
                MenuEntries.Add(menuEntry);

                // Matchmaking can return up to 25 available sessions at a time, but
                // we don't have room to fit that many on the screen. In a perfect
                // world we should make the menu scroll if there are too many, but it
                // is easier to just not bother displaying more than we have room for.
                if (MenuEntries.Count >= MaxSearchResults)
                    break;
            }

            // Add the Back menu entry.
            MenuEntry backMenuEntry = new MenuEntry(Resources.Back);
            backMenuEntry.Selected += BackMenuEntrySelected;
            MenuEntries.Add(backMenuEntry);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public OptionsMenuScreen()
            : base("Options")
        {
            // Create our menu entries.
            soundMenuEntry = new MenuEntry(string.Empty);
            //languageMenuEntry = new MenuEntry(string.Empty);
            screenMenuEntry = new MenuEntry(string.Empty);
            //elfMenuEntry = new MenuEntry(string.Empty);
            setFullscreen = false;
            soundOnOff = true;
            //graphics = new GraphicsDeviceManager(this);
            SetMenuEntryText();

            MenuEntry back = new MenuEntry("Back");

            // Hook up menu event handlers.
            soundMenuEntry.Selected += soundMenuEntrySelected;
            //languageMenuEntry.Selected += LanguageMenuEntrySelected;
            screenMenuEntry.Selected += screenMenuEntrySelected;
               // elfMenuEntry.Selected += ElfMenuEntrySelected;
            back.Selected += OnCancel;

            // Add entries to the menu.
            MenuEntries.Add(soundMenuEntry);
               // MenuEntries.Add(languageMenuEntry);
            MenuEntries.Add(screenMenuEntry);
            //MenuEntries.Add(elfMenuEntry);
            MenuEntries.Add(back);
        }
Exemplo n.º 17
0
        public PauseScreen(GameScreen backgroundScreen, Player human, Player computer)
            : base(String.Empty)
        {
            IsPopup = true;

            this.backgroundScreen = backgroundScreen;

            // Create our menu entries.
            MenuEntry startGameMenuEntry = new MenuEntry("Return");
            MenuEntry exitMenuEntry = new MenuEntry("Quit Game");

            // Hook up menu event handlers.
            startGameMenuEntry.Selected += StartGameMenuEntrySelected;
            exitMenuEntry.Selected += OnCancel;

            // Add entries to the menu.
            MenuEntries.Add(startGameMenuEntry);
            MenuEntries.Add(exitMenuEntry);

            this.human = human;
            this.computer = computer;

            // Preserve the old state of the game
            prevHumanIsActive = this.human.Catapult.IsActive;
            prevCompuerIsActive = this.computer.Catapult.IsActive;

            // Pause the game logic progress
            this.human.Catapult.IsActive = false;
            this.computer.Catapult.IsActive = false;

            AudioManager.PauseResumeSounds(false);
        }
Exemplo n.º 18
0
        //string menuTitle = "Slides Menu";
        /// <summary>
        /// Constructor fills in the menu contents.
        /// </summary>
        public SlideMenuScreen()
            : base("Slides Menu")
        {
            slides = new List<SlideScreen>();
            currentSlideIndex = 0;
            SlideScreen firstSlide = new SlideScreen(this);
            slides.Add(firstSlide);
            _isPlayingSlideshow = false;
            _playWatch = new Stopwatch();
            // Create our menu entries.
            MenuEntry playSlideMenuEntry = new MenuEntry("Play Slides");
            MenuEntry exitMenuEntry = new MenuEntry("Exit");
            MenuEntry slidesMenuEntry = new MenuEntry("Slides");

            // Hook up menu event handlers
            playSlideMenuEntry.Selected += PlayMenuEntrySelected;

            exitMenuEntry.Selected += OnCancel;
            slidesMenuEntry.Selected += SlidesMenuEntrySelected;

            // Add entries to the menu.
            MenuEntries.Add(slidesMenuEntry);
            MenuEntries.Add(playSlideMenuEntry);
            MenuEntries.Add(exitMenuEntry);
        }
Exemplo n.º 19
0
 public controlsscreen()
     : base("Controls")
 {
     IsPopup = false;
     MenuEntry resume = new MenuEntry("Return to Main Menu");
     resume.Selected += OnCancel;
     MenuEntries.Add(resume);
 }
Exemplo n.º 20
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public OptionsMenuScreen()
            : base("Drag Tux using mouse to shoot him and free the birds! GO!")
        {
            MenuEntry exitMenuEntry = new MenuEntry("Exit Options");
            exitMenuEntry.Selected += exitOptions;

            MenuEntries.Add(exitMenuEntry);
        }
        //MenuEntry errorMessageEntry2;
        /// <summary>
        /// Constructor fills in the menu contents.
        /// </summary>
        public MediaplayerErrorScreen()
            : base("Media Player Error")
        {
            errorMessageEntry1 = new MenuEntry("");
            MenuEntries.Add(errorMessageEntry1);

            //errorMessageEntry2 = new MenuEntry("Please press the guide button and stop the media player to continue.");
            //MenuEntries.Add(errorMessageEntry2);
        }
Exemplo n.º 22
0
 /// <summary>
 /// Allows the screen to create the hit bounds for a particular menu entry.
 /// </summary>
 protected virtual Rectangle GetMenuEntryHitBounds(MenuEntry entry)
 {
     // the hit bounds are the entire width of the screen, and the height of the entry
     // with some additional padding above and below.
     return new Rectangle(
         0,
         (int)entry.Position.Y - menuEntryPadding,
         ScreenManager.GraphicsDevice.Viewport.Width,
         entry.GetHeight(this) + (menuEntryPadding * 2));
 }
Exemplo n.º 23
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public ControlsMenuScreen()
            : base("Controls")
        {
            MenuEntry back = new MenuEntry("Back");
            // Hook up menu event handlers.
            back.Selected += OnCancel;

            // Add entries to the menu.
            MenuEntries.Add(back);
        }
Exemplo n.º 24
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public WinnerScreen()
            : base("Winner!")
        {
            // Create our menu entries.
            MenuEntry quitGameMenuEntry = new MenuEntry("Press A to Continue");

            // Hook up menu event handlers.
            quitGameMenuEntry.Selected += QuitGameMenuEntrySelected;

            MenuEntries.Add(quitGameMenuEntry);
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        public CreditsMenuScreen()
            : base("Continue Game")
        {
            // Flag that there is no need for the game to transition
            // off when the pause menu is on top of it.
            IsPopup = true;

            MenuEntry backMenuEntry = new MenuEntry("Back");
            backMenuEntry.Selected += OnCancel;
            MenuEntries.Add(backMenuEntry);
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        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");
            invertYAxisMenuEntry = new MenuEntry("Invert Y-Axis: ?");
            rumbleMenuEntry = new MenuEntry("Rumble: ?");
            MenuEntry quitGameMenuEntry = new MenuEntry("Quit Game");

            if (NarlyGame.invertYAxis)
            {
                invertYAxisMenuEntry.Text = "Invert Y-Axis: On";
            }
            else
            {
                invertYAxisMenuEntry.Text = "Invert Y-Axis: Off";
            }

            if (NarlyGame.rumbleEnabled)
            {
                rumbleMenuEntry.Text = "Rumble: On";
            }
            else
            {
                rumbleMenuEntry.Text = "Rumble: Off";
            }
            lairdModeMenuEntry = new MenuEntry("Laird Mode: ?");
            if (NarlyGame.lairdMode)
            {
                lairdModeMenuEntry.Text = "Laird Mode: On";
            }
            else
            {
                lairdModeMenuEntry.Text = "Laird Mode: Off";
            }

            // Hook up menu event handlers.
            resumeGameMenuEntry.Selected += OnCancel;
            invertYAxisMenuEntry.Selected += ToggleYAxis;
            rumbleMenuEntry.Selected += ToggleRumble;
            lairdModeMenuEntry.Selected += ToggleLairdMode;
            quitGameMenuEntry.Selected += QuitGameMenuEntrySelected;

            // Add entries to the menu.
            MenuEntries.Add(resumeGameMenuEntry);
            MenuEntries.Add(invertYAxisMenuEntry);
            MenuEntries.Add(rumbleMenuEntry);
            MenuEntries.Add(lairdModeMenuEntry);
            MenuEntries.Add(quitGameMenuEntry);
        }
        public override void Activate(bool instancePreserved)
        {
            base.Activate(instancePreserved);

            //Detect if dissection has pins
            if (DissectionHasPins())
            {
                MenuEntry pinExplorerGameMenuEntry = new MenuEntry("Explore Pins");
                pinExplorerGameMenuEntry.Selected += StartExploringPinsMenuEntrySelected;
                MenuEntries.Insert(1, pinExplorerGameMenuEntry);
            }
        }
Exemplo n.º 28
0
        public MainMenu()
            : base(String.Empty)
        {
            MenuEntry startGameMenuEntry = new MenuEntry("Play");
            MenuEntry exitMenuEntry = new MenuEntry("Exit");

             startGameMenuEntry.Selected += StartGameMenuEntrySelected;
            exitMenuEntry.Selected += OnCancel;
            // Add entries to the menu.
            MenuEntries.Add(startGameMenuEntry);
            MenuEntries.Add(exitMenuEntry);
        }
Exemplo n.º 29
0
        /// <summary>
        /// Constructor fills in the menu contents.
        /// </summary>
        public MainMenuScreen()
            : base("Main Menu")
        {
            MenuEntry levelSelector = new MenuEntry("Play Game");
            MenuEntry optionsMenuEntry = new MenuEntry("Options");

            levelSelector.Selected += SelectLevelEntrySelected;
            optionsMenuEntry.Selected += OptionsMenuEntrySelected;

            MenuEntries.Add(levelSelector);
            MenuEntries.Add(optionsMenuEntry);
        }
        public GameOptionsMenuScreen()
            : base("Game Options")
        {
            resumeGameEntry = new MenuEntry("Resume Game");
            backToMenuEntry = new MenuEntry("Quit to Menu");

            resumeGameEntry.Selected += resumeGameEntrySelected;
            backToMenuEntry.Selected += backToMenuEntryEntrySelected;

            MenuEntries.Add(resumeGameEntry);
            MenuEntries.Add(backToMenuEntry);
            IsPopup = true;
        }
Exemplo n.º 31
0
        /// <summary>
        /// Responds to user input, changing the selected entry and accepting
        /// or cancelling the menu.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            // we cancel the current menu screen if the user presses the back button
            PlayerIndex player;

            if (input.IsNewButtonPress(Buttons.Back, ControllingPlayer, out player))
            {
                OnCancel(player);
            }

            if (input.IsMenuDown(ControllingPlayer))
            {
                if (selectedEntry < menuEntries.Count - 1)
                {
                    selectedEntry += 1;
                }
            }

            if (input.IsMenuUp(ControllingPlayer))
            {
                if (selectedEntry > 0)
                {
                    selectedEntry -= 1;
                }
            }

            if (input.IsMenuSelect(ControllingPlayer, out player))
            {
                menuEntries[selectedEntry].OnSelectEntry(player);
            }

            if (input.MouseGesture.HasFlag(MouseGestureType.LeftClick))
            {
                Point clickLocation = new Point((int)input.CurrentMousePosition.X, (int)input.CurrentMousePosition.Y);
                // iterate the entries to see if any were tapped
                for (int i = 0; i < menuEntries.Count; i++)
                {
                    MenuEntry menuEntry = menuEntries[i];

                    if (GetMenuEntryHitBounds(menuEntry).Contains(clickLocation))
                    {
                        // select the entry. since gestures are only available on Windows Phone,
                        // we can safely pass PlayerIndex.One to all entries since there is only
                        // one player on Windows Phone.
                        OnSelectEntry(i, PlayerIndex.One);
                    }
                }
            }

            if (input.MouseGesture.HasFlag(MouseGestureType.Move))
            {
                Point clickLocation = new Point((int)input.CurrentMousePosition.X, (int)input.CurrentMousePosition.Y);
                // iterate the entries to see if any were tapped
                for (int i = 0; i < menuEntries.Count; i++)
                {
                    MenuEntry menuEntry = menuEntries[i];

                    if (GetMenuEntryHitBounds(menuEntry).Contains(clickLocation))
                    {
                        // select the entry. since gestures are only available on Windows Phone,
                        // we can safely pass PlayerIndex.One to all entries since there is only
                        // one player on Windows Phone.
                        //OnSelectEntry(i, PlayerIndex.One);
                        selectedEntry = i;
                    }
                }
            }

            // look for any taps that occurred and select any entries that were tapped
            foreach (GestureSample gesture in input.Gestures)
            {
                if (gesture.GestureType == GestureType.Tap)
                {
                    // convert the position to a Point that we can test against a Rectangle
                    Point tapLocation = new Point((int)gesture.Position.X, (int)gesture.Position.Y);

                    // iterate the entries to see if any were tapped
                    for (int i = 0; i < menuEntries.Count; i++)
                    {
                        MenuEntry menuEntry = menuEntries[i];

                        if (GetMenuEntryHitBounds(menuEntry).Contains(tapLocation))
                        {
                            // select the entry. since gestures are only available on Windows Phone,
                            // we can safely pass PlayerIndex.One to all entries since there is only
                            // one player on Windows Phone.
                            OnSelectEntry(i, PlayerIndex.One);
                        }
                    }
                }
            }
        }
Exemplo n.º 32
0
        /// <summary>
        /// Responds to user input, changing the selected entry and accepting
        /// or cancelling the menu.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            // we cancel the current menu screen if the user presses the back button
            PlayerIndex player;

            if (input.IsNewButtonPress(Buttons.Back, ControllingPlayer, out player))
            {
                OnCancel(player);
            }
#if WINDOWS || MACOS || LINUX
            // Take care of Keyboard input
            if (input.IsMenuUp(ControllingPlayer))
            {
                selectedEntry--;

                if (selectedEntry < 0)
                {
                    selectedEntry = menuEntries.Count - 1;
                }
            }
            else if (input.IsMenuDown(ControllingPlayer))
            {
                selectedEntry++;

                if (selectedEntry >= menuEntries.Count)
                {
                    selectedEntry = 0;
                }
            }
            else if (input.IsNewKeyPress(Keys.Enter, ControllingPlayer, out player) ||
                     input.IsNewKeyPress(Keys.Space, ControllingPlayer, out player))
            {
                OnSelectEntry(selectedEntry, player);
            }


            MouseState state = Mouse.GetState();
            if (state.LeftButton == ButtonState.Released)
            {
                if (isMouseDown)
                {
                    isMouseDown = false;
                    // convert the position to a Point that we can test against a Rectangle
                    Point clickLocation = new Point(state.X, state.Y);

                    // iterate the entries to see if any were tapped
                    for (int i = 0; i < menuEntries.Count; i++)
                    {
                        MenuEntry menuEntry = menuEntries[i];

                        if (menuEntry.Destination.Contains(clickLocation))
                        {
                            // Select the entry. since gestures are only available on Windows Phone,
                            // we can safely pass PlayerIndex.One to all entries since there is only

                            // one player on Windows Phone.
                            OnSelectEntry(i, PlayerIndex.One);
                        }
                    }
                }
            }
            else if (state.LeftButton == ButtonState.Pressed)
            {
                isMouseDown = true;

                // convert the position to a Point that we can test against a Rectangle
                Point clickLocation = new Point(state.X, state.Y);

                // iterate the entries to see if any were tapped
                for (int i = 0; i < menuEntries.Count; i++)
                {
                    MenuEntry menuEntry = menuEntries[i];

                    if (menuEntry.Destination.Contains(clickLocation))
                    {
                        selectedEntry = i;
                    }
                }
            }
#elif XBOX
            // Take care of Gamepad input
            if (input.IsMenuUp(ControllingPlayer))
            {
                selectedEntry--;

                if (selectedEntry < 0)
                {
                    selectedEntry = menuEntries.Count - 1;
                }
            }
            else if (input.IsMenuDown(ControllingPlayer))
            {
                selectedEntry++;

                if (selectedEntry >= menuEntries.Count)
                {
                    selectedEntry = 0;
                }
            }
            else if (input.IsNewButtonPress(Buttons.A, ControllingPlayer, out player))
            {
                OnSelectEntry(selectedEntry, player);
            }
#elif WINDOWS_PHONE || IOS || ANDROID
            // look for any taps that occurred and select any entries that were tapped
            foreach (GestureSample gesture in input.Gestures)
            {
                if (gesture.GestureType == GestureType.Tap)
                {
                    // convert the position to a Point that we can test against a Rectangle
                    Point tapLocation = new Point((int)gesture.Position.X, (int)gesture.Position.Y);

                    // iterate the entries to see if any were tapped
                    for (int i = 0; i < menuEntries.Count; i++)
                    {
                        MenuEntry menuEntry = menuEntries[i];

                        if (menuEntry.Destination.Contains(tapLocation))
                        {
                            // Select the entry. since gestures are only available on Windows Phone,
                            // we can safely pass PlayerIndex.One to all entries since there is only
                            // one player on Windows Phone.
                            OnSelectEntry(i, PlayerIndex.One);
                        }
                    }
                }
            }
#endif
        }
Exemplo n.º 33
0
        /// <summary>
        /// Draws the menu.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            // make sure our entries are in the right place before we draw them
            UpdateMenuEntryLocations();

            GraphicsDevice graphics    = ScreenManager.GraphicsDevice;
            SpriteBatch    spriteBatch = ScreenManager.SpriteBatch;
            SpriteFont     font        = ScreenManager.Font;

            spriteBatch.Begin();

            // Draw each menu entry in turn.
            for (int i = 0; i < menuEntries.Count; i++)
            {
                MenuEntry menuEntry = menuEntries[i];

                bool isSelected = IsActive && (i == selectedEntry);

                menuEntry.Draw(this, isSelected, gameTime);
            }

            // Make the menu slide into place during transitions, using a
            // power curve to make things look more interesting (this makes
            // the movement slow down as it nears the end).

            if (menuTitle != null)
            {
                float transitionOffset = (float)Math.Pow(TransitionPosition, 2);

                // Draw the menu title centered on the screen
                Vector2 titlePosition = new Vector2(graphics.Viewport.Width / 2, _positionTitreHeight);
                Vector2 titleOrigin   = font.MeasureString(menuTitle) / 2;
                titleColor = titleColor * TransitionAlpha;
                float titleScale = 1f;

                titlePosition.Y -= transitionOffset * 100;

                spriteBatch.DrawString(font, menuTitle, titlePosition, titleColor, 0,
                                       titleOrigin, titleScale, SpriteEffects.None, 0);
            }
            else if (menuTitle == null && textureTitle != null)
            {
                float transitionOffset = (float)Math.Pow(TransitionPosition, 2);

                // Draw the menu title centered on the screen
                Vector2 titlePosition = new Vector2(graphics.Viewport.Width / 2, _positionTitreHeight);
                Vector2 titleOrigin   = new Vector2(textureTitle.Width / 2, textureTitle.Height / 2);
                titlePosition = new Vector2(titlePosition.X - titleOrigin.X, titlePosition.Y - titleOrigin.Y);
                titleColor    = titleColor * TransitionAlpha;

                titlePosition.Y -= transitionOffset * 100;

                spriteBatch.Draw(textureTitle, titlePosition, Color.White);
            }
            else
            {
                float transitionOffset = (float)Math.Pow(TransitionPosition, 2);
            }

            spriteBatch.End();
        }