2019-01-24 16:43:03 +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
|
|
|
|
|
|
|
|
|
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;
|
2021-07-15 11:50:34 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
2020-09-02 23:08:33 +08:00
|
|
|
|
using osu.Game.Collections;
|
2021-05-09 23:12:58 +08:00
|
|
|
|
using osu.Game.Database;
|
2021-08-12 12:26:42 +08:00
|
|
|
|
using osu.Game.Localisation;
|
2019-06-20 00:33:51 +08:00
|
|
|
|
using osu.Game.Scoring;
|
2018-08-31 17:28:53 +08:00
|
|
|
|
using osu.Game.Skinning;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
|
|
|
|
{
|
|
|
|
|
public class GeneralSettings : SettingsSubsection
|
|
|
|
|
{
|
2021-07-15 11:50:34 +08:00
|
|
|
|
protected override LocalisableString Header => "General";
|
2018-09-21 20:08:21 +08:00
|
|
|
|
|
2021-10-11 02:32:56 +08:00
|
|
|
|
private SettingsButton importBeatmapsButton;
|
|
|
|
|
private SettingsButton importScoresButton;
|
|
|
|
|
private SettingsButton importSkinsButton;
|
|
|
|
|
private SettingsButton importCollectionsButton;
|
|
|
|
|
private SettingsButton deleteBeatmapsButton;
|
|
|
|
|
private SettingsButton deleteScoresButton;
|
|
|
|
|
private SettingsButton deleteSkinsButton;
|
|
|
|
|
private SettingsButton restoreButton;
|
|
|
|
|
private SettingsButton undeleteButton;
|
2022-05-18 14:09:58 +08:00
|
|
|
|
private SettingsButton deleteBeatmapVideosButton;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-09-09 15:33:48 +08:00
|
|
|
|
[BackgroundDependencyLoader(permitNulls: true)]
|
2022-04-18 17:09:14 +08:00
|
|
|
|
private void load(BeatmapManager beatmaps, ScoreManager scores, SkinManager skins, [CanBeNull] CollectionManager collectionManager, [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
|
|
|
|
{
|
2019-02-28 12:09:38 +08:00
|
|
|
|
Add(importBeatmapsButton = new SettingsButton
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-08-12 12:26:42 +08:00
|
|
|
|
Text = MaintenanceSettingsStrings.ImportBeatmapsFromStable,
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Action = () =>
|
|
|
|
|
{
|
2018-09-21 20:08:21 +08:00
|
|
|
|
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
|
|
|
|
}
|
2019-02-28 12:09:38 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Add(deleteBeatmapsButton = new DangerousSettingsButton
|
|
|
|
|
{
|
2021-08-12 12:26:42 +08:00
|
|
|
|
Text = MaintenanceSettingsStrings.DeleteAllBeatmaps,
|
2019-02-28 12:09:38 +08:00
|
|
|
|
Action = () =>
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-11-26 17:18:45 +08:00
|
|
|
|
dialogOverlay?.Push(new MassDeleteConfirmationDialog(() =>
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-02-28 12:09:38 +08:00
|
|
|
|
deleteBeatmapsButton.Enabled.Value = false;
|
2022-01-11 21:57:47 +08:00
|
|
|
|
Task.Run(() => beatmaps.Delete()).ContinueWith(t => Schedule(() => deleteBeatmapsButton.Enabled.Value = true));
|
2019-02-28 12:09:38 +08:00
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2022-05-18 14:09:58 +08:00
|
|
|
|
Add(deleteBeatmapVideosButton = new DangerousSettingsButton
|
|
|
|
|
{
|
|
|
|
|
Text = MaintenanceSettingsStrings.DeleteAllBeatmapVideos,
|
|
|
|
|
Action = () =>
|
|
|
|
|
{
|
|
|
|
|
dialogOverlay?.Push(new MassVideoDeleteConfirmationDialog(() =>
|
|
|
|
|
{
|
|
|
|
|
deleteBeatmapVideosButton.Enabled.Value = false;
|
|
|
|
|
Task.Run(() => beatmaps.DeleteVideos()).ContinueWith(t => Schedule(() => deleteBeatmapsButton.Enabled.Value = true));
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2021-11-25 16:12:15 +08:00
|
|
|
|
if (legacyImportManager?.SupportsImportFromStable == true)
|
2019-06-20 00:33:51 +08:00
|
|
|
|
{
|
|
|
|
|
Add(importScoresButton = new SettingsButton
|
|
|
|
|
{
|
2021-08-12 12:26:42 +08:00
|
|
|
|
Text = MaintenanceSettingsStrings.ImportScoresFromStable,
|
2019-06-20 00:33:51 +08:00
|
|
|
|
Action = () =>
|
|
|
|
|
{
|
|
|
|
|
importScoresButton.Enabled.Value = false;
|
2021-11-25 16:12:15 +08:00
|
|
|
|
legacyImportManager.ImportFromStableAsync(StableContent.Scores).ContinueWith(t => Schedule(() => importScoresButton.Enabled.Value = true));
|
2019-06-20 00:33:51 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Add(deleteScoresButton = new DangerousSettingsButton
|
|
|
|
|
{
|
2021-08-12 12:26:42 +08:00
|
|
|
|
Text = MaintenanceSettingsStrings.DeleteAllScores,
|
2019-06-20 00:33:51 +08:00
|
|
|
|
Action = () =>
|
|
|
|
|
{
|
2021-11-26 17:18:45 +08:00
|
|
|
|
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
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2021-11-25 16:12:15 +08:00
|
|
|
|
if (legacyImportManager?.SupportsImportFromStable == true)
|
2019-02-28 12:09:38 +08:00
|
|
|
|
{
|
|
|
|
|
Add(importSkinsButton = new SettingsButton
|
2018-08-31 17:28:53 +08:00
|
|
|
|
{
|
2021-08-12 12:26:42 +08:00
|
|
|
|
Text = MaintenanceSettingsStrings.ImportSkinsFromStable,
|
2018-08-31 17:28:53 +08:00
|
|
|
|
Action = () =>
|
|
|
|
|
{
|
2018-09-21 20:08:21 +08:00
|
|
|
|
importSkinsButton.Enabled.Value = false;
|
2021-11-25 16:12:15 +08:00
|
|
|
|
legacyImportManager.ImportFromStableAsync(StableContent.Skins).ContinueWith(t => Schedule(() => importSkinsButton.Enabled.Value = true));
|
2018-08-31 17:28:53 +08:00
|
|
|
|
}
|
2019-02-28 12:09:38 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-02 23:08:33 +08:00
|
|
|
|
Add(deleteSkinsButton = new DangerousSettingsButton
|
2019-02-28 12:09:38 +08:00
|
|
|
|
{
|
2021-08-12 12:26:42 +08:00
|
|
|
|
Text = MaintenanceSettingsStrings.DeleteAllSkins,
|
2020-09-02 23:08:33 +08:00
|
|
|
|
Action = () =>
|
2018-08-31 17:28:53 +08:00
|
|
|
|
{
|
2021-11-26 17:18:45 +08:00
|
|
|
|
dialogOverlay?.Push(new MassDeleteConfirmationDialog(() =>
|
2020-09-02 23:08:33 +08:00
|
|
|
|
{
|
|
|
|
|
deleteSkinsButton.Enabled.Value = false;
|
2022-01-11 22:04:36 +08:00
|
|
|
|
Task.Run(() => skins.Delete()).ContinueWith(t => Schedule(() => deleteSkinsButton.Enabled.Value = true));
|
2020-09-02 23:08:33 +08:00
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2020-09-09 15:33:48 +08:00
|
|
|
|
if (collectionManager != null)
|
2020-09-02 23:08:33 +08:00
|
|
|
|
{
|
2021-11-25 16:12:15 +08:00
|
|
|
|
if (legacyImportManager?.SupportsImportFromStable == true)
|
2020-09-02 23:08:33 +08:00
|
|
|
|
{
|
2020-09-09 15:33:48 +08:00
|
|
|
|
Add(importCollectionsButton = new SettingsButton
|
|
|
|
|
{
|
2021-08-12 12:26:42 +08:00
|
|
|
|
Text = MaintenanceSettingsStrings.ImportCollectionsFromStable,
|
2020-09-09 15:33:48 +08:00
|
|
|
|
Action = () =>
|
|
|
|
|
{
|
|
|
|
|
importCollectionsButton.Enabled.Value = false;
|
2021-11-25 16:12:15 +08:00
|
|
|
|
legacyImportManager.ImportFromStableAsync(StableContent.Collections).ContinueWith(t => Schedule(() => importCollectionsButton.Enabled.Value = true));
|
2020-09-09 15:33:48 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Add(new DangerousSettingsButton
|
|
|
|
|
{
|
2021-08-12 12:26:42 +08:00
|
|
|
|
Text = MaintenanceSettingsStrings.DeleteAllCollections,
|
2018-08-31 17:28:53 +08:00
|
|
|
|
Action = () =>
|
|
|
|
|
{
|
2021-11-26 17:18:45 +08:00
|
|
|
|
dialogOverlay?.Push(new MassDeleteConfirmationDialog(collectionManager.DeleteAll));
|
2018-08-31 17:28:53 +08:00
|
|
|
|
}
|
2020-09-02 23:08:33 +08:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
AddRange(new Drawable[]
|
|
|
|
|
{
|
2018-04-13 17:19:50 +08:00
|
|
|
|
restoreButton = new SettingsButton
|
|
|
|
|
{
|
2021-08-12 12:26:42 +08:00
|
|
|
|
Text = MaintenanceSettingsStrings.RestoreAllHiddenDifficulties,
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Action = () =>
|
|
|
|
|
{
|
|
|
|
|
restoreButton.Enabled.Value = false;
|
2022-01-11 22:04:36 +08:00
|
|
|
|
Task.Run(beatmaps.RestoreAll).ContinueWith(t => Schedule(() => restoreButton.Enabled.Value = true));
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
undeleteButton = new SettingsButton
|
|
|
|
|
{
|
2021-08-12 12:26:42 +08:00
|
|
|
|
Text = MaintenanceSettingsStrings.RestoreAllRecentlyDeletedBeatmaps,
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Action = () =>
|
|
|
|
|
{
|
|
|
|
|
undeleteButton.Enabled.Value = false;
|
2022-01-11 22:04:36 +08:00
|
|
|
|
Task.Run(beatmaps.UndeleteAll).ContinueWith(t => Schedule(() => undeleteButton.Enabled.Value = true));
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
2019-02-28 12:09:38 +08:00
|
|
|
|
});
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|