Beispiel #1
0
        public bool QueueEvents(MouseEventArgs e)
        {
            if (EventsBuffer.Count >= MAX_EVENT_BUFFER_SIZE)
            {
                return(false);
            }

            EventsBuffer.Enqueue(e);
            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// All mouse events are not read immediately but stored in an events buffer, call <seealso cref="ReadInput"/> to read all mouse events
        /// </summary>
        public void ReadInput()
        {
            ClearReleasedState();
            while (EventsBuffer.Count > 0)
            {
                MouseEventArgs e = EventsBuffer.Dequeue();
                switch (e.Type)
                {
                case EventType.Down:
                    OnMouseDown(e.Buttons);
                    break;

                case EventType.Released:
                    OnMouseReleased(e.Buttons);
                    break;

                case EventType.Enter:
                    OnMouseEnter(e.Location);
                    break;

                case EventType.Leave:
                    OnMouseLeave(e.Location);
                    break;

                case EventType.Move:
                    OnMouseMove(e.Location);
                    break;

                case EventType.Wheel:
                    OnMouseWheel(e.Delta);
                    break;

                default:
                    GameException.Raise($"Event type is {e.Type}");
                    break;
                }
            }
        }
Beispiel #3
0
 public void ClearEventsBuffer()
 {
     EventsBuffer.Clear();
 }