/// <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.IsMenuLeft(ControllingPlayer)) { AudioEngine.SoundBank.PlayCue("sonMenuBoutton"); selectedEntry--; if (selectedEntry < 0) selectedEntry = menuEntries.Count - 1; } // Move to the next menu entry? if (input.IsMenuRight(ControllingPlayer)) { AudioEngine.SoundBank.PlayCue("sonMenuBoutton"); selectedEntry++; 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)) OnSelectEntry(selectedEntry, playerIndex); }
/// <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); } }
/// <summary> /// Responds to user input, changing the selected entry and accepting /// or cancelling the menu. /// </summary> public override void HandleInput(InputState input) { // 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. // Look up inputs for the active player profile. PlayerIndex PlayerIndex; int playerIndex = (int)ControllingPlayer.Value; lastKeyboardState = keyboardState; keyboardState = input.CurrentKeyboardStates[playerIndex]; if (input.IsMenuSelect(ControllingPlayer, out PlayerIndex)) { OnSelectEntry(selectedEntry, PlayerIndex); } else if (input.IsMenuCancel(ControllingPlayer, out PlayerIndex)) { OnCancel(PlayerIndex); } // Event handler for when the Sound Volume menu entry is selected. if (MenuEntries[selectedEntry] == soundVolumeMenuEntry && input.IsMenuLeft(ControllingPlayer) && soundVolume > 0) { MediaPlayer.Volume -= 0.0999f; soundVolume = (MediaPlayer.Volume * 10); SetMenuEntryText(); } if (MenuEntries[selectedEntry] == soundVolumeMenuEntry && input.IsMenuRight(ControllingPlayer) && soundVolume < 10) { MediaPlayer.Volume += 0.0999f; soundVolume = (MediaPlayer.Volume * 10); SetMenuEntryText(); } // Event handler for when the Sound FX Volume menu entry is selected. if (input.IsMenuLeft(ControllingPlayer) && MenuEntries[selectedEntry] == fxVolumeMenuEntry) { fxVolume--; SetMenuEntryText(); } if (input.IsMenuRight(ControllingPlayer) && MenuEntries[selectedEntry] == fxVolumeMenuEntry) { fxVolume++; SetMenuEntryText(); } base.HandleInput(input); }