1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 16:06:06 +08:00

Update client beatmap availability in-line with tracker

This commit is contained in:
Salman Ahmed 2021-01-18 10:49:38 +03:00
parent 88abee705b
commit 4e6c1a3906
2 changed files with 22 additions and 0 deletions

View File

@ -43,6 +43,8 @@ namespace osu.Game.Screens.OnlinePlay.Match
[Cached]
protected readonly MultiplayerBeatmapTracker BeatmapTracker;
protected IBindable<BeatmapAvailability> BeatmapAvailability => BeatmapTracker.Availability;
protected RoomSubScreen()
{
InternalChild = BeatmapTracker = new MultiplayerBeatmapTracker

View File

@ -184,7 +184,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
base.LoadComplete();
Playlist.BindCollectionChanged(onPlaylistChanged, true);
BeatmapAvailability.BindValueChanged(updateClientAvailability, true);
client.RoomUpdated += onRoomUpdated;
client.LoadRequested += onLoadRequested;
isConnected = client.IsConnected.GetBoundCopy();
@ -208,6 +210,21 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
private void onPlaylistChanged(object sender, NotifyCollectionChangedEventArgs e) => SelectedItem.Value = Playlist.FirstOrDefault();
private void updateClientAvailability(ValueChangedEvent<BeatmapAvailability> _ = null)
{
if (client.Room != null)
client.ChangeBeatmapAvailability(BeatmapAvailability.Value).CatchUnobservedExceptions(true);
}
private void onRoomUpdated()
{
if (client.Room == null)
return;
if (client.LocalUser?.BeatmapAvailability.Equals(BeatmapAvailability.Value) == false)
updateClientAvailability();
}
private void onReadyClick()
{
Debug.Assert(readyClickOperation == null);
@ -262,7 +279,10 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
base.Dispose(isDisposing);
if (client != null)
{
client.LoadRequested -= onLoadRequested;
client.RoomUpdated -= onRoomUpdated;
}
}
}
}