示例#1
0
 private void OnMouseComponentScroll(object sender, MouseScrollEventArgs e)
 {
     foreach (var module in InputModules)
     {
         var input = module as IInputModule;
         if (input != null)
         {
             if (input.MouseScroll(GameTime, e))
                 break;
         }
     }
 }
示例#2
0
 public virtual bool MouseScroll(GameTime gameTime, MouseScrollEventArgs e)
 {
     return false;
 }
示例#3
0
        /// <summary>
        /// Processes a change between two states.
        /// </summary>
        /// <param name="newState">The new state.</param>
        /// <param name="oldState">The old state.</param>
        private void Process(MouseState newState, MouseState oldState)
        {
            // Movement.
            if ((newState.X != oldState.X) || (newState.Y != oldState.Y))
            {
                var args = new MouseMoveEventArgs(newState.X, newState.Y, (newState.X - oldState.X), (newState.Y - oldState.Y));
                if (Move != null)
                {
                    Move(this, args);
                }
            }

            // Scrolling.
            if (newState.ScrollWheelValue != oldState.ScrollWheelValue)
            {
                var args = new MouseScrollEventArgs(newState.X, newState.Y, newState.ScrollWheelValue, (newState.ScrollWheelValue - oldState.ScrollWheelValue));
                if (Scroll != null)
                {
                    Scroll(this, args);
                }
            }

            // A bit of code duplication here, shame XNA doesn't expose button state through an enumeration...

            // Left button.
            if (newState.LeftButton != oldState.LeftButton)
            {
                var args = new MouseButtonEventArgs(newState.X, newState.Y, MouseButton.Left, (newState.LeftButton == ButtonState.Pressed));
                if (args.IsPressed)
                {
                    if (ButtonDown != null)
                    {
                        ButtonDown(this, args);
                    }
                }
                else
                {
                    if (ButtonUp != null)
                    {
                        ButtonUp(this, args);
                    }
                }
            }

            // Right button.
            if (newState.RightButton != oldState.RightButton)
            {
                var args = new MouseButtonEventArgs(newState.X, newState.Y, MouseButton.Right, (newState.RightButton == ButtonState.Pressed));
                if (args.IsPressed)
                {
                    if (ButtonDown != null)
                    {
                        ButtonDown(this, args);
                    }
                }
                else
                {
                    if (ButtonUp != null)
                    {
                        ButtonUp(this, args);
                    }
                }
            }

            // Middle button.
            if (newState.MiddleButton != oldState.MiddleButton)
            {
                var args = new MouseButtonEventArgs(newState.X, newState.Y, MouseButton.Middle, (newState.MiddleButton == ButtonState.Pressed));
                if (args.IsPressed)
                {
                    if (ButtonDown != null)
                    {
                        ButtonDown(this, args);
                    }
                }
                else
                {
                    if (ButtonUp != null)
                    {
                        ButtonUp(this, args);
                    }
                }
            }
        }
示例#4
0
 public override bool MouseScroll(GameTime gameTime, MouseScrollEventArgs e)
 {
     var selected = Game.Client.HotbarSelection;
     selected += e.DeltaValue > 0 ? -1 : 1;
     if (selected < 0)
         selected = 8;
     if (selected > 8)
         selected = 0;
     Game.Client.HotbarSelection = selected;
     return true;
 }
