using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Forms;
using HumanLikeBattleRobots.Logic;

namespace HumanLikeBattleRobots.Control
{
    static class Mouse
    {
        private static Vec2f position = new Vec2f(0,0);
        private static Dictionary<MouseButtons, bool> buttonDown = new Dictionary<MouseButtons, bool>();

        public delegate void OnMouseHandler(Vec2f position, Dictionary<MouseButtons, bool> buttonDown);
        public static OnMouseHandler OnMouse;


        public static void Initialize()
        {
            foreach (MouseButtons button in Enum.GetValues(typeof(MouseButtons)))
                if (!buttonDown.ContainsKey(button))
                    buttonDown.Add(button, false);
        }

        public static Vec2f Position { get { return position; } }

        public static void Move(int X, int Y)
        {
            //здесь должно быть некое преобразование... или не должно быть
            position.X = X;
            position.Y = Y;
            // добавить отображение курсора по-любому
            if (OnMouse != null)
                OnMouse(Position, buttonDown);
        }

        public static void SetButtonDown(MouseButtons button)
        {
            buttonDown[button] = true;
            if (OnMouse != null)
                OnMouse(Position, buttonDown);
        }

        public static void SetButtonUp(MouseButtons button)
        {
            buttonDown[button] = false;
            if (OnMouse != null)
                OnMouse(Position, buttonDown);
        }
    }
}
