Fix several oversights in data linking causing drawable rooms not updating as expected

This commit is contained in:
Dean Herbert 2022-02-24 16:12:15 +09:00
parent 53bbd00675
commit c6d78b9325
3 changed files with 11 additions and 10 deletions

View File

@ -46,6 +46,7 @@ namespace osu.Game.Online.Rooms
public readonly Bindable<RoomPlaylistItemStats> PlaylistItemStats = new Bindable<RoomPlaylistItemStats>(); public readonly Bindable<RoomPlaylistItemStats> PlaylistItemStats = new Bindable<RoomPlaylistItemStats>();
[JsonProperty("difficulty_range")] [JsonProperty("difficulty_range")]
[Cached]
public readonly Bindable<RoomDifficultyRange> DifficultyRange = new Bindable<RoomDifficultyRange>(); public readonly Bindable<RoomDifficultyRange> DifficultyRange = new Bindable<RoomDifficultyRange>();
[Cached] [Cached]
@ -190,6 +191,7 @@ namespace osu.Game.Online.Rooms
QueueMode.Value = other.QueueMode.Value; QueueMode.Value = other.QueueMode.Value;
DifficultyRange.Value = other.DifficultyRange.Value; DifficultyRange.Value = other.DifficultyRange.Value;
PlaylistItemStats.Value = other.PlaylistItemStats.Value; PlaylistItemStats.Value = other.PlaylistItemStats.Value;
CurrentPlaylistItem.Value = other.CurrentPlaylistItem.Value;
if (EndDate.Value != null && DateTimeOffset.Now >= EndDate.Value) if (EndDate.Value != null && DateTimeOffset.Now >= EndDate.Value)
Status.Value = new RoomStatusEnded(); Status.Value = new RoomStatusEnded();

View File

@ -2,7 +2,6 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using System.Collections.Specialized;
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
@ -12,7 +11,6 @@ using osu.Framework.Utils;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables; using osu.Game.Beatmaps.Drawables;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Online.Rooms;
using osuTK; using osuTK;
namespace osu.Game.Screens.OnlinePlay.Components namespace osu.Game.Screens.OnlinePlay.Components
@ -72,25 +70,23 @@ namespace osu.Game.Screens.OnlinePlay.Components
}; };
} }
[Resolved]
private Room room { get; set; }
protected override void LoadComplete() protected override void LoadComplete()
{ {
base.LoadComplete(); base.LoadComplete();
Playlist.BindCollectionChanged(updateRange, true); DifficultyRange.BindValueChanged(_ => updateRange());
Playlist.BindCollectionChanged((_, __) => updateRange(), true);
} }
private void updateRange(object sender, NotifyCollectionChangedEventArgs e) private void updateRange()
{ {
StarDifficulty minDifficulty; StarDifficulty minDifficulty;
StarDifficulty maxDifficulty; StarDifficulty maxDifficulty;
if (room.DifficultyRange.Value != null) if (DifficultyRange.Value != null)
{ {
minDifficulty = new StarDifficulty(room.DifficultyRange.Value.Min, 0); minDifficulty = new StarDifficulty(DifficultyRange.Value.Min, 0);
maxDifficulty = new StarDifficulty(room.DifficultyRange.Value.Max, 0); maxDifficulty = new StarDifficulty(DifficultyRange.Value.Max, 0);
} }
else else
{ {

View File

@ -41,6 +41,9 @@ namespace osu.Game.Screens.OnlinePlay
[Resolved(typeof(Room))] [Resolved(typeof(Room))]
protected BindableList<PlaylistItem> Playlist { get; private set; } protected BindableList<PlaylistItem> Playlist { get; private set; }
[Resolved(typeof(Room))]
protected Bindable<Room.RoomDifficultyRange> DifficultyRange { get; private set; }
[Resolved(typeof(Room))] [Resolved(typeof(Room))]
protected Bindable<RoomCategory> Category { get; private set; } protected Bindable<RoomCategory> Category { get; private set; }