namespace SlatedGameToolkit.Framework.Input.Devices
{
    public delegate void MouseUpdate(bool leftDown, bool rightDown, bool middle, int x, int y, int scrollX, int scrollY);
    public static class Mouse
    {
        public static event MouseUpdate mouseUpdateEvent;
        public static bool LeftButtonPressed { get; private set; }
        public static bool RightButtonPressed { get; private set; }
        public static bool MiddleButtonPressed { get; private set; }
        public static int ScrollChangeX { get; private set; }
        public static int ScrollChangeY { get; private set; }
        public static int X { get; private set; }
        public static int Y{ get; private set; }

        internal static void OnMouseMoved(int x, int y) {
            X = x;
            Y = y;
        }

        internal static void OnLeftChange(bool down) {
            LeftButtonPressed = down;
            mouseUpdateEvent?.Invoke(down, RightButtonPressed, MiddleButtonPressed, X, Y, ScrollChangeX, ScrollChangeY);
        }

        internal static void OnRightChange(bool down) {
            RightButtonPressed = down;
            mouseUpdateEvent?.Invoke(LeftButtonPressed, down, MiddleButtonPressed, X, Y, ScrollChangeX, ScrollChangeY);
        }

        internal static void OnMiddleChange(bool down) {
            RightButtonPressed = down;
            mouseUpdateEvent?.Invoke(LeftButtonPressed, RightButtonPressed, down, X, Y, ScrollChangeX, ScrollChangeY);
        }

        internal static void OnScroll(int scrollX, int scrollY) {
            ScrollChangeX = scrollX;
            ScrollChangeY = scrollY;
            mouseUpdateEvent?.Invoke(LeftButtonPressed, RightButtonPressed, MiddleButtonPressed, X, Y, scrollX, scrollY);
        }
    }
}