mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 20:22:55 +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()
|
||||
{
|
||||
ChangeHandler?.BeginChange();
|
||||
|
||||
foreach (var h in selectedBlueprints.ToList())
|
||||
EditorBeatmap?.Remove(h.HitObject);
|
||||
|
||||
EditorBeatmap?.RemoveRange(selectedBlueprints.Select(b => b.HitObject));
|
||||
ChangeHandler?.EndChange();
|
||||
}
|
||||
|
||||
|
@ -484,8 +484,7 @@ namespace osu.Game.Screens.Edit
|
||||
protected void Cut()
|
||||
{
|
||||
Copy();
|
||||
foreach (var h in editorBeatmap.SelectedHitObjects.ToArray())
|
||||
editorBeatmap.Remove(h);
|
||||
editorBeatmap.RemoveRange(editorBeatmap.SelectedHitObjects.ToArray());
|
||||
}
|
||||
|
||||
protected void Copy()
|
||||
|
@ -99,8 +99,11 @@ namespace osu.Game.Screens.Edit
|
||||
/// <param name="hitObjects">The <see cref="HitObject"/>s to add.</param>
|
||||
public void AddRange(IEnumerable<HitObject> hitObjects)
|
||||
{
|
||||
foreach (var h in hitObjects)
|
||||
Add(h);
|
||||
ApplyBatchChanges(_ =>
|
||||
{
|
||||
foreach (var h in hitObjects)
|
||||
Add(h);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -166,6 +169,19 @@ namespace osu.Game.Screens.Edit
|
||||
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>
|
||||
/// Finds the index of a <see cref="HitObject"/> in this <see cref="EditorBeatmap"/>.
|
||||
/// </summary>
|
||||
@ -237,18 +253,12 @@ namespace osu.Game.Screens.Edit
|
||||
}
|
||||
|
||||
batchPendingInserts.Clear();
|
||||
|
||||
isBatchApplying = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears all <see cref="HitObjects"/> from this <see cref="EditorBeatmap"/>.
|
||||
/// </summary>
|
||||
public void Clear()
|
||||
{
|
||||
foreach (var h in HitObjects.ToArray())
|
||||
Remove(h);
|
||||
}
|
||||
public void Clear() => RemoveRange(HitObjects.ToArray());
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user