private void CheckMouseEvent(List <Sprite> sprites, Controler controler) { MousePointer mousePointer = controler.MousePointer; if (this.HitBox.Intersects(new Rectangle((int)controler.MousePointer.InWindowPosition.X, (int)controler.MousePointer.InWindowPosition.Y, 1, 1)) && !this.IsHUD) { if (!isOver) { OnMouseOver(sprites, controler); } isOver = true; if ((controler.MousePointer.currentMouseState.LeftButton == ButtonState.Pressed && controler.MousePointer.prevMouseState.LeftButton == ButtonState.Released) || isClicked) { isClicked = true; if (controler.MousePointer.currentMouseState.LeftButton == ButtonState.Released) { Vector2 ClickPosition = new Vector2(mousePointer.Position.X - Position.X - origin.X / 2, mousePointer.Position.Y - Position.Y - origin.Y / 2); OnMouseClick(sprites, controler, ClickPosition); } } if (controler.MousePointer.currentMouseState.LeftButton == ButtonState.Released) { isClicked = false; } } else if (this.IsHUD && controler.MousePointer.HitBox.Intersects(this.HitBox)) { if (!isOver) { OnMouseOver(sprites, controler); } isOver = true; if ((controler.MousePointer.currentMouseState.LeftButton == ButtonState.Pressed && controler.MousePointer.prevMouseState.LeftButton == ButtonState.Released) || isClicked) { isClicked = true; if (controler.MousePointer.currentMouseState.LeftButton == ButtonState.Released) { Vector2 ClickPosition = new Vector2(mousePointer.InWindowPosition.X - Position.X - origin.X / 2, mousePointer.InWindowPosition.Y - Position.Y - origin.Y / 2); OnMouseClick(sprites, controler, ClickPosition); } } if (controler.MousePointer.currentMouseState.LeftButton == ButtonState.Released) { isClicked = false; } } else if (controler.MousePointer.currentMouseState.LeftButton == ButtonState.Released) { if (isOver) { isClicked = false; OnMouseLeave(sprites, controler); isOver = false; } } }
public void OnMouseClick(object sender, MousePointer mousePointer, Controler controler, Vector2 clickPosition) { if (IsFocused) { SetCursor(clickPosition); return; } Focus(controler); }
public Player(Texture2D texture, Texture2D playerFeetTexture, MousePointer mousepointer, string name, TextureManager textureManager) : base(texture) { this.textureManager = textureManager; ChangeName(name); Direction = new Vector2(0, 0); playerFeet = new PlayerFeet(playerFeetTexture); playerFeet.layerDepth = .9f; this.mousePointer = mousepointer; origin = new Vector2(texture.Width / 2, texture.Height / 2); Velocity = 5; layerDepth = .9f; scale = .5f; }
private void OnMouseLeft(object sender, MousePointer mousePointer, Controler controler) { mousePointer.SetCursorIcon(MousePointerType.Default); }
private void OnMouseOver(object sender, MousePointer mousePointer, Controler controler) { mousePointer.SetCursorIcon(MousePointerType.Text); }
private void OnMouseClick(object sender, MousePointer mousePointer, Controler controler, Vector2 clickPosition) { }
private void OnMouseLeft(object sender, MousePointer mousePointer, Controler controler) { isMouseOver = false; controler.MousePointer.SourceRectangle = new Rectangle(0, 0, 75, 75); }
private void OnMouseOver(object sender, MousePointer mousePointer, Controler controler) { isMouseOver = true; controler.MousePointer.SourceRectangle = new Rectangle(300, 0, 75, 75); }