1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 10:02:59 +08:00

Revert user state back to idle upon availability change

This commit is contained in:
Salman Ahmed 2021-01-18 17:23:51 +03:00
parent 5f2e9c5485
commit e6ceaad732

View File

@ -184,7 +184,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
base.LoadComplete(); base.LoadComplete();
Playlist.BindCollectionChanged(onPlaylistChanged, true); Playlist.BindCollectionChanged(onPlaylistChanged, true);
BeatmapAvailability.BindValueChanged(updateClientAvailability, true); BeatmapAvailability.BindValueChanged(updateBeatmapAvailability, true);
client.RoomUpdated += onRoomUpdated; client.RoomUpdated += onRoomUpdated;
client.LoadRequested += onLoadRequested; client.LoadRequested += onLoadRequested;
@ -210,10 +210,15 @@ 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) private void updateBeatmapAvailability(ValueChangedEvent<BeatmapAvailability> _ = null)
{ {
if (client.Room != null) if (client.Room == null)
client.ChangeBeatmapAvailability(BeatmapAvailability.Value).CatchUnobservedExceptions(true); return;
client.ChangeBeatmapAvailability(BeatmapAvailability.Value).CatchUnobservedExceptions(true);
if (client.LocalUser?.State == MultiplayerUserState.Ready)
client.ChangeState(MultiplayerUserState.Idle).CatchUnobservedExceptions(true);
} }
private void onRoomUpdated() private void onRoomUpdated()
@ -222,7 +227,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
return; return;
if (client.LocalUser?.BeatmapAvailability.Equals(BeatmapAvailability.Value) == false) if (client.LocalUser?.BeatmapAvailability.Equals(BeatmapAvailability.Value) == false)
updateClientAvailability(); updateBeatmapAvailability();
} }
private void onReadyClick() private void onReadyClick()