Пример #1
0
        /// <summary>
        /// Adds the clickable to the menu, and adds height to it.
        /// </summary>
        /// <param name="clickable"></param>
        public override void add(Clickable clickable)
        {
            height += clickable.getHeight() + 2;

            if (clickable.getWidth() > width) width = clickable.getWidth();
            base.add(clickable);
        }
Пример #2
0
 /// <summary>
 /// Adds clickable array to the menu.
 /// </summary>
 /// <param name="clickable"></param>
 public virtual void add(Clickable[] clickable)
 {
     foreach(Clickable click in clickable)
     {
         click.setLayer(getLayer() + 1);
         items.Add(click);
     }
 }
Пример #3
0
        /// <summary>
        /// add an array of clickables to the menu, and adds height.
        /// </summary>
        /// <param name="clickable"></param>
        public override void add(Clickable[] clickable)
        {
            foreach (Clickable click in clickable)
            {
                height += click.getHeight() + 2;

                if (click.getWidth() > width) width = click.getWidth();
                base.add(clickable);
            }
        }
Пример #4
0
 public InputManager()
 {
     if (instance == null)
     {
         loadKeyConfig();
         laps = 0;
         clicked = null;
     }
     else throw new Exception("Do not construct InputManager. Use getInstance()");
 }
Пример #5
0
 /// <summary>
 /// Adds clickable to the menu.
 /// </summary>
 /// <param name="clickable"></param>
 public virtual void add(Clickable clickable)
 {
     clickable.setLayer(getLayer() + 1);
     items.Add(clickable);
 }
Пример #6
0
 /// <summary>
 /// Checks if the right mouse button is pressing the clickable.
 /// </summary>
 /// <param name="clickable"></param>
 /// <returns></returns>
 public bool isRightPressing(Clickable clickable)
 {
     if (Mouse.GetState().RightButton.Equals(ButtonState.Pressed))
     {
         if (Mouse.GetState().X >= clickable.getVector().X && Mouse.GetState().X <= clickable.getVector().X + clickable.getWidth())
         {
             if (Mouse.GetState().Y >= clickable.getVector().Y && Mouse.GetState().Y <= clickable.getVector().Y + clickable.getHeight())
             {
                 return true;
             }
         }
     }
     return false;
 }
Пример #7
0
        /// <summary>
        /// Checks if the clickable is being pressed.
        /// </summary>
        /// <param name="clickable"></param>
        /// <returns></returns>
        public bool isPressing(Clickable clickable)
        {
            bool set = (clicked == clickable);
            if (clicked != null)
            {
                if (clicked.getLayer() < clickable.getLayer()) return false;

                if (laps++ > 25)
                {
                    if (!set)
                        if (!isPressing(clicked))
                        {
                            clicked.tellPressed(false);
                            clicked = null;
                        }
                    laps = 0;
                }

            }

            bool pressed = Mouse.GetState().LeftButton.Equals(ButtonState.Pressed);

            if (clicked == null || set)
                if (pressed)
                {
                    if (set)
                    {
                        return true;
                    }

                    if (Mouse.GetState().X >= clickable.getVector().X && Mouse.GetState().X <= clickable.getVector().X + clickable.getWidth())
                    {
                        if (Mouse.GetState().Y >= clickable.getVector().Y && Mouse.GetState().Y <= clickable.getVector().Y + clickable.getHeight())
                        {
                            clicked = clickable;
                            clicked.tellPressed(true);
                            return true;
                        }
                    }
                }

            //temp fix
            if (set && textBoxFocused())
            {
                if (Mouse.GetState().X >= clickable.getVector().X && Mouse.GetState().X <= clickable.getVector().X + clickable.getWidth())
                {
                    if (Mouse.GetState().Y >= clickable.getVector().Y && Mouse.GetState().Y <= clickable.getVector().Y + clickable.getHeight())
                    {
                        clicked = clickable;
                        clicked.tellPressed(true);
                        return true;
                    }
                }
            }

            clickable.tellPressed(false);
            return false;
        }