diff --git a/OngekiFumenEditor/Base/Collections/SoflanList_CachedPositionList.cs b/OngekiFumenEditor/Base/Collections/SoflanList_CachedPositionList.cs index 243c8970..9034b3eb 100644 --- a/OngekiFumenEditor/Base/Collections/SoflanList_CachedPositionList.cs +++ b/OngekiFumenEditor/Base/Collections/SoflanList_CachedPositionList.cs @@ -54,7 +54,7 @@ public enum ChgEvt public IEnumerable<(TGrid TGrid, double speed, BPMChange curBpm, ChgEvt)> GetCalculatableEvents(BpmList bpmList, bool isDesignModel) { var curBpm = bpmList.FirstBpm; - KeyframeSoflan curSpeedEvent = null; + IKeyframeSoflan curSpeedEvent = null; IEnumerable<(TGrid TGrid, double speed, BPMChange curBpm, ChgEvt evt)> GetEventTimings(ITimelineObject evt) { @@ -66,17 +66,34 @@ public enum ChgEvt var speed = (curSpeedEvent is not null && curSpeedEvent.EndTGrid > t) ? (isDesignModel ? curSpeedEvent.SpeedInEditor : curSpeedEvent.Speed) : 1.0d; yield return (evt.TGrid, speed, curBpm, ChgEvt.BpmChanged); break; - case KeyframeSoflan soflanEvt: + case IKeyframeSoflan soflanEvt: curSpeedEvent = soflanEvt; yield return (evt.TGrid, (isDesignModel ? soflanEvt.SpeedInEditor : soflanEvt.Speed), curBpm, ChgEvt.SoflanChanged); break; + case IDurationSoflan durationEvt: + var itor = durationEvt.GenerateKeyframeSoflans().GetEnumerator(); + if (itor.MoveNext()) + { + curSpeedEvent = itor.Current; + yield return (itor.Current.TGrid, (isDesignModel ? itor.Current.SpeedInEditor : itor.Current.Speed), curBpm, ChgEvt.SoflanBegan); + if (itor.MoveNext()) + { + var prev = itor.Current; + while (itor.MoveNext()) + { + //process prev + yield return (itor.Current.TGrid, (isDesignModel ? itor.Current.SpeedInEditor : itor.Current.Speed), curBpm, ChgEvt.SoflanChanged); + //set prev + prev = itor.Current; + } + curSpeedEvent = itor.Current; + yield return (itor.Current.TGrid, (isDesignModel ? itor.Current.SpeedInEditor : itor.Current.Speed), curBpm, ChgEvt.SoflanEnded); + } + } + break; } } - var r = this.SelectMany(x => x switch - { - IKeyframeSoflan t => Enumerable.Repeat(x, 1), - IDurationSoflan t => t.GenerateKeyframeSoflans() - }) + var r = this .FilterNull() .AsEnumerable() .Concat(bpmList) diff --git a/OngekiFumenEditor/Base/ISoflan.cs b/OngekiFumenEditor/Base/ISoflan.cs index fe783b7d..b7696bc5 100644 --- a/OngekiFumenEditor/Base/ISoflan.cs +++ b/OngekiFumenEditor/Base/ISoflan.cs @@ -12,6 +12,8 @@ public interface ISoflan : ITimelineObject, INotifyPropertyChanged, IDisplayable float Speed { get; set; } bool ApplySpeedInDesignMode { get; set; } + public float SpeedInEditor => ApplySpeedInDesignMode ? Speed : Math.Abs(Speed); + TGrid EndTGrid { get; set; } // 考虑到SoflanList的间隔树使用 } }