2022-06-22 04:02:33 +00:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
2019-01-24 08:43:03 +00:00
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-07-28 03:46:38 +00:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
2021-07-15 03:50:34 +00:00
|
|
|
|
using osu.Framework.Localisation;
|
2017-07-28 03:46:38 +00:00
|
|
|
|
using osu.Game.Beatmaps;
|
2021-05-09 15:12:58 +00:00
|
|
|
|
using osu.Game.Database;
|
2021-08-12 04:26:42 +00:00
|
|
|
|
using osu.Game.Localisation;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-07-28 03:46:38 +00:00
|
|
|
|
namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
|
|
|
|
{
|
2022-06-21 22:00:03 +00:00
|
|
|
|
public class BeatmapSettings : SettingsSubsection
|
2017-07-28 03:46:38 +00:00
|
|
|
|
{
|
2022-06-21 22:00:03 +00:00
|
|
|
|
protected override LocalisableString Header => "Beatmaps";
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2022-06-22 04:07:44 +00:00
|
|
|
|
private SettingsButton importBeatmapsButton = null!;
|
|
|
|
|
private SettingsButton deleteBeatmapsButton = null!;
|
|
|
|
|
private SettingsButton deleteBeatmapVideosButton = null!;
|
|
|
|
|
private SettingsButton restoreButton = null!;
|
|
|
|
|
private SettingsButton undeleteButton = null!;
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(BeatmapManager beatmaps, LegacyImportManager? legacyImportManager, IDialogOverlay? dialogOverlay)
|
2017-07-28 03:46:38 +00:00
|
|
|
|
{
|
2021-11-25 08:12:15 +00:00
|
|
|
|
if (legacyImportManager?.SupportsImportFromStable == true)
|
2017-07-28 03:46:38 +00:00
|
|
|
|
{
|
2019-02-28 04:09:38 +00:00
|
|
|
|
Add(importBeatmapsButton = new SettingsButton
|
2017-07-28 03:46:38 +00:00
|
|
|
|
{
|
2021-08-12 04:26:42 +00:00
|
|
|
|
Text = MaintenanceSettingsStrings.ImportBeatmapsFromStable,
|
2017-07-28 03:46:38 +00:00
|
|
|
|
Action = () =>
|
|
|
|
|
{
|
2018-09-21 12:08:21 +00:00
|
|
|
|
importBeatmapsButton.Enabled.Value = false;
|
2022-06-24 12:25:23 +00:00
|
|
|
|
legacyImportManager.ImportFromStableAsync(StableContent.Beatmaps).ContinueWith(_ => Schedule(() => importBeatmapsButton.Enabled.Value = true));
|
2017-07-28 03:46:38 +00:00
|
|
|
|
}
|
2019-02-28 04:09:38 +00:00
|
|
|
|
});
|
2022-06-22 04:13:04 +00:00
|
|
|
|
}
|
2022-06-21 22:41:25 +00:00
|
|
|
|
|
2022-06-22 04:13:04 +00:00
|
|
|
|
Add(deleteBeatmapsButton = new DangerousSettingsButton
|
|
|
|
|
{
|
|
|
|
|
Text = MaintenanceSettingsStrings.DeleteAllBeatmaps,
|
|
|
|
|
Action = () =>
|
2022-06-21 22:00:03 +00:00
|
|
|
|
{
|
2022-06-22 04:13:04 +00:00
|
|
|
|
dialogOverlay?.Push(new MassDeleteConfirmationDialog(() =>
|
2022-06-21 22:00:03 +00:00
|
|
|
|
{
|
2022-06-22 04:13:04 +00:00
|
|
|
|
deleteBeatmapsButton.Enabled.Value = false;
|
2022-06-24 12:25:23 +00:00
|
|
|
|
Task.Run(() => beatmaps.Delete()).ContinueWith(_ => Schedule(() => deleteBeatmapsButton.Enabled.Value = true));
|
2022-06-22 04:13:04 +00:00
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
});
|
2019-02-28 04:09:38 +00:00
|
|
|
|
|
2022-06-22 04:13:04 +00:00
|
|
|
|
Add(deleteBeatmapVideosButton = new DangerousSettingsButton
|
|
|
|
|
{
|
|
|
|
|
Text = MaintenanceSettingsStrings.DeleteAllBeatmapVideos,
|
|
|
|
|
Action = () =>
|
|
|
|
|
{
|
|
|
|
|
dialogOverlay?.Push(new MassVideoDeleteConfirmationDialog(() =>
|
|
|
|
|
{
|
|
|
|
|
deleteBeatmapVideosButton.Enabled.Value = false;
|
2022-06-24 12:25:23 +00:00
|
|
|
|
Task.Run(beatmaps.DeleteAllVideos).ContinueWith(_ => Schedule(() => deleteBeatmapVideosButton.Enabled.Value = true));
|
2022-06-22 04:13:04 +00:00
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
AddRange(new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
restoreButton = new SettingsButton
|
2022-05-18 06:09:58 +00:00
|
|
|
|
{
|
2022-06-22 04:13:04 +00:00
|
|
|
|
Text = MaintenanceSettingsStrings.RestoreAllHiddenDifficulties,
|
2017-09-01 09:26:01 +00:00
|
|
|
|
Action = () =>
|
|
|
|
|
{
|
2022-06-22 04:13:04 +00:00
|
|
|
|
restoreButton.Enabled.Value = false;
|
2022-06-24 12:25:23 +00:00
|
|
|
|
Task.Run(beatmaps.RestoreAll).ContinueWith(_ => Schedule(() => restoreButton.Enabled.Value = true));
|
2017-09-01 09:26:01 +00:00
|
|
|
|
}
|
2022-06-22 04:13:04 +00:00
|
|
|
|
},
|
|
|
|
|
undeleteButton = new SettingsButton
|
2017-11-30 09:58:32 +00:00
|
|
|
|
{
|
2022-06-22 04:13:04 +00:00
|
|
|
|
Text = MaintenanceSettingsStrings.RestoreAllRecentlyDeletedBeatmaps,
|
|
|
|
|
Action = () =>
|
2017-11-30 09:58:32 +00:00
|
|
|
|
{
|
2022-06-22 04:13:04 +00:00
|
|
|
|
undeleteButton.Enabled.Value = false;
|
2022-06-24 12:25:23 +00:00
|
|
|
|
Task.Run(beatmaps.UndeleteAll).ContinueWith(_ => Schedule(() => undeleteButton.Enabled.Value = true));
|
2017-11-30 09:58:32 +00:00
|
|
|
|
}
|
2022-06-22 04:13:04 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
2017-07-28 03:46:38 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|