public override void HandleInput(GameTime gameTime, InputState input) { base.HandleInput(gameTime, input); foreach (MenuEntry entry in initials) { if (input.MouseHoverIn(entry.ClickRectangle)) { selectedChar = Array.IndexOf(initials, entry); char ch = entry.Text.ToCharArray()[0]; ch = (char)((int)ch + input.RelativeScrollValue); entry.Text = ch.ToString(); } } PlayerIndex index; if (up.Evaluate(input, ControllingPlayer, out index)) { char ch = initials[selectedChar].Text.ToCharArray()[0]; ch += (char)1; initials[selectedChar].Text = ch.ToString(); } if (down.Evaluate(input, ControllingPlayer, out index)) { char ch = initials[selectedChar].Text.ToCharArray()[0]; ch -= (char)1; initials[selectedChar].Text = ch.ToString(); } char c = initials[selectedChar].Text.ToCharArray()[0]; int num = (int)c; if (num < 65) num = 90; if (num > 90) num = 65; c = (char)num; initials[selectedChar].Text = c.ToString(); if (right.Evaluate(input, ControllingPlayer, out index)) { selectedChar++; } if (left.Evaluate(input, ControllingPlayer, out index)) { selectedChar--; } selectedChar = (int)MathHelper.Clamp((float)selectedChar, 0f, 2f); if (!expired && accept.Evaluate(input, ControllingPlayer, out index)) { parent.Initials.Add(Initials); SetInitialsOf((PlayerIndex)ControllingPlayer, Initials); ExitScreen(); expired = true; } }
/// <summary> /// Responds to user input, changing the selected entry and accepting or cancelling /// the menu. /// </summary> public override void HandleInput(GameTime gameTime, InputState input) { #if WINDOWS foreach (MenuEntry entry in MenuEntries) { if (input.MouseHoverIn(entry.ClickRectangle) && selectedEntry != MenuEntries.IndexOf(entry)) { selectedEntry = MenuEntries.IndexOf(entry); if (!string.IsNullOrEmpty(selectionChangeSound)) SoundManager.Play(selectionChangeSound); } if (input.LeftButtonDownIn(entry.ClickRectangle) && prevMouseCheck()) { OnSelectEntry(selectedEntry, PlayerIndex.One); } } lastState = input.CurrentMouseState; #endif #if XBOX || WINDOWS PlayerIndex playerIndex; //Move to the previous menu entry? if (menuUp.Evaluate(input, ControllingPlayer, out playerIndex)) { selectedEntry--; if (!string.IsNullOrEmpty(selectionChangeSound)) SoundManager.Play(selectionChangeSound); if (selectedEntry < 0) { selectedEntry = menuEntries.Count - 1; } } //Move to the next menu entry? if (menuDown.Evaluate(input, ControllingPlayer, out playerIndex)) { selectedEntry++; if (!string.IsNullOrEmpty(selectionChangeSound)) SoundManager.Play(selectionChangeSound); if (selectedEntry >= menuEntries.Count) { selectedEntry = 0; } } if (menuSelect.Evaluate(input, ControllingPlayer, out playerIndex)) { OnSelectEntry(selectedEntry, playerIndex); if (!string.IsNullOrEmpty(selectionSound)) { SoundManager.Play(selectionSound); } } else if (menuCancel.Evaluate(input, ControllingPlayer, out playerIndex)) { OnCancel(playerIndex); if (!string.IsNullOrEmpty(cancelSound)) { SoundManager.Play(cancelSound); } } #endif }