mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 18:53:51 +08:00
Update client beatmap availability in-line with tracker
This commit is contained in:
parent
88abee705b
commit
4e6c1a3906
@ -43,6 +43,8 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
|||||||
[Cached]
|
[Cached]
|
||||||
protected readonly MultiplayerBeatmapTracker BeatmapTracker;
|
protected readonly MultiplayerBeatmapTracker BeatmapTracker;
|
||||||
|
|
||||||
|
protected IBindable<BeatmapAvailability> BeatmapAvailability => BeatmapTracker.Availability;
|
||||||
|
|
||||||
protected RoomSubScreen()
|
protected RoomSubScreen()
|
||||||
{
|
{
|
||||||
InternalChild = BeatmapTracker = new MultiplayerBeatmapTracker
|
InternalChild = BeatmapTracker = new MultiplayerBeatmapTracker
|
||||||
|
@ -184,7 +184,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
Playlist.BindCollectionChanged(onPlaylistChanged, true);
|
Playlist.BindCollectionChanged(onPlaylistChanged, true);
|
||||||
|
BeatmapAvailability.BindValueChanged(updateClientAvailability, true);
|
||||||
|
|
||||||
|
client.RoomUpdated += onRoomUpdated;
|
||||||
client.LoadRequested += onLoadRequested;
|
client.LoadRequested += onLoadRequested;
|
||||||
|
|
||||||
isConnected = client.IsConnected.GetBoundCopy();
|
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 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()
|
private void onReadyClick()
|
||||||
{
|
{
|
||||||
Debug.Assert(readyClickOperation == null);
|
Debug.Assert(readyClickOperation == null);
|
||||||
@ -262,7 +279,10 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
|||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
|
|
||||||
if (client != null)
|
if (client != null)
|
||||||
|
{
|
||||||
client.LoadRequested -= onLoadRequested;
|
client.LoadRequested -= onLoadRequested;
|
||||||
|
client.RoomUpdated -= onRoomUpdated;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user