mirror of
https://github.com/ppy/osu.git
synced 2025-03-06 09:47:22 +08:00
update var names and test logic
This commit is contained in:
parent
8eeb5ae06b
commit
19a4cef113
@ -23,7 +23,7 @@ namespace osu.Game.Screens.Ranking
|
|||||||
public partial class CollectionButton : GrayButton, IHasPopover
|
public partial class CollectionButton : GrayButton, IHasPopover
|
||||||
{
|
{
|
||||||
private readonly BeatmapInfo beatmapInfo;
|
private readonly BeatmapInfo beatmapInfo;
|
||||||
private readonly Bindable<bool> current;
|
private readonly Bindable<bool> isInAnyCollection;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private RealmAccess realmAccess { get; set; } = null!;
|
private RealmAccess realmAccess { get; set; } = null!;
|
||||||
@ -37,7 +37,7 @@ namespace osu.Game.Screens.Ranking
|
|||||||
: base(FontAwesome.Solid.Book)
|
: base(FontAwesome.Solid.Book)
|
||||||
{
|
{
|
||||||
this.beatmapInfo = beatmapInfo;
|
this.beatmapInfo = beatmapInfo;
|
||||||
current = new Bindable<bool>(false);
|
isInAnyCollection = new Bindable<bool>(false);
|
||||||
|
|
||||||
Size = new Vector2(75, 30);
|
Size = new Vector2(75, 30);
|
||||||
|
|
||||||
@ -54,9 +54,9 @@ namespace osu.Game.Screens.Ranking
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
collectionSubscription = realmAccess.RegisterForNotifications(r => r.All<BeatmapCollection>(), updateRealm);
|
collectionSubscription = realmAccess.RegisterForNotifications(r => r.All<BeatmapCollection>(), collectionsChanged);
|
||||||
|
|
||||||
current.BindValueChanged(_ => updateState(), true);
|
isInAnyCollection.BindValueChanged(_ => updateState(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
@ -66,14 +66,14 @@ namespace osu.Game.Screens.Ranking
|
|||||||
collectionSubscription?.Dispose();
|
collectionSubscription?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateRealm(IRealmCollection<BeatmapCollection> sender, ChangeSet? changes)
|
private void collectionsChanged(IRealmCollection<BeatmapCollection> sender, ChangeSet? changes)
|
||||||
{
|
{
|
||||||
current.Value = sender.AsEnumerable().Any(c => c.BeatmapMD5Hashes.Contains(beatmapInfo.MD5Hash));
|
isInAnyCollection.Value = sender.AsEnumerable().Any(c => c.BeatmapMD5Hashes.Contains(beatmapInfo.MD5Hash));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateState()
|
private void updateState()
|
||||||
{
|
{
|
||||||
Background.FadeColour(current.Value ? colours.Green : colours.Gray4, 500, Easing.InOutExpo);
|
Background.FadeColour(isInAnyCollection.Value ? colours.Green : colours.Gray4, 500, Easing.InOutExpo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Popover GetPopover() => new CollectionPopover(beatmapInfo);
|
public Popover GetPopover() => new CollectionPopover(beatmapInfo);
|
||||||
|
@ -9,6 +9,7 @@ using System.Diagnostics;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Database;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
@ -197,8 +198,9 @@ namespace osu.Game.Tests.Visual.OnlinePlay
|
|||||||
|
|
||||||
case GetBeatmapSetRequest getBeatmapSetRequest:
|
case GetBeatmapSetRequest getBeatmapSetRequest:
|
||||||
{
|
{
|
||||||
// Incorrect logic, see https://github.com/ppy/osu/pull/28991#issuecomment-2256721076 for reason why this change
|
var baseBeatmap = getBeatmapSetRequest.Type == BeatmapSetLookupType.BeatmapId
|
||||||
var baseBeatmap = beatmapManager.QueryBeatmap(b => b.OnlineID == getBeatmapSetRequest.ID);
|
? beatmapManager.QueryBeatmap(b => b.OnlineID == getBeatmapSetRequest.ID)
|
||||||
|
: beatmapManager.QueryBeatmapSet(s => s.OnlineID == getBeatmapSetRequest.ID)?.PerformRead(s => s.Beatmaps.First().Detach());
|
||||||
|
|
||||||
if (baseBeatmap == null)
|
if (baseBeatmap == null)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user