Add legacy beatmap diffing

This commit is contained in:
smoogipoo
2020-04-09 20:48:59 +09:00
parent e58bf8a0d0
commit 86243d463f
3 changed files with 488 additions and 4 deletions

View File

@ -107,6 +107,16 @@ namespace osu.Game.Screens.Edit
private IList mutableHitObjects => (IList)PlayableBeatmap.HitObjects;
/// <summary>
/// Adds a collection of <see cref="HitObject"/>s to this <see cref="EditorBeatmap"/>.
/// </summary>
/// <param name="hitObjects">The <see cref="HitObject"/>s to add.</param>
public void AddRange(IEnumerable<HitObject> hitObjects)
{
foreach (var h in hitObjects)
Add(h);
}
/// <summary>
/// Adds a <see cref="HitObject"/> to this <see cref="EditorBeatmap"/>.
/// </summary>
@ -128,12 +138,34 @@ namespace osu.Game.Screens.Edit
/// Removes a <see cref="HitObject"/> from this <see cref="EditorBeatmap"/>.
/// </summary>
/// <param name="hitObject">The <see cref="HitObject"/> to add.</param>
public void Remove(HitObject hitObject)
/// <returns>True if the <see cref="HitObject"/> has been removed, false otherwise.</returns>
public bool Remove(HitObject hitObject)
{
if (!mutableHitObjects.Contains(hitObject))
return;
int index = FindIndex(hitObject);
mutableHitObjects.Remove(hitObject);
if (index == -1)
return false;
RemoveAt(index);
return true;
}
/// <summary>
/// Finds the index of a <see cref="HitObject"/> in this <see cref="EditorBeatmap"/>.
/// </summary>
/// <param name="hitObject">The <see cref="HitObject"/> to search for.</param>
/// <returns>The index of <paramref name="hitObject"/>.</returns>
public int FindIndex(HitObject hitObject) => mutableHitObjects.IndexOf(hitObject);
/// <summary>
/// Removes a <see cref="HitObject"/> at an index in this <see cref="EditorBeatmap"/>.
/// </summary>
/// <param name="index">The index of the <see cref="HitObject"/> to remove.</param>
public void RemoveAt(int index)
{
var hitObject = (HitObject)mutableHitObjects[index];
mutableHitObjects.RemoveAt(index);
var bindable = startTimeBindables[hitObject];
bindable.UnbindAll();