1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 09:07:25 +08:00
osu-lazer/osu.Game/Overlays/Settings/Sections/Maintenance/BeatmapSettings.cs

91 lines
3.9 KiB
C#
Raw Normal View History

2022-06-22 12:02:33 +08:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2018-04-13 17:19:50 +08:00
2022-06-17 15:37:17 +08:00
#nullable disable
2018-04-13 17:19:50 +08:00
using System.Threading.Tasks;
2020-09-09 15:33:48 +08:00
using JetBrains.Annotations;
2018-04-13 17:19:50 +08:00
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
2018-04-13 17:19:50 +08:00
using osu.Game.Beatmaps;
2021-05-09 23:12:58 +08:00
using osu.Game.Database;
using osu.Game.Localisation;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Overlays.Settings.Sections.Maintenance
{
public class BeatmapSettings : SettingsSubsection
2018-04-13 17:19:50 +08:00
{
protected override LocalisableString Header => "Beatmaps";
2021-10-11 02:32:56 +08:00
private SettingsButton importBeatmapsButton;
private SettingsButton deleteBeatmapsButton;
private SettingsButton deleteBeatmapVideosButton;
2021-10-11 02:32:56 +08:00
private SettingsButton restoreButton;
private SettingsButton undeleteButton;
2018-04-13 17:19:50 +08:00
2020-09-09 15:33:48 +08:00
[BackgroundDependencyLoader(permitNulls: true)]
2022-06-22 06:41:25 +08:00
private void load(BeatmapManager beatmaps, [CanBeNull] LegacyImportManager legacyImportManager, IDialogOverlay dialogOverlay)
2018-04-13 17:19:50 +08:00
{
2021-11-25 16:12:15 +08:00
if (legacyImportManager?.SupportsImportFromStable == true)
2018-04-13 17:19:50 +08:00
{
Add(importBeatmapsButton = new SettingsButton
2018-04-13 17:19:50 +08:00
{
Text = MaintenanceSettingsStrings.ImportBeatmapsFromStable,
2018-04-13 17:19:50 +08:00
Action = () =>
{
importBeatmapsButton.Enabled.Value = false;
2021-11-25 16:12:15 +08:00
legacyImportManager.ImportFromStableAsync(StableContent.Beatmaps).ContinueWith(t => Schedule(() => importBeatmapsButton.Enabled.Value = true));
2018-04-13 17:19:50 +08:00
}
});
2022-06-22 06:41:25 +08:00
Add(deleteBeatmapsButton = new DangerousSettingsButton
{
2022-06-22 06:41:25 +08:00
Text = MaintenanceSettingsStrings.DeleteAllBeatmaps,
Action = () =>
{
2022-06-22 06:41:25 +08:00
dialogOverlay?.Push(new MassDeleteConfirmationDialog(() =>
{
deleteBeatmapsButton.Enabled.Value = false;
Task.Run(() => beatmaps.Delete()).ContinueWith(t => Schedule(() => deleteBeatmapsButton.Enabled.Value = true));
}));
}
});
2022-06-22 06:41:25 +08:00
Add(deleteBeatmapVideosButton = new DangerousSettingsButton
{
2022-06-22 06:41:25 +08:00
Text = MaintenanceSettingsStrings.DeleteAllBeatmapVideos,
2018-04-13 17:19:50 +08:00
Action = () =>
{
2022-06-22 06:41:25 +08:00
dialogOverlay?.Push(new MassVideoDeleteConfirmationDialog(() =>
{
deleteBeatmapVideosButton.Enabled.Value = false;
Task.Run(beatmaps.DeleteAllVideos).ContinueWith(t => Schedule(() => deleteBeatmapVideosButton.Enabled.Value = true));
}));
2018-04-13 17:19:50 +08:00
}
2022-06-22 06:41:25 +08:00
});
AddRange(new Drawable[]
2018-04-13 17:19:50 +08:00
{
2022-06-22 06:41:25 +08:00
restoreButton = new SettingsButton
{
Text = MaintenanceSettingsStrings.RestoreAllHiddenDifficulties,
Action = () =>
{
restoreButton.Enabled.Value = false;
Task.Run(beatmaps.RestoreAll).ContinueWith(t => Schedule(() => restoreButton.Enabled.Value = true));
}
},
undeleteButton = new SettingsButton
2018-04-13 17:19:50 +08:00
{
2022-06-22 06:41:25 +08:00
Text = MaintenanceSettingsStrings.RestoreAllRecentlyDeletedBeatmaps,
Action = () =>
{
undeleteButton.Enabled.Value = false;
Task.Run(beatmaps.UndeleteAll).ContinueWith(t => Schedule(() => undeleteButton.Enabled.Value = true));
}
2018-04-13 17:19:50 +08:00
}
2022-06-22 06:41:25 +08:00
});
}
2018-04-13 17:19:50 +08:00
}
}
}