mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 08:22:56 +08:00
Use batch change application in many places that can benefit from it
This commit is contained in:
parent
14c734c244
commit
09f5e9c9eb
@ -239,10 +239,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
private void deleteSelected()
|
private void deleteSelected()
|
||||||
{
|
{
|
||||||
ChangeHandler?.BeginChange();
|
ChangeHandler?.BeginChange();
|
||||||
|
EditorBeatmap?.RemoveRange(selectedBlueprints.Select(b => b.HitObject));
|
||||||
foreach (var h in selectedBlueprints.ToList())
|
|
||||||
EditorBeatmap?.Remove(h.HitObject);
|
|
||||||
|
|
||||||
ChangeHandler?.EndChange();
|
ChangeHandler?.EndChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,8 +484,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
protected void Cut()
|
protected void Cut()
|
||||||
{
|
{
|
||||||
Copy();
|
Copy();
|
||||||
foreach (var h in editorBeatmap.SelectedHitObjects.ToArray())
|
editorBeatmap.RemoveRange(editorBeatmap.SelectedHitObjects.ToArray());
|
||||||
editorBeatmap.Remove(h);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void Copy()
|
protected void Copy()
|
||||||
|
@ -99,8 +99,11 @@ namespace osu.Game.Screens.Edit
|
|||||||
/// <param name="hitObjects">The <see cref="HitObject"/>s to add.</param>
|
/// <param name="hitObjects">The <see cref="HitObject"/>s to add.</param>
|
||||||
public void AddRange(IEnumerable<HitObject> hitObjects)
|
public void AddRange(IEnumerable<HitObject> hitObjects)
|
||||||
{
|
{
|
||||||
foreach (var h in hitObjects)
|
ApplyBatchChanges(_ =>
|
||||||
Add(h);
|
{
|
||||||
|
foreach (var h in hitObjects)
|
||||||
|
Add(h);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -166,6 +169,19 @@ namespace osu.Game.Screens.Edit
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Removes a collection of <see cref="HitObject"/>s to this <see cref="EditorBeatmap"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hitObjects">The <see cref="HitObject"/>s to remove.</param>
|
||||||
|
public void RemoveRange(IEnumerable<HitObject> hitObjects)
|
||||||
|
{
|
||||||
|
ApplyBatchChanges(_ =>
|
||||||
|
{
|
||||||
|
foreach (var h in hitObjects)
|
||||||
|
Remove(h);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Finds the index of a <see cref="HitObject"/> in this <see cref="EditorBeatmap"/>.
|
/// Finds the index of a <see cref="HitObject"/> in this <see cref="EditorBeatmap"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -237,18 +253,12 @@ namespace osu.Game.Screens.Edit
|
|||||||
}
|
}
|
||||||
|
|
||||||
batchPendingInserts.Clear();
|
batchPendingInserts.Clear();
|
||||||
|
|
||||||
isBatchApplying = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Clears all <see cref="HitObjects"/> from this <see cref="EditorBeatmap"/>.
|
/// Clears all <see cref="HitObjects"/> from this <see cref="EditorBeatmap"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Clear()
|
public void Clear() => RemoveRange(HitObjects.ToArray());
|
||||||
{
|
|
||||||
foreach (var h in HitObjects.ToArray())
|
|
||||||
Remove(h);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user