mirror of
https://github.com/osukey/osukey.git
synced 2025-05-10 08:07:18 +09:00
Moved "undelete all" logic to BeatmapManager and added a progress notification
This commit is contained in:
parent
4c45102d61
commit
d2b80fdbfc
@ -339,6 +339,36 @@ namespace osu.Game.Beatmaps
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void UndeleteAll()
|
||||||
|
{
|
||||||
|
var mapSets = QueryBeatmapSets(bs => bs.DeletePending);
|
||||||
|
|
||||||
|
if (mapSets.Count() == 0) return;
|
||||||
|
|
||||||
|
var notification = new ProgressNotification
|
||||||
|
{
|
||||||
|
Progress = 0,
|
||||||
|
State = ProgressNotificationState.Active,
|
||||||
|
};
|
||||||
|
|
||||||
|
PostNotification?.Invoke(notification);
|
||||||
|
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
|
foreach (var bs in mapSets)
|
||||||
|
{
|
||||||
|
if (notification.State == ProgressNotificationState.Cancelled)
|
||||||
|
// user requested abort
|
||||||
|
return;
|
||||||
|
|
||||||
|
notification.Text = $"Restoring ({i} of {mapSets.Count()})";
|
||||||
|
notification.Progress = (float)++i / mapSets.Count();
|
||||||
|
Undelete(bs);
|
||||||
|
}
|
||||||
|
|
||||||
|
notification.State = ProgressNotificationState.Completed;
|
||||||
|
}
|
||||||
|
|
||||||
public void Undelete(BeatmapSetInfo beatmapSet)
|
public void Undelete(BeatmapSetInfo beatmapSet)
|
||||||
{
|
{
|
||||||
if (beatmapSet.Protected)
|
if (beatmapSet.Protected)
|
||||||
|
@ -62,11 +62,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
|||||||
Action = () =>
|
Action = () =>
|
||||||
{
|
{
|
||||||
undeleteButton.Enabled.Value = false;
|
undeleteButton.Enabled.Value = false;
|
||||||
Task.Run(() =>
|
Task.Run(() => beatmaps.UndeleteAll()).ContinueWith(t => Schedule(() => undeleteButton.Enabled.Value = true));
|
||||||
{
|
|
||||||
foreach (var bs in beatmaps.QueryBeatmapSets(bs => bs.DeletePending).ToList())
|
|
||||||
beatmaps.Undelete(bs);
|
|
||||||
}).ContinueWith(t => Schedule(() => undeleteButton.Enabled.Value = true));
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user