mirror of
https://github.com/ppy/osu.git
synced 2025-02-20 20:33:21 +08:00
Perform a single Save
call rather than doing it in each difficulty
This commit is contained in:
parent
311f0947e4
commit
489d7a30ec
@ -107,9 +107,6 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
|
||||
AddStep("test play", () => Editor.TestGameplay());
|
||||
|
||||
AddUntilStep("wait for dialog", () => DialogOverlay.CurrentDialog != null);
|
||||
AddStep("confirm save", () => InputManager.Key(Key.Number1));
|
||||
|
||||
AddUntilStep("wait for return to editor", () => Editor.IsCurrentScreen());
|
||||
|
||||
AddAssert("track is still not virtual", () => Beatmap.Value.Track is not TrackVirtual);
|
||||
|
@ -32,9 +32,6 @@ namespace osu.Game.Screens.Edit.Setup
|
||||
[Resolved]
|
||||
private IBindable<WorkingBeatmap> working { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private EditorBeatmap editorBeatmap { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private Editor? editor { get; set; }
|
||||
|
||||
@ -114,25 +111,17 @@ namespace osu.Game.Screens.Edit.Setup
|
||||
{
|
||||
newFilename = $"{baseFilename}{source.Extension}";
|
||||
|
||||
foreach (var beatmapInSet in set.Beatmaps)
|
||||
foreach (var beatmap in set.Beatmaps)
|
||||
{
|
||||
string filenameInBeatmap = readFilename(beatmapInSet.Metadata);
|
||||
if (set.GetFile(readFilename(beatmap.Metadata)) is RealmNamedFileUsage otherExistingFile)
|
||||
beatmaps.DeleteFile(set, otherExistingFile);
|
||||
|
||||
if (set.GetFile(filenameInBeatmap) is RealmNamedFileUsage existingFile)
|
||||
beatmaps.DeleteFile(set, existingFile);
|
||||
|
||||
if (filenameInBeatmap != newFilename)
|
||||
{
|
||||
writeFilename(beatmapInSet.Metadata, newFilename);
|
||||
|
||||
if (!beatmapInSet.Equals(working.Value.BeatmapInfo))
|
||||
beatmaps.Save(beatmapInSet, beatmaps.GetWorkingBeatmap(beatmapInSet).Beatmap);
|
||||
}
|
||||
writeFilename(beatmap.Metadata, newFilename);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var beatmap = working.Value.BeatmapInfo;
|
||||
var thisBeatmap = working.Value.BeatmapInfo;
|
||||
|
||||
string[] filenames = set.Files.Select(f => f.Filename).Where(f =>
|
||||
f.StartsWith(baseFilename, StringComparison.OrdinalIgnoreCase) &&
|
||||
@ -142,7 +131,7 @@ namespace osu.Game.Screens.Edit.Setup
|
||||
|
||||
var oldFile = set.GetFile(currentFilename);
|
||||
|
||||
if (oldFile != null && set.Beatmaps.Where(b => !b.Equals(beatmap)).All(b => readFilename(b.Metadata) != currentFilename))
|
||||
if (oldFile != null && set.Beatmaps.Where(b => !b.Equals(thisBeatmap)).All(b => readFilename(b.Metadata) != currentFilename))
|
||||
{
|
||||
beatmaps.DeleteFile(set, oldFile);
|
||||
newFilename = currentFilename;
|
||||
@ -157,7 +146,9 @@ namespace osu.Game.Screens.Edit.Setup
|
||||
using (var stream = source.OpenRead())
|
||||
beatmaps.AddFile(set, stream, newFilename);
|
||||
|
||||
editorBeatmap.SaveState();
|
||||
// editor change handler cannot be aware of any file changes or other difficulties having their metadata modified.
|
||||
// for simplicity's sake, trigger a save when changing any resource to ensure the change is correctly saved.
|
||||
editor?.Save();
|
||||
}
|
||||
|
||||
private void backgroundChanged(ValueChangedEvent<FileInfo?> file)
|
||||
|
Loading…
Reference in New Issue
Block a user