Beispiel #1
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;
            }
Beispiel #2
0
        private void RefreshList()
        {
            //save the list
            var lastList = _GridList
                           .Where(g => g is KeyFrameGrid)
                           .Cast <KeyFrameGrid>().ToArray();

            _GridList.Clear();

            var data = _Parent.CurrentAction;

            if (data == null)
            {
                UpdateControlWidth();
                SelectKeyGrid(null);
                return;
            }

            var          imageList   = _Parent.Project.ImageList;
            KeyFrameGrid newSelected = null;

            for (int i = 0; i < data.Segments.Count; ++i)
            {
                var seg = data.Segments[i];

                //calculate cancellable frame
                int cancellableJump = -1, cancellableSkill = -1;
                if (seg.JumpCancellable != null)
                {
                    int sum = 0;
                    for (int fi = 0; fi < seg.Frames.Count; ++fi)
                    {
                        if (sum >= seg.JumpCancellable.StartFrom)
                        {
                            cancellableJump = fi;
                            break;
                        }
                        sum += seg.Frames[fi].Duration;
                    }
                }
                if (seg.SkillCancellable != null)
                {
                    int sum = 0;
                    for (int fi = 0; fi < seg.Frames.Count; ++fi)
                    {
                        if (sum >= seg.SkillCancellable.StartFrom)
                        {
                            cancellableSkill = fi;
                            break;
                        }
                        sum += seg.Frames[fi].Duration;
                    }
                }
                for (int j = 0; j < seg.Frames.Count; ++j)
                {
                    var frame = seg.Frames[j];
                    var image = frame.ImageID == null ? null : imageList.GetImage(frame.ImageID);

                    //flags
                    KeyFrameFlags flags = 0;
                    if (j == 0)
                    {
                        flags |= KeyFrameFlags.IsKeyFrame;
                    }
                    if (j == 0 && seg.Damage != null)
                    {
                        flags |= KeyFrameFlags.HasDamage;
                    }
                    if (j == cancellableJump)
                    {
                        flags |= KeyFrameFlags.JumpCancellable;
                    }
                    if (j == cancellableSkill)
                    {
                        flags |= KeyFrameFlags.SkillCancellable;
                    }

                    //create
                    var keyFrame = new KeyFrameGrid(image, _GridList.Count, i, j, flags, frame);

                    //restore status
                    //selected
                    if (_LastSelected != null && frame == _LastSelected.FrameObject)
                    {
                        keyFrame.IsSelected = true;
                        newSelected         = keyFrame;
                    }
                    var lastItem = lastList.Where(g => g.FrameObject == frame).FirstOrDefault();
                    if (lastItem != null && !lastItem.IsFolded)
                    {
                        keyFrame.IsFolded = false;
                    }

                    _GridList.Add(keyFrame);
                    for (int k = 0; k < frame.Duration - 1; ++k)
                    {
                        _GridList.Add(new NormalFrameGrid(keyFrame, image, _GridList.Count));
                    }
                }
            }

            _GridList.Add(new EmptyGrid());

            UpdateControlWidth();

            if (_GridList.Count > 0 && _GridList[0] is KeyFrameGrid && newSelected == null)
            {
                newSelected = (KeyFrameGrid)_GridList[0];
            }
            SelectKeyGrid(newSelected);
        }