Add progress for deleting all maps

This commit is contained in:
Dean Herbert 2017-07-31 18:52:59 +09:00
parent bc8f8de049
commit f67822a59b
2 changed files with 31 additions and 5 deletions

View File

@ -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;
}
}
}

View File

@ -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));
}
},
};