示例#5
0
        /// <summary>
        /// Processes a change between two states.
        /// </summary>
        /// <param name="newState">The new state.</param>
        /// <param name="oldState">The old state.</param>
        private void Process(MouseState newState, MouseState oldState)
        {
            // Movement.
            if ((newState.X != oldState.X) || (newState.Y != oldState.Y))
            {
                var args = new MouseMoveEventArgs(newState.X, newState.Y, (newState.X - oldState.X), (newState.Y - oldState.Y));
                if (Move != null)
                    Move(this, args);
            }

            // Scrolling.
            if (newState.ScrollWheelValue != oldState.ScrollWheelValue)
            {
                var args = new MouseScrollEventArgs(newState.X, newState.Y, newState.ScrollWheelValue, (newState.ScrollWheelValue - oldState.ScrollWheelValue));
                if (Scroll != null)
                    Scroll(this, args);
            }

            // A bit of code duplication here, shame XNA doesn't expose button state through an enumeration...

            // Left button.
            if (newState.LeftButton != oldState.LeftButton)
            {
                var args = new MouseButtonEventArgs(newState.X, newState.Y, MouseButton.Left, (newState.LeftButton == ButtonState.Pressed));
                if (args.IsPressed)
                {
                    if (ButtonDown != null)
                        ButtonDown(this, args);
                }
                else
                {
                    if (ButtonUp != null)
                        ButtonUp(this, args);
                }
            }

            // Right button.
            if (newState.RightButton != oldState.RightButton)
            {
                var args = new MouseButtonEventArgs(newState.X, newState.Y, MouseButton.Right, (newState.RightButton == ButtonState.Pressed));
                if (args.IsPressed)
                {
                    if (ButtonDown != null)
                        ButtonDown(this, args);
                }
                else
                {
                    if (ButtonUp != null)
                        ButtonUp(this, args);
                }
            }

            // Middle button.
            if (newState.MiddleButton != oldState.MiddleButton)
            {
                var args = new MouseButtonEventArgs(newState.X, newState.Y, MouseButton.Middle, (newState.MiddleButton == ButtonState.Pressed));
                if (args.IsPressed)
                {
                    if (ButtonDown != null)
                        ButtonDown(this, args);
                }
                else
                {
                    if (ButtonUp != null)
                        ButtonUp(this, args);
                }
            }
        }
示例#6
0
        /// <summary>
        ///  Processes a change between two states.
        /// </summary>
        /// <param name="newState">The new state.</param>
        /// <param name="oldState">The old state.</param>
        private void Process(MouseState newState, MouseState oldState)
        {
            // Movement.
            if (newState.X != oldState.X || newState.Y != oldState.Y)
            {
                var args = new MouseMoveEventArgs(newState.X, newState.Y, newState.X - oldState.X,
                                                  newState.Y - oldState.Y);
                Move?.Invoke(this, args);
            }

            // Scrolling.
            if (newState.ScrollWheelValue != oldState.ScrollWheelValue)
            {
                var args = new MouseScrollEventArgs(newState.X, newState.Y, newState.ScrollWheelValue,
                                                    newState.ScrollWheelValue - oldState.ScrollWheelValue);
                Scroll?.Invoke(this, args);
            }

            // A bit of code duplication here, shame XNA doesn't expose button state through an enumeration...

            // Left button.
            if (newState.LeftButton != oldState.LeftButton)
            {
                var args = new MouseButtonEventArgs(newState.X, newState.Y, MouseButton.Left,
                                                    newState.LeftButton == ButtonState.Pressed);
                if (args.IsPressed)
                {
                    ButtonDown?.Invoke(this, args);
                }
                else
                {
                    ButtonUp?.Invoke(this, args);
                }
            }

            // Right button.
            if (newState.RightButton != oldState.RightButton)
            {
                var args = new MouseButtonEventArgs(newState.X, newState.Y, MouseButton.Right,
                                                    newState.RightButton == ButtonState.Pressed);
                if (args.IsPressed)
                {
                    ButtonDown?.Invoke(this, args);
                }
                else
                {
                    ButtonUp?.Invoke(this, args);
                }
            }

            // Middle button.
            if (newState.MiddleButton != oldState.MiddleButton)
            {
                var args = new MouseButtonEventArgs(newState.X, newState.Y, MouseButton.Middle,
                                                    newState.MiddleButton == ButtonState.Pressed);
                if (args.IsPressed)
                {
                    ButtonDown?.Invoke(this, args);
                }
                else
                {
                    ButtonUp?.Invoke(this, args);
                }
            }
        }