public static void Perform() { var doc = Document.Current; foreach (var row in doc.TopLevelSelectedRows().ToList()) { if (!row.IsCopyPasteAllowed()) { continue; } if (row.Components.Get <PropertyRow>()?.Animator is IAnimator animator) { doc.History.DoTransaction(() => { foreach (var keyframe in animator.Keys.ToList()) { RemoveKeyframe.Perform(animator, keyframe.Frame); } }); } else if (row.Components.Get <AnimationTrackRow>()?.Track is AnimationTrack track) { doc.History.DoTransaction(() => { RemoveFromList <AnimationTrackList, AnimationTrack> .Perform(doc.Animation.Tracks, track); }); } else if (row.Components.Get <BoneRow>()?.Bone is Bone currentBone) { var bones = doc.Container.Nodes.OfType <Bone>().ToList(); var dependentBones = BoneUtils.FindBoneDescendats(currentBone, bones).ToList(); dependentBones.Insert(0, currentBone); UntieWidgetsFromBones.Perform(dependentBones, doc.Container.Nodes.OfType <Widget>()); foreach (var bone in dependentBones) { UnlinkFolderItem.Perform(doc.Container, bone); doc.Container.AsWidget.BoneArray[bone.Index] = default; } doc.History.DoTransaction(() => { foreach (var mesh in doc.Container.Nodes.OfType <Lime.Animesh>()) { mesh.OnBoneArrayChanged?.Invoke(); } }); } else if (Row.GetFolderItem(row) is IFolderItem item) { UnlinkFolderItem.Perform(doc.Container, item); } } }
protected override void InternalDo(TimelineHorizontalShift op) { var container = Document.Current.Container; foreach (var node in container.Nodes) { foreach (var animator in node.Animators.Where(i => i.AnimationId == Document.Current.AnimationId)) { var keys = op.Direction > 0 ? animator.ReadonlyKeys.Reverse() : animator.ReadonlyKeys; foreach (var k in keys.ToList()) { if (k.Frame >= op.Column) { RemoveKeyframe.Perform(animator, k.Frame); var k1 = k.Clone(); k1.Frame += op.Direction.Sign(); if (op.Direction > 0 || k.Frame > op.Column) { SetKeyframe.Perform(animator, k1); } } } } } var markers = container.Markers.ToList(); if (op.Direction > 0) { markers.Reverse(); } foreach (var m in markers) { if (m.Frame >= op.Column) { DeleteMarker.Perform(container.Markers, m); var m1 = m.Clone(); m1.Frame += op.Direction.Sign(); if (op.Direction > 0 || m.Frame > op.Column) { SetMarker.Perform(container.Markers, m1); } } } }
public static void Perform() { foreach (var row in Document.Current.TopLevelSelectedRows().ToList()) { if (!row.IsCopyPasteAllowed()) { continue; } if (row.Components.Get <PropertyRow>()?.Animator is IAnimator animator) { Document.Current.History.DoTransaction(() => { foreach (var keyframe in animator.Keys.ToList()) { RemoveKeyframe.Perform(animator, keyframe.Frame); } }); continue; } var item = Row.GetFolderItem(row); var currentBone = row.Components.Get <BoneRow>()?.Bone; if (currentBone != null) { var bones = Document.Current.Container.Nodes.OfType <Bone>().ToList(); var dependentBones = BoneUtils.FindBoneDescendats(currentBone, bones).ToList(); dependentBones.Insert(0, currentBone); UntieWidgetsFromBones.Perform(dependentBones, Document.Current.Container.Nodes.OfType <Widget>()); foreach (var bone in dependentBones) { UnlinkFolderItem.Perform(Document.Current.Container, bone); Document.Current.Container.AsWidget.BoneArray[bone.Index] = default(BoneArray.Entry); } } else if (item != null) { UnlinkFolderItem.Perform(Document.Current.Container, item); } } }
public static void Perform(int column) { var container = Document.Current.Container; foreach (var node in container.Nodes) { var occupied = new HashSet <int>(); if (node.Animators.Count == 0) { continue; } foreach (var animator in node.Animators.Where(i => i.AnimationId == Document.Current.AnimationId)) { foreach (var k in animator.ReadonlyKeys) { occupied.Add(k.Frame); } } int removeAt = occupied.Max() + 1; for (int i = column - 1; ; ++i) { if (!occupied.Contains(i)) { removeAt = i; break; } } foreach (var animator in node.Animators.Where(i => i.AnimationId == Document.Current.AnimationId).ToList()) { var keys = animator.ReadonlyKeys.ToList(); foreach (var k in keys) { if (k.Frame != 0 && k.Frame >= removeAt) { var k1 = k.Clone(); k1.Frame -= 1; SetKeyframe.Perform(animator, k1); RemoveKeyframe.Perform(animator, k.Frame); } } } } var markers = container.Markers.ToList(); if (markers.Count == 0) { return; } var markersOccupied = new HashSet <int>(); foreach (var m in markers) { markersOccupied.Add(m.Frame); } int markersRemoveAt = markersOccupied.Max() + 1; for (int i = column - 1; ; ++i) { if (!markersOccupied.Contains(i)) { markersRemoveAt = i; break; } } foreach (var m in markers) { if (m.Frame != 0 && m.Frame >= markersRemoveAt) { var m1 = m.Clone(); m1.Frame -= 1; DeleteMarker.Perform(container, m, false); SetMarker.Perform(container, m1, false); } } }