public override void Draw(GameTime gameTime, Point mousePos) { Text.Draw(Font, textPoint.ToVector2(), 1, HitBox.Contains(mousePos)); base.Draw(gameTime, mousePos); }
protected internal override void OnMouseUp(Point _hitPoint, int _iButton) { if (_iButton == Screen.Game.InputMgr.PrimaryMouseButton) { if (mNotebook.DraggedTab == this) { mNotebook.DropTab(); DragOffset = 0; } if (_hitPoint.Y < mNotebook.LayoutRect.Y + mNotebook.Style.TabHeight /* && IsInTab */) { if (_hitPoint.X > LayoutRect.X && _hitPoint.X < LayoutRect.Right) { OnActivateUp(); } } } else if (_iButton == 1) { if (IsClosable && HitBox.Contains(_hitPoint)) { Close(); Screen.Focus(mNotebook); if (mNotebook.TabClosedHandler != null) { mNotebook.TabClosedHandler(this); } } } }
public override Widget HitTest(Point _point) { // The splitter itself if (HitBox.Contains(_point)) { return(this); } // The panes if (mFirstPane != null && mbDisplayFirstPane) { Widget widget = mFirstPane.HitTest(_point); if (widget != null) { return(widget); } } if (mSecondPane != null && mbDisplaySecondPane) { Widget widget = mSecondPane.HitTest(_point); if (widget != null) { return(widget); } } return(null); }
public bool isClicked(MouseState ms, MouseState prevState) { if (HitBox.Contains(ms.Position) && ms.LeftButton == ButtonState.Pressed && prevState.LeftButton == ButtonState.Released) { return(true); } return(false); }
protected internal override void OnMouseUp(Point _hitPoint, int _iButton) { if (_iButton != Screen.Game.InputMgr.PrimaryMouseButton) { return; } mbIsMouseDown = false; mHoverPoint = _hitPoint; if (mHoveredActionButton != null) { if (mbIsHoveredActionButtonDown) { mHoveredActionButton.OnMouseUp(_hitPoint, _iButton); mbIsHoveredActionButtonDown = false; } } else if (IsDragging) { Debug.Assert(FocusedRow != null); ListViewRow draggedRow = FocusedRow; if (HitBox.Contains(_hitPoint) && HoveredRow != draggedRow && DragNDropHandler != null) { int iIndex = ((HoveredRow != null) ? Rows.IndexOf(HoveredRow) : (Rows.Count - 1)) + (mbInsertAfter ? 1 : 0); if (iIndex > Rows.IndexOf(draggedRow)) { iIndex--; } if (DragNDropHandler(draggedRow, iIndex)) { Rows.Remove(draggedRow); Rows.Insert(iIndex, draggedRow); } } } else if (mbIsHoveringNewRow) { if (NewRowClickedHandler != null) { NewRowClickedHandler(this); } } else { SelectRowAt(_hitPoint); } IsDragging = false; }
public virtual bool CheckCollisionArrow(Arrow arrow) { //Arrow doesn't hit anything but alive ones. if (CurrentState != State.Alive) { return(false); } return(HitBox.Contains(arrow.HeadPoint)); }
public bool IsClicked(MouseState mouse) { if (IsVisible) { if (mouse.LeftButton == ButtonState.Pressed && HitBox.Contains(mouse.X, mouse.Y)) { return(true); } } return(false); }
public override void Draw(GameTime gameTime, Point mousePos) { var hovered = HitBox.Contains(mousePos); for (var i = 0; i < BorderThickness; i++) { DrawRect.PadIn(i).Draw(hovered ? BorderHoverColor : BorderColor, Bounds); } }
public override void Update(GameTime gameTime, Input input) { if (!HitBox.Contains(input.MousePos) || input.Hovered) { return; } if (input.LeftPress) { input.CaptureClick(); Option?.Execute(); } else if (input.MouseMovement != Point.Zero) { input.CaptureHover(); Hover?.Invoke(); } }
//---------------------------------------------------------------------- public override Widget HitTest(Point _point) { if (HitBox.Contains(_point)) { Widget hitWidget; for (int iChild = mlChildren.Count - 1; iChild >= 0; iChild--) { Widget child = mlChildren[iChild]; if ((hitWidget = child.HitTest(_point)) != null) { return(hitWidget); } } } return(null); }
/// <summary> /// /// </summary> /// <param name="pos">Needs to be relative to rt where link was rendered.</param> /// <param name="clickType"></param> /// <returns></returns> public bool HitTest(Vector2 pos, ClickType clickType) { if (HitBox.Contains(pos)) { if (GamePadInput.ActiveMode == GamePadInput.InputMode.Touch) { // In touch mode, we don't hover first, count it as clicked right away. if (clickType == ClickType.WasPressed || clickType == ClickType.WasReleased) { IsClickFocus = true; WasClicked = true; return(true); } } else { if (clickType == ClickType.WasPressed) { IsClickFocus = true; } else if (clickType == ClickType.WasReleased) { if (IsClickFocus) { WasClicked = true; } } return(true); } } IsClickFocus = false; WasClicked = false; return(false); } // end of HitTest()
public override void Update() { if (!IsControlled && CharacterState == CharacterState.Active) { #region AI Behavior switch (AIState) { case AIState.Attack: if (mainMan.GameMan.Players[0].CharacterState != CharacterState.Dead && PlayerInArea()) { //Move close to attack if (DistanceToPlayer(0) > AttackRange) { if (mainMan.GameMan.Players[0].Character.Type == Faction.Thief && mainMan.GameMan.Players[0].Character.CurrentAbility.InUse) { MoveToPoint((mainMan.GameMan.Players[0].Character.CurrentAbility as Decoy).Position.X, (mainMan.GameMan.Players[0].Character.CurrentAbility as Decoy).Position.Y); } else { MoveToPoint(mainMan.GameMan.Players[0].X, mainMan.GameMan.Players[0].Y); } } else { //Fight them suckers SwitchAIState(AIState.Swing); } } else { SwitchAIState(AIState.Idle); } AIStateTimer -= (float)mainMan.GameTime.ElapsedGameTime.TotalSeconds; if (AIStateTimer <= 0f) { SwitchAIState(AIState.Idle); } break; case AIState.Swing: AIStateTimer -= (float)mainMan.GameTime.ElapsedGameTime.TotalSeconds; if (AIStateTimer <= 0f) { SwitchAIState(AIState.Idle); } break; case AIState.Defend: if (mainMan.GameMan.Players[0].CharacterState != CharacterState.Dead && PlayerInArea()) { //Check if player is too close and move back if (DistanceToPlayer(0) < SightRange / 1.5) { SetDirectionToPoint(mainMan.GameMan.Players[0].X, mainMan.GameMan.Players[0].Y); MoveToPoint(X + (float)(MovementSpeed * Math.Cos((270f - Direction) * Math.PI / 180f)), Y + (float)(MovementSpeed * Math.Sin((270f - Direction) * Math.PI / 180f))); } else { SwitchAIState(AIState.Idle); } } else { SwitchAIState(AIState.Idle); } AIStateTimer -= (float)mainMan.GameTime.ElapsedGameTime.TotalSeconds; if (AIStateTimer <= 0f) { SwitchAIState(AIState.Idle); } break; case AIState.Idle: AIStateTimer -= (float)mainMan.GameTime.ElapsedGameTime.TotalSeconds; if (AIStateTimer <= 0f) { //random movement? if (!mainMan.GameMan.Players[0].NoCharacter && PlayerInArea() && mainMan.GameMan.Players[0].Character.Type != Type && mainMan.GameMan.Players[0].CharacterState == CharacterState.Active) { if (DistanceToPlayer(0) < SightRange) { //Get random SwitchAIState(GetRandomAIState(EncounterAIStates)); } } else { AIStateTimer = AITimers[AIState]; } } break; case AIState.Switch: //Move to sword MoveToPoint(mainMan.GameMan.Players[0].X, mainMan.GameMan.Players[0].Y); //Check if picked up if (HitBox.Contains(mainMan.GameMan.Players[0].Position)) { //Pick it up!!! mainMan.GameMan.Players[0].SwitchBlade(this); } break; case AIState.Ability: //Warp to player CurrentAbility.AIUse(); SwitchAIState(AIState.Idle); break; case AIState.Cower: break; case AIState.Ready: break; } #endregion } base.Update(); }
public virtual bool Contains(Point point) { return(HitBox.Contains(point)); }
public bool IsClicked() { return(HitBox.Contains(Globals.MouseState.Position) && Globals.MouseState.LeftButton == ButtonState.Pressed && Globals.OldMouseState.LeftButton == ButtonState.Released); }
public override Widget HitTest(Point _point) { return(Scrollbar.HitTest(_point) ?? base.HitTest(_point) ?? (HitBox.Contains(_point) ? this : null)); }
//---------------------------------------------------------------------- public override void Draw() { Screen.DrawBox(Style.ListViewFrame, LayoutRect, Style.ListViewFrameCornerSize, Color.White); if (DisplayColumnHeaders) { int iColX = 0; foreach (ListViewColumn col in Columns) { Screen.DrawBox(Style.ColumnHeaderFrame, new Rectangle(LayoutRect.X + Padding.Left + iColX, LayoutRect.Y + Padding.Top, col.Width, Style.RowHeight), Style.ColumnHeaderCornerSize, Color.White); if (col.Label != null) { col.Label.Draw(); } else { col.Image.Draw(); } iColX += col.Width + ColSpacing; } } Screen.PushScissorRectangle(new Rectangle(LayoutRect.X + Padding.Left, LayoutRect.Y + Padding.Top + (DisplayColumnHeaders ? Style.RowHeight : 0), LayoutRect.Width - Padding.Horizontal, LayoutRect.Height - Padding.Vertical - (DisplayColumnHeaders ? Style.RowHeight : 0))); int iRowIndex = 0; foreach (ListViewRow row in Rows) { int iRowY = GetRowY(iRowIndex); if ((iRowY + Style.RowHeight + Style.RowSpacing < 0) || (iRowY > LayoutRect.Height - Padding.Vertical)) { iRowIndex++; continue; } if (MergeColumns) { Rectangle rowRect = new Rectangle(LayoutRect.X + Padding.Left, LayoutRect.Y + Padding.Top + iRowY, LayoutRect.Width - Padding.Horizontal, Style.RowHeight); Screen.DrawBox(SelectedRow == row ? Style.SelectedCellFrame : Style.CellFrame, rowRect, Style.CellCornerSize, Color.White); if (HasFocus && FocusedRow == row) { if (SelectedRow != row) { Screen.DrawBox(Style.CellFocusOverlay, rowRect, Style.CellCornerSize, Color.White); } else if (Style.SelectedCellFocusOverlay != null) { Screen.DrawBox(Style.SelectedCellFocusOverlay, rowRect, Style.CellCornerSize, Color.White); } } if (HoveredRow == row && !IsDragging) { if (SelectedRow != row) { Screen.DrawBox(Style.CellHoverOverlay, rowRect, Style.CellCornerSize, Color.White); } else if (Style.SelectedCellHoverOverlay != null) { Screen.DrawBox(Style.SelectedCellHoverOverlay, rowRect, Style.CellCornerSize, Color.White); } } } int iColX = 0; for (int i = 0; i < row.Cells.Length; i++) { ListViewColumn col = Columns[i]; Rectangle rowRect = new Rectangle(LayoutRect.X + Padding.Left + iColX, LayoutRect.Y + Padding.Top + iRowY, col.Width, Style.RowHeight); if (!MergeColumns) { Screen.DrawBox(SelectedRow == row ? Style.SelectedCellFrame : Style.CellFrame, rowRect, Style.CellCornerSize, Color.White); if (HasFocus && FocusedRow == row) { if (SelectedRow != row) { Screen.DrawBox(Style.CellFocusOverlay, rowRect, Style.CellCornerSize, Color.White); } else if (Style.SelectedCellFocusOverlay != null) { Screen.DrawBox(Style.SelectedCellFocusOverlay, rowRect, Style.CellCornerSize, Color.White); } } if (HoveredRow == row && !IsDragging) { if (SelectedRow != row) { Screen.DrawBox(Style.CellHoverOverlay, rowRect, Style.CellCornerSize, Color.White); } else if (Style.SelectedCellHoverOverlay != null) { Screen.DrawBox(Style.SelectedCellHoverOverlay, rowRect, Style.CellCornerSize, Color.White); } } } row.Cells[i].Draw(new Point(LayoutRect.X + Padding.Left + iColX, LayoutRect.Y + Padding.Top + iRowY)); iColX += col.Width + ColSpacing; } iRowIndex++; } if (NewRowText != null) { int iRowY = GetRowY(iRowIndex); Screen.DrawBox(mbIsHoveringNewRow ? Style.NewRowHoveredFrame : Style.NewRowFrame, new Rectangle(LayoutRect.X + Padding.Left, LayoutRect.Y + Padding.Top + iRowY, LayoutRect.Width - Padding.Horizontal, Style.RowHeight), Style.NewRowFrameCornerSize, Color.White); Vector2 vTextPos = new Vector2(LayoutRect.X + Padding.Left + Style.NewRowHorizontalPadding, LayoutRect.Y + Padding.Top + iRowY + Style.RowHeight / 2f - (int)(Screen.Style.MediumFont.LineSpacing * 0.9f / 2f) + Screen.Style.MediumFont.YOffset); Screen.Game.SpriteBatch.DrawString(Screen.Style.MediumFont, NewRowText, vTextPos, mbIsHoveringNewRow ? Style.NewRowHoveredTextColor : Style.NewRowTextColor); iRowIndex++; } if (HoveredRow != null && !IsDragging) { foreach (Button button in ActionButtons) { button.Draw(); } } if (IsDragging && HitBox.Contains(mHoverPoint)) { int iX = LayoutRect.X + Padding.Left; int iWidth = LayoutRect.Width - Padding.Horizontal; if (HoveredRow != null) { int iY = LayoutRect.Y + Padding.Top + GetRowY(Rows.IndexOf(HoveredRow) + (mbInsertAfter ? 1 : 0)) - (Style.RowSpacing + Screen.Style.ListRowInsertMarker.Height) / 2; Rectangle markerRect = new Rectangle(iX, iY, iWidth, Screen.Style.ListRowInsertMarker.Height); Screen.DrawBox(Screen.Style.ListRowInsertMarker, markerRect, Screen.Style.ListRowInsertMarkerCornerSize, Color.White); } else if (IsHovered) { int iY = LayoutRect.Y + Padding.Top + (mbInsertAfter ? GetRowY(Rows.Count) : 0) - (Style.RowSpacing + Screen.Style.ListRowInsertMarker.Height) / 2; Rectangle markerRect = new Rectangle(iX, iY, iWidth, Screen.Style.ListRowInsertMarker.Height); Screen.DrawBox(Screen.Style.ListRowInsertMarker, markerRect, Screen.Style.ListRowInsertMarkerCornerSize, Color.White); } } Screen.PopScissorRectangle(); Scrollbar.Draw(); }