Exemplo n.º 1
0
        public override void HandleInput(InputState input)
        {
            base.HandleInput(input);

            PlayerIndex player;
            if(input.IsNewButtonPress(Buttons.Back, ControllingPlayer, out player))
            {
                OnCancel(player);
            }

#if WINDOWS || MACOS || LINUX
            if (input.IsMenuUp(ControllingPlayer))
            {
                selectedEntry--;

                if (selectedEntry < 0)
                    selectedEntry = menuEntries.Count - 1;
            }
            else if (input.IsMenuDown(ControllingPlayer))
            {
                selectedEntry++;

                if (selectedEntry >= menuEntries.Count)
                    selectedEntry = 0;
            }
            else if(input.IsNewKeyPress(Keys.Enter, ControllingPlayer, out player) || input.IsNewKeyPress(Keys.Space, ControllingPlayer, out player))
            {
                OnSelectEntry(selectedEntry, player);
            }

            MouseState state = Mouse.GetState();
            if (state.LeftButton == ButtonState.Released)
            {
                if (isMouseDown)
                {
                    isMouseDown = false;

                    Point clickLocation = new Point(state.X, state.Y);

                    for (int i = 0; i < menuEntries.Count; i++)
                    {
                        MenuEntry menuEntry = menuEntries[i];

                        if (menuEntry.Destination.Contains(clickLocation))
                        {
                            OnSelectEntry(i, PlayerIndex.One);
                        }
                    }
                }
            }
            else if(state.LeftButton == ButtonState.Pressed)
            {
                isMouseDown = true;

                Point clickLocation = new Point(state.X, state.Y);

                for(int i=0; i<menuEntries.Count; i++)
                {
                    MenuEntry menuEntry = menuEntries[i];

                    if (menuEntry.Destination.Contains(clickLocation))
                        selectedEntry = 1;
                }
            }
            if (input.IsMenuUp(ControllingPlayer))
            {
                selectedEntry--;

                if (selectedEntry < 0)
                    selectedEntry = menuEntries.Count - 1;
            }
            else if (input.IsMenuDown(ControllingPlayer))
            {
                selectedEntry++;

                if (selectedEntry >= menuEntries.Count)
                    selectedEntry = 0;
            }
            else if (input.IsNewButtonPress(Buttons.A, ControllingPlayer, out player))
                OnSelectEntry(selectedEntry, player);
        }
Exemplo n.º 2
0
 protected virtual Rectangle GetMenuEntryHitBounds(MenuEntry entry)
 {
     return new Rectangle(0, (int)entry.Destination.Y - menuEntryPadding,
         ScreenManager.GraphicsDevice.Viewport.Width,
         entry.GetHeight(this) + (menuEntryPadding * 2));
 }