Remove CollectionManager

This commit is contained in:
Dean Herbert
2022-07-27 15:59:36 +09:00
parent 6b73f7c7ec
commit 9c543fef48
19 changed files with 276 additions and 292 deletions

View File

@ -17,6 +17,7 @@ using osu.Framework.Graphics.UserInterface;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Collections;
using osu.Game.Database;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays;
@ -32,12 +33,12 @@ namespace osu.Game.Screens.Select.Carousel
[Resolved(CanBeNull = true)]
private IDialogOverlay dialogOverlay { get; set; }
[Resolved(CanBeNull = true)]
private CollectionManager collectionManager { get; set; }
[Resolved(CanBeNull = true)]
private ManageCollectionsDialog manageCollectionsDialog { get; set; }
[Resolved]
private RealmAccess realm { get; set; }
public IEnumerable<DrawableCarouselItem> DrawableBeatmaps => beatmapContainer?.IsLoaded != true ? Enumerable.Empty<DrawableCarouselItem>() : beatmapContainer.AliveChildren;
[CanBeNull]
@ -223,14 +224,11 @@ namespace osu.Game.Screens.Select.Carousel
if (beatmapSet.OnlineID > 0 && viewDetails != null)
items.Add(new OsuMenuItem("Details...", MenuItemType.Standard, () => viewDetails(beatmapSet.OnlineID)));
if (collectionManager != null)
{
var collectionItems = collectionManager.Collections.Select(createCollectionMenuItem).ToList();
if (manageCollectionsDialog != null)
collectionItems.Add(new OsuMenuItem("Manage...", MenuItemType.Standard, manageCollectionsDialog.Show));
var collectionItems = realm.Realm.All<RealmBeatmapCollection>().AsEnumerable().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)));
@ -241,13 +239,13 @@ namespace osu.Game.Screens.Select.Carousel
}
}
private MenuItem createCollectionMenuItem(BeatmapCollection collection)
private MenuItem createCollectionMenuItem(RealmBeatmapCollection collection)
{
Debug.Assert(beatmapSet != null);
TernaryState state;
int countExisting = beatmapSet.Beatmaps.Count(b => collection.BeatmapHashes.Contains(b.MD5Hash));
int countExisting = beatmapSet.Beatmaps.Count(b => collection.BeatmapMD5Hashes.Contains(b.MD5Hash));
if (countExisting == beatmapSet.Beatmaps.Count)
state = TernaryState.True;
@ -256,21 +254,21 @@ namespace osu.Game.Screens.Select.Carousel
else
state = TernaryState.False;
return new TernaryStateToggleMenuItem(collection.Name.Value, MenuItemType.Standard, s =>
return new TernaryStateToggleMenuItem(collection.Name, MenuItemType.Standard, s =>
{
foreach (var b in beatmapSet.Beatmaps)
{
switch (s)
{
case TernaryState.True:
if (collection.BeatmapHashes.Contains(b.MD5Hash))
if (collection.BeatmapMD5Hashes.Contains(b.MD5Hash))
continue;
collection.BeatmapHashes.Add(b.MD5Hash);
collection.BeatmapMD5Hashes.Add(b.MD5Hash);
break;
case TernaryState.False:
collection.BeatmapHashes.Remove(b.MD5Hash);
collection.BeatmapMD5Hashes.Remove(b.MD5Hash);
break;
}
}