mirror of
https://github.com/ppy/osu
synced 2025-01-19 04:20:59 +00:00
Add progress for deleting all maps
This commit is contained in:
parent
bc8f8de049
commit
f67822a59b
@ -459,5 +459,35 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
Import(Directory.GetDirectories(stableInstallPath));
|
||||
}
|
||||
|
||||
public void DeleteAll()
|
||||
{
|
||||
var maps = GetAllUsableBeatmapSets().ToArray();
|
||||
|
||||
if (maps.Length == 0) return;
|
||||
|
||||
var notification = new ProgressNotification
|
||||
{
|
||||
Progress = 0,
|
||||
State = ProgressNotificationState.Active,
|
||||
};
|
||||
|
||||
PostNotification?.Invoke(notification);
|
||||
|
||||
int i = 0;
|
||||
|
||||
foreach (var b in maps)
|
||||
{
|
||||
if (notification.State == ProgressNotificationState.Cancelled)
|
||||
// user requested abort
|
||||
return;
|
||||
|
||||
notification.Text = $"Deleting ({i} of {maps.Length})";
|
||||
notification.Progress = (float)++i / maps.Length;
|
||||
Delete(b);
|
||||
}
|
||||
|
||||
notification.State = ProgressNotificationState.Completed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,11 +38,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
||||
Action = () =>
|
||||
{
|
||||
deleteButton.Enabled.Value = false;
|
||||
Task.Run(() =>
|
||||
{
|
||||
foreach (var b in beatmaps.GetAllUsableBeatmapSets())
|
||||
beatmaps.Delete(b);
|
||||
}).ContinueWith(t => Schedule(() => deleteButton.Enabled.Value = true));
|
||||
Task.Run(() => beatmaps.DeleteAll()).ContinueWith(t => Schedule(() => deleteButton.Enabled.Value = true));
|
||||
}
|
||||
},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user