예제 #1
0
        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;
                }
            }
        }
예제 #2
0
        public SpriteSheetFrame AddFrame(string name, int id, Rect frameRect)
        {
            SpriteSheetFrame frame = new SpriteSheetFrame(frameRect, this)
            {
                TagName = name, Id = id
            };

            Frames.Add(frame);

            return(frame);
        }
예제 #3
0
        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;
        }
예제 #4
0
        public void HighLightFrame(SpriteSheetFrame spriteSheetFrame, bool highlight)
        {
            if (spriteSheetFrame.Highlighted == highlight)
            {
                return;
            }

            spriteSheetFrame.Highlighted = highlight;

            if (highlight)
            {
                HighLightedFrame = spriteSheetFrame;
            }
            else
            {
                HighLightedFrame = null;
            }
        }
예제 #5
0
        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;
        }
예제 #6
0
        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;
                }
            }
        }
예제 #7
0
 public void ToggleSelectFrame(SpriteSheetFrame spriteSheetFrame)
 {
     SelectFrame(spriteSheetFrame, !spriteSheetFrame.Selected);
 }
예제 #8
0
 public void ChangeFrameRect(SpriteSheetFrame frame, Rect newFrameRect)
 {
     frame.BoundingRect = newFrameRect;
 }