Replace BeatmapCollection with RealmBeatmapCollection

This commit is contained in:
Dean Herbert
2022-07-27 16:46:23 +09:00
parent 9c543fef48
commit 41393616d8
18 changed files with 158 additions and 180 deletions

View File

@ -1,10 +1,7 @@
// 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.
#nullable disable
using System;
using JetBrains.Annotations;
using osu.Framework.Bindables;
namespace osu.Game.Collections
@ -18,26 +15,26 @@ namespace osu.Game.Collections
/// The collection to filter beatmaps from.
/// May be null to not filter by collection (include all beatmaps).
/// </summary>
[CanBeNull]
public readonly BeatmapCollection Collection;
public readonly BeatmapCollection? Collection;
/// <summary>
/// The name of the collection.
/// </summary>
[NotNull]
public readonly Bindable<string> CollectionName;
/// <summary>
/// Creates a new <see cref="CollectionFilterMenuItem"/>.
/// </summary>
/// <param name="collection">The collection to filter beatmaps from.</param>
public CollectionFilterMenuItem([CanBeNull] BeatmapCollection collection)
public CollectionFilterMenuItem(BeatmapCollection? collection)
{
Collection = collection;
CollectionName = Collection?.Name.GetBoundCopy() ?? new Bindable<string>("All beatmaps");
CollectionName = new Bindable<string>(collection?.Name ?? "All beatmaps");
}
public bool Equals(CollectionFilterMenuItem other)
// TODO: track name changes i guess?
public bool Equals(CollectionFilterMenuItem? other)
{
if (other == null)
return false;
@ -45,7 +42,7 @@ namespace osu.Game.Collections
// collections may have the same name, so compare first on reference equality.
// this relies on the assumption that only one instance of the BeatmapCollection exists game-wide, managed by CollectionManager.
if (Collection != null)
return Collection == other.Collection;
return Collection.ID == other.Collection?.ID;
// fallback to name-based comparison.
// this is required for special dropdown items which don't have a collection (all beatmaps / manage collections items below).