/// <summary> /// Responds to user input, accepting or cancelling the message box. /// </summary> public override void HandleInput(InputState input) { PlayerIndex playerIndex; // 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 our Accepted and // Cancelled events, so they can tell which player triggered them. if (input.IsMenuSelect(ControllingPlayer, out playerIndex)) { // Raise the accepted event, then exit the message box. if (Accepted != null) { Accepted(this, new PlayerIndexEventArgs(playerIndex)); } ExitScreen(); } else if (input.IsMenuDown(ControllingPlayer)) { if (curLine < (totLines - 1)) { curLine++; } else { curLine = totLines - 1; } } else if (input.IsMenuUp(ControllingPlayer)) { if (curLine > 0) { curLine--; } else { curLine = 0; } } }
/// <summary> /// Responds to user input, changing the selected entry and accepting /// or cancelling the menu. /// </summary> public override void HandleInput(InputState input) { int usedToBe = selectedEntry; // Move to the previous menu entry? if (input.IsMenuUp(ControllingPlayer)) { evdEnGlobals.soundBank.PlayCue("menu"); selectedEntry--; if (selectedEntry < 0) { selectedEntry = menuEntries.Count - 1; } // here we do only one attempt to skip read-only item while (menuEntries[selectedEntry].ReadOnly && (selectedEntry != usedToBe)) { selectedEntry--; if (selectedEntry < 0) { selectedEntry = menuEntries.Count - 1; } } OnActiveMenuItemChanged(ControllingPlayer.HasValue ? ControllingPlayer.Value : PlayerIndex.One); } // Move to the next menu entry? if (input.IsMenuDown(ControllingPlayer)) { evdEnGlobals.soundBank.PlayCue("menu"); selectedEntry++; if (selectedEntry >= menuEntries.Count) { selectedEntry = 0; } // here we do only one attempt to skip read-only item while (menuEntries[selectedEntry].ReadOnly && (selectedEntry != usedToBe)) { selectedEntry++; if (selectedEntry >= menuEntries.Count) { selectedEntry = 0; } } OnActiveMenuItemChanged(ControllingPlayer.HasValue ? ControllingPlayer.Value : PlayerIndex.One); } // 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.IsMenuLeft(ControllingPlayer, out playerIndex)) { evdEnGlobals.soundBank.PlayCue("menu"); OnLeftEntry(selectedEntry, playerIndex); } else if (input.IsMenuRight(ControllingPlayer, out playerIndex)) { evdEnGlobals.soundBank.PlayCue("menu"); OnRightEntry(selectedEntry, playerIndex); } else if (input.IsMenuSelect(ControllingPlayer, out playerIndex)) { evdEnGlobals.soundBank.PlayCue("menu"); OnSelectEntry(selectedEntry, playerIndex); } else if (input.IsMenuCancel(ControllingPlayer, out playerIndex)) { evdEnGlobals.soundBank.PlayCue("menu"); OnCancel(playerIndex); } }