Merge branch 'no-auto-gen' into editor-timing-screen

This commit is contained in:
Dean Herbert 2019-10-27 12:36:21 +09:00
commit acc0251124
1 changed files with 34 additions and 1 deletions

View File

@ -184,7 +184,7 @@ private T binarySearch<T>(IReadOnlyList<T> list, double time)
public void Add(double time, ControlPoint newPoint, bool force = false)
{
if (!force && SimilarPointAt(time, newPoint)?.EquivalentTo(newPoint) == true)
if (!force && checkAlreadyExisting(time, newPoint))
return;
GroupAt(time, true).Add(newPoint);
@ -209,6 +209,39 @@ public ControlPointGroup GroupAt(double time, bool createIfNotExisting = false)
return null;
}
/// <summary>
/// Check whether <see cref="newPoint"/> should be added.
/// </summary>
/// <param name="time">The time to find the timing control point at.</param>
/// <param name="newPoint">A point to be added.</param>
/// <returns>Whether the new point should be added.</returns>
private bool checkAlreadyExisting(double time, ControlPoint newPoint)
{
ControlPoint existing = null;
switch (newPoint)
{
case TimingControlPoint _:
// Timing points are a special case and need to be added regardless of fallback availability.
existing = binarySearch(TimingPoints, time);
break;
case EffectControlPoint _:
existing = EffectPointAt(time);
break;
case SampleControlPoint _:
existing = SamplePointAt(time);
break;
case DifficultyControlPoint _:
existing = DifficultyPointAt(time);
break;
}
return existing?.EquivalentTo(newPoint) == true;
}
private void groupItemRemoved(ControlPoint obj)
{
switch (obj)