Exemplo n.º 1
0
        protected override void UpdateScreen(GameTime gameTime)
        {
            if (MenuState == MenuState.Normal)
            {
                if (_menuEntries.Count == 0)
                {
                    return;
                }

                if (_menuEntries[_selectedEntry].State != MenuEntry.EntryState.Highlight)
                {
                    _menuEntries[_selectedEntry].Highlight();
                }

                for (int i = 0; i < _menuEntries.Count; i++)
                {
                    _menuEntries[i].UpdateEntry(gameTime);
                    _menuEntries[_selectedEntry].AnimateHighlighted(gameTime);
                }

                if (MouseTexture != null)
                {
                    Vector2 mousePos = InputMap.GetMousePosition();
                    MouseBounds = new Rectangle((int)mousePos.X, (int)mousePos.Y, MouseTexture.Width, MouseTexture.Height);
                }
            }
            else if (MenuState == MenuState.ActivatingSubmenu)
            {
                ActivateSubmenu();
            }
            else
            {
                Restore();
            }
        }
Exemplo n.º 2
0
 private void DrawMouse(SpriteBatch spriteBatch, GameTime gameTime)
 {
     if (MouseTexture != null && _mouseVisible)
     {
         spriteBatch.Draw(MouseTexture, InputMap.GetMousePosition(), Color.White);
     }
 }
Exemplo n.º 3
0
        public void Initialize()
        {
            if (_isInitialized)
            {
                return;
            }

            InputMap       = new InputMap();
            _isInitialized = true;
        }
Exemplo n.º 4
0
        public override void HandleInput()
        {
            if (MenuState != MenuState.Normal || _transitioning)
            {
                return;
            }

            if (InputMap.NewActionPress(PreviousEntryActionName))
            {
                _menuEntries[_selectedEntry].Normal();
                _selectedEntry--;
                if (_selectedEntry < 0)
                {
                    _selectedEntry = _menuEntries.Count - 1;
                }
                _menuEntries[_selectedEntry].Highlight();
            }

            if (InputMap.NewActionPress(NextEntryActionName))
            {
                _menuEntries[_selectedEntry].Normal();
                _selectedEntry++;
                if (_selectedEntry >= _menuEntries.Count)
                {
                    _selectedEntry = 0;
                }
                _menuEntries[_selectedEntry].Highlight();
            }

            if (MouseTexture != null && _mouseVisible)
            {
                for (int i = _menuEntries.Count - 1; i >= 0; i--)
                {
                    if (_menuEntries[i].BoundingRectangle.Intersects(MouseBounds))
                    {
                        _menuEntries[_selectedEntry].Normal();
                        _selectedEntry = i;
                        _menuEntries[_selectedEntry].Highlight();
                    }
                }
            }

            if (InputMap.NewActionPress(SelectedEntryActionName))
            {
                _menuEntries[_selectedEntry].Select();
            }

            if (InputMap.NewActionPress(MenuCancelActionName))
            {
                MenuCancel();
            }
        }
Exemplo n.º 5
0
 protected InputDevice(InputMap <TDeviceKeyType> keyMap, Scene scene)
 {
     KeyMap = keyMap;
     scene.AddObject(this);
 }
Exemplo n.º 6
0
 public XNAKeyboardInputDevice(InputMap <Keys> inputMap, InputKey left, InputKey right, InputKey up, InputKey down, Scene scene) : base(inputMap, scene)
 {
     dPad = new DPad(this, left, right, up, down);
 }
Exemplo n.º 7
0
 public XNAMouseInputDevice(InputMap <MouseButton> inputMap, Scene scene) : base(inputMap, scene)
 {
 }
Exemplo n.º 8
0
        public void Initialize()
        {
            if (_isInitialized)
            {
                return;
            }

            InputMap = new InputMap();
            _isInitialized = true;
        }