1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 06:57:39 +08:00

Move CollectionManager to OsuGame

This commit is contained in:
smoogipoo 2020-09-09 15:39:15 +09:00
parent 4ddf5f054b
commit 0360f7d845
6 changed files with 29 additions and 25 deletions

View File

@ -62,7 +62,7 @@ namespace osu.Game.Collections
private readonly IBindable<string> collectionName;
private readonly BeatmapCollection collection;
[Resolved]
[Resolved(CanBeNull = true)]
private CollectionManager collectionManager { get; set; }
private Container textBoxPaddingContainer;
@ -127,7 +127,7 @@ namespace osu.Game.Collections
return;
// Add the new collection and disable our placeholder. If all text is removed, the placeholder should not show back again.
collectionManager.Collections.Add(collection);
collectionManager?.Collections.Add(collection);
textBox.PlaceholderText = string.Empty;
// When this item changes from placeholder to non-placeholder (via changing containers), its textbox will lose focus, so it needs to be re-focused.
@ -158,7 +158,7 @@ namespace osu.Game.Collections
[Resolved(CanBeNull = true)]
private DialogOverlay dialogOverlay { get; set; }
[Resolved]
[Resolved(CanBeNull = true)]
private CollectionManager collectionManager { get; set; }
private readonly BeatmapCollection collection;
@ -231,7 +231,7 @@ namespace osu.Game.Collections
return true;
}
private void deleteCollection() => collectionManager.Collections.Remove(collection);
private void deleteCollection() => collectionManager?.Collections.Remove(collection);
}
}
}

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
@ -19,7 +20,7 @@ namespace osu.Game.Collections
private const double enter_duration = 500;
private const double exit_duration = 200;
[Resolved]
[Resolved(CanBeNull = true)]
private CollectionManager collectionManager { get; set; }
public ManageCollectionsDialog()
@ -100,7 +101,7 @@ namespace osu.Game.Collections
new DrawableCollectionList
{
RelativeSizeAxes = Axes.Both,
Items = { BindTarget = collectionManager.Collections }
Items = { BindTarget = collectionManager?.Collections ?? new BindableList<BeatmapCollection>() }
}
}
}

View File

@ -538,9 +538,6 @@ namespace osu.Game
ScoreManager.GetStableStorage = GetStorageForStableInstall;
ScoreManager.PresentImport = items => PresentScore(items.First());
CollectionManager.PostNotification = n => notifications.Post(n);
CollectionManager.GetStableStorage = GetStorageForStableInstall;
Container logoContainer;
BackButton.Receptor receptor;
@ -614,6 +611,12 @@ namespace osu.Game
d.Origin = Anchor.TopRight;
}), rightFloatingOverlayContent.Add, true);
loadComponentSingleFile(new CollectionManager(Storage)
{
PostNotification = n => notifications.Post(n),
GetStableStorage = GetStorageForStableInstall
}, Add, true);
loadComponentSingleFile(screenshotManager, Add);
// dependency on notification overlay, dependent by settings overlay

View File

@ -26,7 +26,6 @@ using osu.Framework.Graphics.Textures;
using osu.Framework.Input;
using osu.Framework.Logging;
using osu.Game.Audio;
using osu.Game.Collections;
using osu.Game.Database;
using osu.Game.Input;
using osu.Game.Input.Bindings;
@ -57,8 +56,6 @@ namespace osu.Game
protected BeatmapManager BeatmapManager;
protected CollectionManager CollectionManager;
protected ScoreManager ScoreManager;
protected SkinManager SkinManager;
@ -228,9 +225,6 @@ namespace osu.Game
dependencies.Cache(difficultyManager);
AddInternal(difficultyManager);
dependencies.Cache(CollectionManager = new CollectionManager(Storage));
AddInternal(CollectionManager);
dependencies.Cache(KeyBindingStore = new KeyBindingStore(contextFactory, RulesetStore));
dependencies.Cache(SettingsStore = new SettingsStore(contextFactory));
dependencies.Cache(RulesetConfigCache = new RulesetConfigCache(SettingsStore));

View File

@ -48,7 +48,7 @@ namespace osu.Game.Screens.Select.Carousel
[Resolved]
private BeatmapDifficultyManager difficultyManager { get; set; }
[Resolved]
[Resolved(CanBeNull = true)]
private CollectionManager collectionManager { get; set; }
[Resolved(CanBeNull = true)]
@ -224,11 +224,14 @@ namespace osu.Game.Screens.Select.Carousel
if (beatmap.OnlineBeatmapID.HasValue && beatmapOverlay != null)
items.Add(new OsuMenuItem("Details...", MenuItemType.Standard, () => beatmapOverlay.FetchAndShowBeatmap(beatmap.OnlineBeatmapID.Value)));
var collectionItems = collectionManager.Collections.Select(createCollectionMenuItem).ToList();
if (manageCollectionsDialog != null)
collectionItems.Add(new OsuMenuItem("Manage...", MenuItemType.Standard, manageCollectionsDialog.Show));
if (collectionManager != null)
{
var collectionItems = collectionManager.Collections.Select(createCollectionMenuItem).ToList();
if (manageCollectionsDialog != null)
collectionItems.Add(new OsuMenuItem("Manage...", MenuItemType.Standard, manageCollectionsDialog.Show));
items.Add(new OsuMenuItem("Collections") { Items = collectionItems });
items.Add(new OsuMenuItem("Collections") { Items = collectionItems });
}
if (hideRequested != null)
items.Add(new OsuMenuItem("Hide", MenuItemType.Destructive, () => hideRequested(beatmap)));

View File

@ -35,7 +35,7 @@ namespace osu.Game.Screens.Select.Carousel
[Resolved(CanBeNull = true)]
private DialogOverlay dialogOverlay { get; set; }
[Resolved]
[Resolved(CanBeNull = true)]
private CollectionManager collectionManager { get; set; }
[Resolved(CanBeNull = true)]
@ -142,11 +142,14 @@ namespace osu.Game.Screens.Select.Carousel
if (beatmapSet.OnlineBeatmapSetID != null && viewDetails != null)
items.Add(new OsuMenuItem("Details...", MenuItemType.Standard, () => viewDetails(beatmapSet.OnlineBeatmapSetID.Value)));
var collectionItems = collectionManager.Collections.Select(createCollectionMenuItem).ToList();
if (manageCollectionsDialog != null)
collectionItems.Add(new OsuMenuItem("Manage...", MenuItemType.Standard, manageCollectionsDialog.Show));
if (collectionManager != null)
{
var collectionItems = collectionManager.Collections.Select(createCollectionMenuItem).ToList();
if (manageCollectionsDialog != null)
collectionItems.Add(new OsuMenuItem("Manage...", MenuItemType.Standard, manageCollectionsDialog.Show));
items.Add(new OsuMenuItem("Collections") { Items = collectionItems });
items.Add(new OsuMenuItem("Collections") { Items = collectionItems });
}
if (beatmapSet.Beatmaps.Any(b => b.Hidden))
items.Add(new OsuMenuItem("Restore all hidden", MenuItemType.Standard, () => restoreHiddenRequested(beatmapSet)));