Implement collection import

This commit is contained in:
smoogipoo
2020-09-03 00:08:33 +09:00
parent 39c304d008
commit a56f9d6770
4 changed files with 99 additions and 41 deletions

View File

@ -6,6 +6,7 @@ using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Beatmaps;
using osu.Game.Collections;
using osu.Game.Graphics.UserInterface;
using osu.Game.Scoring;
using osu.Game.Skinning;
@ -19,6 +20,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
private TriangleButton importBeatmapsButton;
private TriangleButton importScoresButton;
private TriangleButton importSkinsButton;
private TriangleButton importCollectionsButton;
private TriangleButton deleteBeatmapsButton;
private TriangleButton deleteScoresButton;
private TriangleButton deleteSkinsButton;
@ -26,7 +28,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
private TriangleButton undeleteButton;
[BackgroundDependencyLoader]
private void load(BeatmapManager beatmaps, ScoreManager scores, SkinManager skins, DialogOverlay dialogOverlay)
private void load(BeatmapManager beatmaps, ScoreManager scores, SkinManager skins, CollectionManager collections, DialogOverlay dialogOverlay)
{
if (beatmaps.SupportsImportFromStable)
{
@ -93,20 +95,43 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
});
}
AddRange(new Drawable[]
Add(deleteSkinsButton = new DangerousSettingsButton
{
deleteSkinsButton = new DangerousSettingsButton
Text = "Delete ALL skins",
Action = () =>
{
Text = "Delete ALL skins",
dialogOverlay?.Push(new DeleteAllBeatmapsDialog(() =>
{
deleteSkinsButton.Enabled.Value = false;
Task.Run(() => skins.Delete(skins.GetAllUserSkins())).ContinueWith(t => Schedule(() => deleteSkinsButton.Enabled.Value = true));
}));
}
});
if (collections.SupportsImportFromStable)
{
Add(importCollectionsButton = new SettingsButton
{
Text = "Import collections from stable",
Action = () =>
{
dialogOverlay?.Push(new DeleteAllBeatmapsDialog(() =>
{
deleteSkinsButton.Enabled.Value = false;
Task.Run(() => skins.Delete(skins.GetAllUserSkins())).ContinueWith(t => Schedule(() => deleteSkinsButton.Enabled.Value = true));
}));
importCollectionsButton.Enabled.Value = false;
collections.ImportFromStableAsync().ContinueWith(t => Schedule(() => importCollectionsButton.Enabled.Value = true));
}
},
});
}
Add(new DangerousSettingsButton
{
Text = "Delete ALL collections",
Action = () =>
{
dialogOverlay?.Push(new DeleteAllBeatmapsDialog(() => collections.Collections.Clear()));
}
});
AddRange(new Drawable[]
{
restoreButton = new SettingsButton
{
Text = "Restore all hidden difficulties",