1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-17 22:52:54 +08:00
osu-lazer/osu.Game/Overlays/Settings/Sections/Maintenance/BeatmapSettings.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

116 lines
4.8 KiB
C#
Raw Normal View History

// 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
using System.Threading.Tasks;
2020-09-09 15:33:48 +08:00
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Game.Beatmaps;
2021-05-09 23:12:58 +08:00
using osu.Game.Database;
using osu.Game.Localisation;
2019-06-20 00:33:51 +08:00
using osu.Game.Scoring;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Overlays.Settings.Sections.Maintenance
{
public class BeatmapSettings : SettingsSubsection
{
protected override LocalisableString Header => "Beatmaps";
2021-10-11 02:32:56 +08:00
private SettingsButton importBeatmapsButton;
private SettingsButton importScoresButton;
private SettingsButton deleteBeatmapsButton;
private SettingsButton deleteBeatmapVideosButton;
2021-10-11 02:32:56 +08:00
private SettingsButton deleteScoresButton;
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)]
private void load(BeatmapManager beatmaps, ScoreManager scores, [CanBeNull] LegacyImportManager legacyImportManager, IDialogOverlay dialogOverlay)
{
2021-11-25 16:12:15 +08:00
if (legacyImportManager?.SupportsImportFromStable == true)
{
Add(importBeatmapsButton = new SettingsButton
{
Text = MaintenanceSettingsStrings.ImportBeatmapsFromStable,
Action = () =>
{
importBeatmapsButton.Enabled.Value = false;
2021-11-25 16:12:15 +08:00
legacyImportManager.ImportFromStableAsync(StableContent.Beatmaps).ContinueWith(t => Schedule(() => importBeatmapsButton.Enabled.Value = true));
}
});
Add(importScoresButton = new SettingsButton
{
Text = MaintenanceSettingsStrings.ImportScoresFromStable,
Action = () =>
{
importScoresButton.Enabled.Value = false;
legacyImportManager.ImportFromStableAsync(StableContent.Scores).ContinueWith(t => Schedule(() => importScoresButton.Enabled.Value = true));
}
});
}
Add(deleteBeatmapsButton = new DangerousSettingsButton
{
Text = MaintenanceSettingsStrings.DeleteAllBeatmaps,
Action = () =>
{
dialogOverlay?.Push(new MassDeleteConfirmationDialog(() =>
{
deleteBeatmapsButton.Enabled.Value = false;
2022-01-11 21:57:47 +08:00
Task.Run(() => beatmaps.Delete()).ContinueWith(t => Schedule(() => deleteBeatmapsButton.Enabled.Value = true));
}));
}
});
Add(deleteBeatmapVideosButton = new DangerousSettingsButton
{
Text = MaintenanceSettingsStrings.DeleteAllBeatmapVideos,
Action = () =>
{
dialogOverlay?.Push(new MassVideoDeleteConfirmationDialog(() =>
{
deleteBeatmapVideosButton.Enabled.Value = false;
2022-06-06 19:12:18 +08:00
Task.Run(beatmaps.DeleteAllVideos).ContinueWith(t => Schedule(() => deleteBeatmapVideosButton.Enabled.Value = true));
}));
}
});
2019-06-20 00:33:51 +08:00
Add(deleteScoresButton = new DangerousSettingsButton
{
Text = MaintenanceSettingsStrings.DeleteAllScores,
2019-06-20 00:33:51 +08:00
Action = () =>
{
dialogOverlay?.Push(new MassDeleteConfirmationDialog(() =>
2019-06-20 00:33:51 +08:00
{
deleteScoresButton.Enabled.Value = false;
2021-12-13 18:01:20 +08:00
Task.Run(() => scores.Delete()).ContinueWith(t => Schedule(() => deleteScoresButton.Enabled.Value = true));
2019-06-20 00:33:51 +08:00
}));
}
});
2020-09-02 23:08:33 +08:00
AddRange(new Drawable[]
{
2017-10-21 10:46:06 +08:00
restoreButton = new SettingsButton
{
Text = MaintenanceSettingsStrings.RestoreAllHiddenDifficulties,
Action = () =>
{
restoreButton.Enabled.Value = false;
2022-01-11 22:04:36 +08:00
Task.Run(beatmaps.RestoreAll).ContinueWith(t => Schedule(() => restoreButton.Enabled.Value = true));
}
},
undeleteButton = new SettingsButton
{
Text = MaintenanceSettingsStrings.RestoreAllRecentlyDeletedBeatmaps,
Action = () =>
{
undeleteButton.Enabled.Value = false;
2022-01-11 22:04:36 +08:00
Task.Run(beatmaps.UndeleteAll).ContinueWith(t => Schedule(() => undeleteButton.Enabled.Value = true));
}
},
});
}
}
}