From 1a023d2c887ab72795c34e435cb22b4a130e2a6f Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Wed, 9 Sep 2020 16:33:48 +0900 Subject: [PATCH] Fix a few more tests --- .../Sections/Maintenance/GeneralSettings.cs | 36 ++++++++++--------- .../Select/CollectionFilterDropdown.cs | 8 +++-- 2 files changed, 25 insertions(+), 19 deletions(-) diff --git a/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs index 83ee5e497a..848ce381a9 100644 --- a/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Maintenance/GeneralSettings.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Threading.Tasks; +using JetBrains.Annotations; using osu.Framework.Allocation; using osu.Framework.Graphics; using osu.Game.Beatmaps; @@ -27,8 +28,8 @@ public class GeneralSettings : SettingsSubsection private TriangleButton restoreButton; private TriangleButton undeleteButton; - [BackgroundDependencyLoader] - private void load(BeatmapManager beatmaps, ScoreManager scores, SkinManager skins, CollectionManager collectionManager, DialogOverlay dialogOverlay) + [BackgroundDependencyLoader(permitNulls: true)] + private void load(BeatmapManager beatmaps, ScoreManager scores, SkinManager skins, [CanBeNull] CollectionManager collectionManager, DialogOverlay dialogOverlay) { if (beatmaps.SupportsImportFromStable) { @@ -108,28 +109,31 @@ private void load(BeatmapManager beatmaps, ScoreManager scores, SkinManager skin } }); - if (collectionManager.SupportsImportFromStable) + if (collectionManager != null) { - Add(importCollectionsButton = new SettingsButton + if (collectionManager.SupportsImportFromStable) { - Text = "Import collections from stable", + Add(importCollectionsButton = new SettingsButton + { + Text = "Import collections from stable", + Action = () => + { + importCollectionsButton.Enabled.Value = false; + collectionManager.ImportFromStableAsync().ContinueWith(t => Schedule(() => importCollectionsButton.Enabled.Value = true)); + } + }); + } + + Add(new DangerousSettingsButton + { + Text = "Delete ALL collections", Action = () => { - importCollectionsButton.Enabled.Value = false; - collectionManager.ImportFromStableAsync().ContinueWith(t => Schedule(() => importCollectionsButton.Enabled.Value = true)); + dialogOverlay?.Push(new DeleteAllBeatmapsDialog(collectionManager.DeleteAll)); } }); } - Add(new DangerousSettingsButton - { - Text = "Delete ALL collections", - Action = () => - { - dialogOverlay?.Push(new DeleteAllBeatmapsDialog(collectionManager.DeleteAll)); - } - }); - AddRange(new Drawable[] { restoreButton = new SettingsButton diff --git a/osu.Game/Screens/Select/CollectionFilterDropdown.cs b/osu.Game/Screens/Select/CollectionFilterDropdown.cs index 7270354e87..1e2a3d0aa7 100644 --- a/osu.Game/Screens/Select/CollectionFilterDropdown.cs +++ b/osu.Game/Screens/Select/CollectionFilterDropdown.cs @@ -37,10 +37,12 @@ public CollectionFilterDropdown() ItemSource = filters; } - [BackgroundDependencyLoader] - private void load(CollectionManager collectionManager) + [BackgroundDependencyLoader(permitNulls: true)] + private void load([CanBeNull] CollectionManager collectionManager) { - collections.BindTo(collectionManager.Collections); + if (collectionManager != null) + collections.BindTo(collectionManager.Collections); + collections.CollectionChanged += (_, __) => collectionsChanged(); collectionsChanged(); }