public override void OnUpdate(MainDisplay owner) { base.OnUpdate(owner); if (Active) { Vector2 mouseDelta = owner.WorldMousePosition - initialPressedPos; if (mouseDelta.X != 0 || mouseDelta.Y != 0) { if (!owner.BottomPanelHidden) { owner.HideBottomPanel(); hidBottomPanel = true; } if (!owner.TopPanelHidden) { owner.HideTopPanel(); hidTopPanel = true; } } mouseDelta = mouseDelta.Negative; owner.Camera.Move(mouseDelta); } }
public override void OnStart(MainDisplay owner) { initialPressedPos = owner.WorldMousePosition; base.OnStart(owner); }
public override void OnUpdate(MainDisplay owner) { base.OnUpdate(owner); if (Active) { SelectRect.Left = _initialPressedPos.X; SelectRect.Top = _initialPressedPos.Y; SelectRect.Right = owner.WorldMousePosition.X; SelectRect.Bottom = owner.WorldMousePosition.Y; var oldDraggingRectangle = SelectRect; SelectRect.Left = MathHelper.Min(oldDraggingRectangle.Left, oldDraggingRectangle.Right); SelectRect.Right = MathHelper.Max(oldDraggingRectangle.Left, oldDraggingRectangle.Right); SelectRect.Top = MathHelper.Min(oldDraggingRectangle.Top, oldDraggingRectangle.Bottom); SelectRect.Bottom = MathHelper.Max(oldDraggingRectangle.Top, oldDraggingRectangle.Bottom); SelectRect.Left = MathHelper.Max(owner.CurrentSpriteSheet.BoundingRect.Left, SelectRect.Left); SelectRect.Right = MathHelper.Min(owner.CurrentSpriteSheet.BoundingRect.Right, SelectRect.Right); SelectRect.Top = MathHelper.Max(owner.CurrentSpriteSheet.BoundingRect.Top, SelectRect.Top); SelectRect.Bottom = MathHelper.Min(owner.CurrentSpriteSheet.BoundingRect.Bottom, SelectRect.Bottom); } }
public virtual void OnUpdate(MainDisplay owner) { if (CheckStateChange(owner)) { Active = false; } }
public override void OnUpdate(MainDisplay owner) { base.OnUpdate(owner); if (Active) { SelectRect.Left = _initialPressedPos.X; SelectRect.Top = _initialPressedPos.Y; SelectRect.Right = owner.WorldMousePosition.X; SelectRect.Bottom = owner.WorldMousePosition.Y; if (SelectRect.Width != 0 && SelectRect.Height != 0) { owner.HideTopPanel(); var oldDraggingRectangle = SelectRect; SelectRect.Left = MathHelper.Min(oldDraggingRectangle.Left, SelectRect.Right); SelectRect.Right = MathHelper.Max(oldDraggingRectangle.Left, SelectRect.Right); SelectRect.Top = MathHelper.Min(oldDraggingRectangle.Top, SelectRect.Bottom); SelectRect.Bottom = MathHelper.Max(oldDraggingRectangle.Top, SelectRect.Bottom); if (owner.CurrentSpriteSheet.Frames.Count > 0) { foreach (var frame in owner.CurrentSpriteSheet.Frames) { owner.CurrentSpriteSheet.SelectFrame(frame, SelectRect.Intersects(frame.RelativeBoundingRect)); } } } } }
protected override bool CheckStateChange(MainDisplay owner) { if (Input.MousePressed(MouseButton.Left, "MainDisplay")) { Handler.ChangeState(IdleState.Instance); return(true); } return(false); }
public override void OnExit(MainDisplay owner) { Vector2 mousePos = owner.WorldMousePosition; var positionClicked = new Vector2(mousePos.X - owner.CurrentSpriteSheet.BoundingRect.Left, mousePos.Y - owner.CurrentSpriteSheet.BoundingRect.Top).ToPoint(); owner.CurrentSpriteSheet.ClearColor(positionClicked.X, positionClicked.Y); }
protected override bool CheckStateChange(MainDisplay owner) { if (Input.ControlReleased(Configuration.ViewZoomControl, "MainDisplay")) { Handler.ChangeState(IdleState.Instance); return(true); } return(false); }
public override void OnStart(MainDisplay owner) { base.OnStart(owner); if (owner.TopPanelHidden) { owner.ShowTopPanel(); } }
public override void OnUpdate(MainDisplay owner) { base.OnUpdate(owner); if (Active) { float mouseX = owner.WorldMousePosition.X; float mouseY = owner.WorldMousePosition.Y; if (_modifyMode == FrameRectModifyMode.Move) { _frameRect.CenterX = mouseX - _deltaPressed.X; _frameRect.CenterY = mouseY - _deltaPressed.Y; } if ((_modifyMode & FrameRectModifyMode.ResizeLeft) == FrameRectModifyMode.ResizeLeft) { _frameRect.Left = mouseX; } else if ((_modifyMode & FrameRectModifyMode.ResizeRight) == FrameRectModifyMode.ResizeRight) { _frameRect.Right = mouseX; } if ((_modifyMode & FrameRectModifyMode.ResizeTop) == FrameRectModifyMode.ResizeTop) { _frameRect.Top = mouseY; } else if ((_modifyMode & FrameRectModifyMode.ResizeBottom) == FrameRectModifyMode.ResizeBottom) { _frameRect.Bottom = mouseY; } var oldDraggingRectangle = _frameRect; _frameRect.Left = MathHelper.Min(oldDraggingRectangle.Left, oldDraggingRectangle.Right); _frameRect.Right = MathHelper.Max(oldDraggingRectangle.Left, oldDraggingRectangle.Right); _frameRect.Top = MathHelper.Min(oldDraggingRectangle.Top, oldDraggingRectangle.Bottom); _frameRect.Bottom = MathHelper.Max(oldDraggingRectangle.Top, oldDraggingRectangle.Bottom); _frameRect.Left = MathHelper.Max(owner.CurrentSpriteSheet.BoundingRect.Left, _frameRect.Left); _frameRect.Right = MathHelper.Min(owner.CurrentSpriteSheet.BoundingRect.Right, _frameRect.Right); _frameRect.Top = MathHelper.Max(owner.CurrentSpriteSheet.BoundingRect.Top, _frameRect.Top); _frameRect.Bottom = MathHelper.Min(owner.CurrentSpriteSheet.BoundingRect.Bottom, _frameRect.Bottom); } }
public override void OnUpdate(MainDisplay owner) { base.OnUpdate(owner); if (Active) { float delta = owner.WorldMousePosition.Y - lastMouseY; if (delta >= 0.01f || delta <= -0.01f) { owner.Camera.ZoomToWorldPoint(owner.WorldMousePosition.X, owner.WorldMousePosition.Y, MathHelper.CalculateCameraZoomFactor(owner.Camera, -(int)delta)); } lastMouseY = owner.WorldMousePosition.Y; } }
public override void OnExit(MainDisplay owner) { if (hidBottomPanel) { owner.ShowBottomPanel(); hidBottomPanel = false; } if (hidTopPanel) { owner.ShowTopPanel(); hidTopPanel = false; } base.OnExit(owner); }
public override void OnExit(MainDisplay owner) { if (SelectRect.Width > 0 && SelectRect.Height > 0) { var foundRect = Application.Instance.ShrinkFrameSelect(owner.CurrentSpriteSheet.Texture, SelectRect, 0.12); if (foundRect.Width > 0 && foundRect.Height > 0) { owner.CurrentSpriteSheet.AddFrame(foundRect); owner.CurrentSpriteSheet.SortFrames(); } } SelectRect = Rect.Empty; _initialPressedPos = Vector2.Zero; }
public override void OnExit(MainDisplay owner) { if (_frameRect.Width > 0 && _frameRect.Height > 0) { var foundRect = Application.Instance.ShrinkFrameSelect(owner.CurrentSpriteSheet.Texture, _frameRect, 0.12); if (foundRect.Width > 0 && foundRect.Height > 0) { owner.CurrentSpriteSheet.ChangeFrameRect(_frameBeingChanged, foundRect); Application.Instance.OnSpriteSheetFrameRectChanged(_frameBeingChanged); } } _frameBeingChanged = null; _frameRect = Rect.Empty; _deltaPressed = Vector2.Zero; _modifyMode = FrameRectModifyMode.None; }
public override void OnStart(MainDisplay owner) { base.OnStart(owner); _pressedPosition = owner.WorldMousePosition; _frameBeingChanged = owner.CurrentSpriteSheet.HighLightedFrame; _frameRect = _frameBeingChanged.RelativeBoundingRect; _deltaPressed = new Vector2(_pressedPosition.X - _frameBeingChanged.RelativeBoundingRect.CenterX, _pressedPosition.Y - _frameBeingChanged.RelativeBoundingRect.CenterY); if (_pressedPosition.X > _frameRect.Left + 5 && _pressedPosition.X < _frameRect.Right - 5 && _pressedPosition.Y > _frameRect.Top + 5 && _pressedPosition.Y < _frameRect.Bottom - 5) { _modifyMode = FrameRectModifyMode.Move; } else { if (_pressedPosition.X < _frameRect.Left + 5) { _modifyMode |= FrameRectModifyMode.ResizeLeft; } else if (_pressedPosition.X > _frameRect.Right - 5) { _modifyMode |= FrameRectModifyMode.ResizeRight; } if (_pressedPosition.Y < _frameRect.Top + 5) { _modifyMode |= FrameRectModifyMode.ResizeTop; } else if (_pressedPosition.Y > _frameRect.Bottom - 5) { _modifyMode |= FrameRectModifyMode.ResizeBottom; } } }
protected override bool CheckStateChange(MainDisplay owner) { if (owner.MouseIsOverGUI) { return(false); } if (Input.ControlPressed(Configuration.SelectSpriteControl, "MainDisplay")) { Handler.ChangeState(SelectingSpriteState.Instance); return(true); } if (Input.ControlPressed(Configuration.SpriteMarkUpControl, "MainDisplay") && owner.MouseIsInsideSpriteSheet) { if (owner.CurrentSpriteSheet.HighLightedFrame == null) { Handler.ChangeState(SpriteMarkupingState.Instance); } else { Handler.ChangeState(ChangingSpriteMarkupState.Instance); } return(true); } if (Input.ControlPressed(Configuration.DragCameraControl, "MainDisplay")) { Handler.ChangeState(MovingCameraState.Instance); return(true); } if (Input.ControlPressed(Configuration.ViewZoomControl, "MainDisplay")) { Handler.ChangeState(ZoomingCameraState.Instance); return(true); } return(false); }
public override void OnStart(MainDisplay owner) { base.OnStart(owner); _initialPressedPos = owner.WorldMousePosition; // Add the frame that we have selected clicking with the mouse if (owner.CurrentSpriteSheet.HighLightedFrame != null) { var selected = owner.CurrentSpriteSheet.HighLightedFrame.Selected; owner.CurrentSpriteSheet.SelectFrame(owner.CurrentSpriteSheet.HighLightedFrame, !selected); if (!selected) { Application.Instance.MainWindow.PropertiesGrid.SelectedObject = owner.CurrentSpriteSheet.HighLightedFrame; } } else { owner.CurrentSpriteSheet.UnselectAllFrames(); } }
public override void OnUpdate(MainDisplay owner) { base.OnUpdate(owner); if (Active && !owner.MouseIsOverGUI) { Vector2 mousePos = owner.WorldMousePosition; if (owner.CurrentSpriteSheet.Frames.Count > 0) { foreach (SpriteSheetFrame frame in owner.CurrentSpriteSheet.Frames) { if (frame.RelativeBoundingRect.Contains(mousePos.X, mousePos.Y)) { owner.CurrentSpriteSheet.HighLightFrame(frame, true); } else { owner.CurrentSpriteSheet.HighLightFrame(frame, false); } } } } }
protected abstract bool CheckStateChange(MainDisplay owner);
public virtual void OnExit(MainDisplay owner) { }
public override void OnStart(MainDisplay owner) { lastMouseY = owner.WorldMousePosition.Y; base.OnStart(owner); }
public override void OnExit(MainDisplay owner) { SelectRect = Rect.Empty; _initialPressedPos = Vector2.Zero; }
public override void OnExit(MainDisplay owner) { lastMouseY = 0; base.OnExit(owner); }
public void Init(MainDisplay owner, State initialState) { _owner = owner; ChangeState(initialState); }
public virtual void OnStart(MainDisplay owner) { Active = true; }