Ejemplo n.º 1
0
        private static GSPat.ImageManipulation ExportIM(Pat.Frame frame, Pat.FrameImage image)
        {
            var scaleX     = frame.ScaleX;
            var scaleY     = frame.ScaleY;
            var rotation   = frame.Rotation;
            var alphaBlend = image.AlphaBlendMode;

            //TODO add other fields
            if (scaleX == 100 && scaleY == 100 && rotation == 0 && !alphaBlend)
            {
                return(null);
            }
            return(new GSPat.ImageManipulation
            {
                AlphaBlend = (short)(alphaBlend ? 1 : 0),
                ScaleX = (short)scaleX,
                ScaleY = (short)scaleY,
                Rotation = (short)rotation,

                Alpha = (byte)(255 * frame.Alpha),
                Red = (byte)(255 * frame.Red),
                Green = (byte)(255 * frame.Green),
                Blue = (byte)(255 * frame.Blue),
            });
        }
Ejemplo n.º 2
0
            public KeyFrameGrid(Bitmap bitmap, int index, int segIndex, int frameIndex, KeyFrameFlags flags, Pat.Frame frameObj)
                : base(bitmap, index)
            {
                Segment     = segIndex;
                Frame       = frameIndex;
                Flags       = flags;
                FrameObject = frameObj;

                IsFolded = true;
            }
Ejemplo n.º 3
0
        private void ResetFrame(Pat.AnimationSegment segment, Pat.Frame frame)
        {
            CurrentSegment = segment;
            CurrentFrame   = frame;

            if (FrameReset != null)
            {
                FrameReset();
            }
        }
Ejemplo n.º 4
0
 private Pat.FramePoint GetOutputPoint(Pat.Frame frame, int i)
 {
     if (EditingPoint == i)
     {
         return(new Pat.FramePoint
         {
             X = frame.Points[i].X + OffsetX,
             Y = frame.Points[i].Y + OffsetY,
         });
     }
     return(frame.Points[i]);
 }
 private string FindFrame(Pat.Action a, Pat.Frame f)
 {
     for (int i = 0; i < a.Segments.Count; ++i)
     {
         var s = a.Segments[i];
         for (int j = 0; j < s.Frames.Count; ++j)
         {
             if (s.Frames[j] == f)
             {
                 return("Segment " + i.ToString() + " Frame " + j.ToString());
             }
         }
     }
     return("Unknown");
 }
Ejemplo n.º 6
0
 private void ValidatePoints(Pat.Frame frame)
 {
     if (frame.Points == null)
     {
         frame.Points = new List <Pat.FramePoint>();
     }
     while (frame.Points.Count < 3)
     {
         frame.Points.Add(new Pat.FramePoint());
     }
     if (frame.Points.Count > 3)
     {
         frame.Points.RemoveRange(3, frame.Points.Count - 3);
     }
 }
Ejemplo n.º 7
0
        public void InsertNewFrameBefore()
        {
            if (_LastSelected != null)
            {
                var grid         = (KeyFrameGrid)_LastSelected;
                var segmentIndex = grid.Segment;
                var frameIndex   = grid.Frame;

                var action = _Parent.CurrentAction;
                if (action == null)
                {
                    return;
                }

                var frame = new Pat.Frame()
                {
                    Duration    = action.Segments[segmentIndex].Frames[frameIndex].Duration,
                    ImageID     = null,
                    AttackBoxes = new List <Pat.Box>(),
                    HitBoxes    = new List <Pat.Box>(),
                    Points      = new List <Pat.FramePoint>(),
                    ScaleX      = 100,
                    ScaleY      = 100,
                };

                if (frameIndex == 0 && segmentIndex > 0)
                {
                    action.Segments[segmentIndex - 1].Frames.Add(frame);
                }
                else
                {
                    action.Segments[segmentIndex].Frames.Insert(frameIndex, frame);
                }

                RefreshList();
            }
        }
Ejemplo n.º 8
0
        public void ShowSelectImageForm()
        {
            if (_LastSelected != null)
            {
                var grid = (KeyFrameGrid)_LastSelected;

                var action = _Parent.CurrentAction;
                if (action == null)
                {
                    return;
                }

                var frame = action.Segments[grid.Segment].Frames[grid.Frame];

                var dialog = new ImageSelectForm(_Parent.Project)
                {
                    SelectedImage = frame.ImageID,
                };
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    frame.ImageID = dialog.SelectedImage;
                    RefreshList();
                }
            }
            else
            {
                var dialog = new ImageSelectForm(_Parent.Project)
                {
                    SelectedImage = null,
                };
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    //create a new frame
                    var action = _Parent.CurrentAction;
                    if (action == null)
                    {
                        return;
                    }

                    if (action.Segments.Count == 0)
                    {
                        action.Segments.Add(new Pat.AnimationSegment()
                        {
                            Frames = new List <Pat.Frame>(),
                        });
                    }
                    var segment = action.Segments.Last();

                    int duration = 1;
                    if (segment.Frames.Count > 0)
                    {
                        duration = segment.Frames.Last().Duration;
                    }

                    var frame = new Pat.Frame()
                    {
                        Duration    = duration,
                        ImageID     = dialog.SelectedImage,
                        AttackBoxes = new List <Pat.Box>(),
                        HitBoxes    = new List <Pat.Box>(),
                        Points      = new List <Pat.FramePoint>(),
                        ScaleX      = 100,
                        ScaleY      = 100,
                    };
                    segment.Frames.Add(frame);

                    //ensure after refreshing, the new frame is selected
                    _LastSelected = new KeyFrameGrid(null, 0, 0, 0, 0, frame);

                    RefreshList();
                }
            }
        }
 protected abstract List <Pat.Box> GetBoxListFromFrame(Pat.Frame frame);