Browse Source

Paste correct cel length

flabbet 8 tháng trước cách đây
mục cha
commit
c8b02787bd

+ 1 - 1
src/PixiDocks

@@ -1 +1 @@
-Subproject commit c843c98b5101129180f859f752f490fce1afc957
+Subproject commit 5f14bdf0e46dd470e46a88ce5f58de4e02c68e94

+ 1 - 1
src/PixiEditor/Models/DocumentModels/DocumentUpdater.cs

@@ -487,7 +487,7 @@ internal class DocumentUpdater
 
     private void ProcessKeyFrameLength(KeyFrameLength_ChangeInfo info)
     {
-        doc.AnimationHandler.SetFrameLength(info.KeyFrameGuid, info.StartFrame, info.Duration);
+        doc.AnimationHandler.SetCelLength(info.KeyFrameGuid, info.StartFrame, info.Duration);
     }
 
     private void ProcessKeyFrameVisibility(KeyFrameVisibility_ChangeInfo info)

+ 10 - 0
src/PixiEditor/Models/DocumentModels/Public/DocumentOperationsModule.cs

@@ -873,4 +873,14 @@ internal class DocumentOperationsModule : IDocumentOperations
 
         return newGuid;
     }
+
+    public void ChangeCelLength(Guid celId, int startFrame, int duration)
+    {
+        if (Internals.ChangeController.IsBlockingChangeActive)
+            return;
+
+        Internals.ChangeController.TryStopActiveExecutor();
+
+        Internals.ActionAccumulator.AddFinishedActions(new KeyFrameLength_Action(celId, startFrame, duration), new EndKeyFrameLength_Action());
+    }
 }

+ 1 - 1
src/PixiEditor/Models/Handlers/IAnimationHandler.cs

@@ -14,7 +14,7 @@ internal interface IAnimationHandler
     public Guid? CreateCel(Guid targetLayerGuid, int frame, Guid? toCloneFrom = null, int? frameToCopyFrom = null);
     public void SetFrameRate(int newFrameRate);
     public void SetActiveFrame(int newFrame);
-    public void SetFrameLength(Guid keyFrameId, int newStartFrame, int newDuration);
+    public void SetCelLength(Guid keyFrameId, int newStartFrame, int newDuration);
     public void SetKeyFrameVisibility(Guid infoKeyFrameId, bool infoIsVisible);
     public bool FindKeyFrame<T>(Guid guid, out T keyFrameHandler) where T : ICelHandler;
     internal void AddKeyFrame(ICelHandler iCel);

+ 1 - 1
src/PixiEditor/ViewModels/Document/AnimationDataViewModel.cs

@@ -224,7 +224,7 @@ internal class AnimationDataViewModel : ObservableObject, IAnimationHandler
         OnPropertyChanged(nameof(OnionOpacityBindable));
     }
 
-    public void SetFrameLength(Guid keyFrameId, int newStartFrame, int newDuration)
+    public void SetCelLength(Guid keyFrameId, int newStartFrame, int newDuration)
     {
         if (TryFindCels(keyFrameId, out CelViewModel keyFrame))
         {

+ 6 - 3
src/PixiEditor/ViewModels/SubViewModels/ClipboardViewModel.cs

@@ -222,14 +222,17 @@ internal class ClipboardViewModel : SubViewModel<ViewModelMain>
         foreach (var celId in cels)
         {
             ICelHandler cel = doc.AnimationDataViewModel.AllCels.First(x => x.Id == celId);
-            Guid? newCel = doc.AnimationDataViewModel.CreateCel(cel.LayerGuid, doc.AnimationDataViewModel.ActiveFrameBindable + i, cel.LayerGuid,
+            int celFrame = doc.AnimationDataViewModel.ActiveFrameBindable + i;
+            Guid? newCel = doc.AnimationDataViewModel.CreateCel(cel.LayerGuid,
+                doc.AnimationDataViewModel.ActiveFrameBindable + i, cel.LayerGuid,
                 cel.StartFrameBindable);
             if (newCel != null)
             {
+                int duration = cel.DurationBindable;
+                doc.Operations.ChangeCelLength(newCel.Value, celFrame, duration);
                 newCels.Add(newCel.Value);
+                i += duration;
             }
-
-            i++;
         }
 
         doc.Operations.InvokeCustomAction(() =>