Skip to content

Commit

Permalink
fix GetCalculatableEvents() process wrong soflan changes
Browse files Browse the repository at this point in the history
  • Loading branch information
MikiraSora committed Dec 28, 2023
1 parent a6a5c6d commit 38a45e3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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<ITimelineObject>()
.Concat(bpmList)
Expand Down
2 changes: 2 additions & 0 deletions OngekiFumenEditor/Base/ISoflan.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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的间隔树使用
}
}

0 comments on commit 38a45e3

Please sign in to comment.