1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 19:12:57 +08:00

Added a new "undelete" button that restores every beatmap with "DeletePending" set to true.

This commit is contained in:
FreezyLemon 2017-11-30 10:58:32 +01:00
parent dddd432dc8
commit bf386598b6
2 changed files with 36 additions and 0 deletions

View File

@ -338,6 +338,28 @@ namespace osu.Game.Beatmaps
}
}
public void Undelete(BeatmapSetInfo beatmapSet)
{
lock (importContext)
{
var context = importContext.Value;
using (var transaction = context.BeginTransaction())
{
context.ChangeTracker.AutoDetectChangesEnabled = false;
var iFiles = new FileStore(() => context, storage);
var iBeatmaps = createBeatmapStore(() => context);
if (iBeatmaps.Undelete(beatmapSet))
iFiles.Reference(beatmapSet.Files.Select(f => f.FileInfo).ToArray());
context.ChangeTracker.AutoDetectChangesEnabled = true;
context.SaveChanges(transaction);
}
}
}
/// <summary>
/// Delete a beatmap difficulty.
/// </summary>

View File

@ -15,6 +15,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
private TriangleButton importButton;
private TriangleButton deleteButton;
private TriangleButton restoreButton;
private TriangleButton undeleteButton;
protected override string Header => "General";
@ -55,6 +56,19 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
}).ContinueWith(t => Schedule(() => restoreButton.Enabled.Value = true));
}
},
undeleteButton = new SettingsButton
{
Text = "Restore all recently deleted beatmaps",
Action = () =>
{
undeleteButton.Enabled.Value = false;
Task.Run(() =>
{
foreach (var bs in beatmaps.QueryBeatmapSets(bs => bs.DeletePending).ToList())
beatmaps.Undelete(bs);
}).ContinueWith(t => Schedule(() => undeleteButton.Enabled.Value = true));
}
},
};
}
}