/// <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); }
/// <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); } }
/// <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); } }
public InputManager() { if (instance == null) { loadKeyConfig(); laps = 0; clicked = null; } else throw new Exception("Do not construct InputManager. Use getInstance()"); }
/// <summary> /// Adds clickable to the menu. /// </summary> /// <param name="clickable"></param> public virtual void add(Clickable clickable) { clickable.setLayer(getLayer() + 1); items.Add(clickable); }
/// <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; }
/// <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; }