/// <summary> /// Responds to user input, changing the selected entry and accepting /// or cancelling the menu. /// </summary> public override void HandleInput(InputHelper input, GameTime gameTime) { // Mouse on a menu item _hoverEntry = GetMenuEntryAt(input.Cursor); // Accept or cancel the menu? if (input.IsMenuSelect()) { if (GetPreviewCollision(input.Cursor)) { if (_menuEntries[_selectedEntry].Screen != null) { Framework.AddScreen(_menuEntries[_selectedEntry].Screen); Framework.AddScreen(new DescriptionBoxScreen((_menuEntries[_selectedEntry].Screen as PhysicsDemoScreen).GetDetails())); ContentWrapper.PlaySoundEffect("Click"); } } if (_hoverEntry != -1) { if (_selectedEntry == _hoverEntry) { if (_menuEntries[_selectedEntry].Screen != null) { Framework.AddScreen(_menuEntries[_selectedEntry].Screen); Framework.AddScreen(new DescriptionBoxScreen((_menuEntries[_selectedEntry].Screen as PhysicsDemoScreen).GetDetails())); ContentWrapper.PlaySoundEffect("Click"); } } else { _selectedEntry = _hoverEntry; } } } if (GetSliderCollision(input.Cursor)) { _scrollHover = true; if (input.IsMenuHold()) { _scrollLock = true; } } else { _scrollHover = false; } if (input.IsMenuRelease()) { _scrollLock = false; } if (_scrollLock) { _menuOffset = (int)Math.Round((MathHelper.Clamp(input.Cursor.Y, _menuStart, _menuStart + _menuSpacing * (NumEntries - 1)) - _menuStart) / _scrollSpacing); UpdateMenuPositions(); } if (input.IsScreenExit()) { Framework.ExitGame(); } if (input.IsMenuDown()) { _menuOffset++; UpdateMenuPositions(); } if (input.IsMenuUp()) { _menuOffset--; UpdateMenuPositions(); } }