Add a very simple method of applying batch changes to EditorBeatmap

This commit is contained in:
Dean Herbert
2020-10-06 21:21:09 +09:00
parent fa65e14455
commit 14c734c244
2 changed files with 73 additions and 17 deletions

View File

@ -68,16 +68,19 @@ namespace osu.Game.Screens.Edit
toRemove.Sort();
toAdd.Sort();
// Apply the changes.
for (int i = toRemove.Count - 1; i >= 0; i--)
editorBeatmap.RemoveAt(toRemove[i]);
if (toAdd.Count > 0)
editorBeatmap.ApplyBatchChanges(eb =>
{
IBeatmap newBeatmap = readBeatmap(newState);
foreach (var i in toAdd)
editorBeatmap.Insert(i, newBeatmap.HitObjects[i]);
}
// Apply the changes.
for (int i = toRemove.Count - 1; i >= 0; i--)
eb.RemoveAt(toRemove[i]);
if (toAdd.Count > 0)
{
IBeatmap newBeatmap = readBeatmap(newState);
foreach (var i in toAdd)
eb.Insert(i, newBeatmap.HitObjects[i]);
}
});
}
private string readString(byte[] state) => Encoding.UTF8.GetString(state);