Beispiel #1
0
        /// <summary>
        /// Responds to user input, changing the selected entry and accepting
        /// or cancelling the menu.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            // Move to the left menu entry?
            if (input.IsMenuLeft(ControllingPlayer))
            {
                AudioEngine.SoundBank.PlayCue("sonMenuBoutton");
                if (selectedEntry == 0)
                {
                    page = maxpage;
                    selectedEntry = levels.Count - 1;
                }
                else if (selectedEntry == (page * 8) && page > 0)
                {
                    page--;
                    selectedEntry--;
                }
                else if (selectedEntry > 0)
                    selectedEntry--;
            }

            // Move to the right menu entry?
            if (input.IsMenuRight(ControllingPlayer))
            {
                AudioEngine.SoundBank.PlayCue("sonMenuBoutton");
                if (selectedEntry == (page + 1) * 8 - 1 && selectedEntry < (levels.Count - 2))
                {
                    page++;
                    selectedEntry++;
                }
                else if (selectedEntry == levels.Count - 1)
                {
                    page = 0;
                    selectedEntry = 0;
                }
                else if (selectedEntry < levels.Count - 1)
                    selectedEntry++;
            }

            // Move to the up menu entry?
            if (input.IsMenuUp(ControllingPlayer))
            {
                AudioEngine.SoundBank.PlayCue("sonMenuBoutton");
                if (selectedEntry == levels.Count - 1)
                    selectedEntry--;
                else if (page == 0 && selectedEntry < 4)
                {
                    page = maxpage;
                    selectedEntry = levels.Count - 1;
                }
                else if (selectedEntry > (page * 8) + 3)
                    selectedEntry -= 4;
                else if (page > 0 && selectedEntry <= (page * 8) + 3)
                {
                    selectedEntry -= 4;
                    page--;
                }
            }

            // Move to the down menu entry?
            if (input.IsMenuDown(ControllingPlayer))
            {
                AudioEngine.SoundBank.PlayCue("sonMenuBoutton");
                if (selectedEntry == levels.Count - 1)
                {
                    page = 0;
                    selectedEntry = 0;
                }
                else if (selectedEntry > (page * 8) + 3 && page < maxpage)
                {
                    page++;
                    selectedEntry += 4;
                }
                else if (selectedEntry <= (page * 8) + 3)
                    selectedEntry += 4;
                else if (selectedEntry < levels.Count - 1)
                    selectedEntry = levels.Count - 1;
            }

            // Accept or cancel the menu? We pass in our ControllingPlayer, which may
            // either be null (to accept input from any player) or a specific index.
            // If we pass a null controlling player, the InputState helper returns to
            // us which player actually provided the input. We pass that through to
            // OnSelectEntry and OnCancel, so they can tell which player triggered them.
            PlayerIndex playerIndex;

            if (input.IsMenuCancel(ControllingPlayer, out playerIndex))
                OnSelectEntry(levels.Count - 1, playerIndex);

            if (input.IsMenuSelect(ControllingPlayer, out playerIndex))
            {
                AudioEngine.SoundBank.PlayCue("menuBouge");
                OnSelectEntry(selectedEntry, playerIndex);
            }
        }
Beispiel #2
0
        /// <summary>
        /// Responds to user input, changing the selected entry and accepting
        /// or cancelling the menu.
        /// </summary>
        public override void HandleInput(InputState input)
        {
            // Move to the previous menu entry?
            if (input.IsMenuUp(ControllingPlayer))
            {
                selectedEntry--;
                AudioEngine.SoundBank.PlayCue("sonMenuBoutton");

                if (selectedEntry < 0)
                    selectedEntry = menuEntries.Count - 1;
            }

            // Move to the next menu entry?
            if (input.IsMenuDown(ControllingPlayer))
            {
                selectedEntry++;
                AudioEngine.SoundBank.PlayCue("sonMenuBoutton");
                if (selectedEntry >= menuEntries.Count)
                    selectedEntry = 0;
            }

            // Accept or cancel the menu? We pass in our ControllingPlayer, which may
            // either be null (to accept input from any player) or a specific index.
            // If we pass a null controlling player, the InputState helper returns to
            // us which player actually provided the input. We pass that through to
            // OnSelectEntry and OnCancel, so they can tell which player triggered them.
            PlayerIndex playerIndex;

            if (input.IsMenuSelect(ControllingPlayer, out playerIndex))
            {
                AudioEngine.SoundBank.PlayCue("menuBouge");
                OnSelectEntry(selectedEntry, playerIndex);
            }
            else if (input.IsMenuCancel(ControllingPlayer, out playerIndex))
            {
                AudioEngine.SoundBank.PlayCue("menuBouge");
                OnCancel(playerIndex);
            }
        }