diff --git a/osu.Game/Screens/OnlinePlay/Match/RoomSubScreen.cs b/osu.Game/Screens/OnlinePlay/Match/RoomSubScreen.cs index c049d4be20..7569da00f2 100644 --- a/osu.Game/Screens/OnlinePlay/Match/RoomSubScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Match/RoomSubScreen.cs @@ -43,6 +43,8 @@ namespace osu.Game.Screens.OnlinePlay.Match [Cached] protected readonly MultiplayerBeatmapTracker BeatmapTracker; + protected IBindable BeatmapAvailability => BeatmapTracker.Availability; + protected RoomSubScreen() { InternalChild = BeatmapTracker = new MultiplayerBeatmapTracker diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerMatchSubScreen.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerMatchSubScreen.cs index a641935b9a..94288673fb 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerMatchSubScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerMatchSubScreen.cs @@ -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 _ = 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; + } } } }