public void OnSpriteSheetFrameRectChanged(SpriteSheetFrame frameChanged) { var animations = GetAnimationsFromSpriteSheet(CurrentShownSpriteSheet); var animConfigDisplay = GetDisplay <AnimConfigDisplay>("AnimConfig"); foreach (var animation in animations) { foreach (var frame in animation.Frames) { if (frame.SpriteFrame.SpriteFrameId == frameChanged.Id) { frame.ResetSpriteFrame(new Sprite(CurrentShownSpriteSheet.Texture, frameChanged.BoundingRect), frameChanged.Id); if (animConfigDisplay.CurrentAnimation.Id == animation.Id) { animConfigDisplay.SetAnimation(animation); } } break; } } }
public SpriteSheetFrame AddFrame(string name, int id, Rect frameRect) { SpriteSheetFrame frame = new SpriteSheetFrame(frameRect, this) { TagName = name, Id = id }; Frames.Add(frame); return(frame); }
public void SelectFrame(SpriteSheetFrame spriteSheetFrame, bool select) { if (select && !spriteSheetFrame.Selected) { SelectedFrames.Add(spriteSheetFrame); } else if (!select && spriteSheetFrame.Selected) { SelectedFrames.Remove(spriteSheetFrame); } spriteSheetFrame.Selected = select; }
public void HighLightFrame(SpriteSheetFrame spriteSheetFrame, bool highlight) { if (spriteSheetFrame.Highlighted == highlight) { return; } spriteSheetFrame.Highlighted = highlight; if (highlight) { HighLightedFrame = spriteSheetFrame; } else { HighLightedFrame = null; } }
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; } } }
public void ToggleSelectFrame(SpriteSheetFrame spriteSheetFrame) { SelectFrame(spriteSheetFrame, !spriteSheetFrame.Selected); }
public void ChangeFrameRect(SpriteSheetFrame frame, Rect newFrameRect) { frame.BoundingRect = newFrameRect; }