Merge pull request #11318 from peppy/fix-ready-button-crash

This commit is contained in:
Bartłomiej Dach 2020-12-26 13:18:40 +01:00 committed by GitHub
commit 3e06f592a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 24 additions and 19 deletions

View File

@ -33,7 +33,7 @@ namespace osu.Game.Online.Multiplayer
/// <summary>
/// Invoked when any change occurs to the multiplayer room.
/// </summary>
public event Action? RoomChanged;
public event Action? RoomUpdated;
/// <summary>
/// Invoked when the multiplayer server requests the current beatmap to be loaded into play.
@ -134,7 +134,7 @@ namespace osu.Game.Online.Multiplayer
apiRoom = null;
Room = null;
RoomChanged?.Invoke();
RoomUpdated?.Invoke();
}, false);
return Task.CompletedTask;
@ -214,7 +214,7 @@ namespace osu.Game.Online.Multiplayer
break;
}
RoomChanged?.Invoke();
RoomUpdated?.Invoke();
}, false);
return Task.CompletedTask;
@ -238,7 +238,7 @@ namespace osu.Game.Online.Multiplayer
Room.Users.Add(user);
RoomChanged?.Invoke();
RoomUpdated?.Invoke();
}, false);
}
@ -255,7 +255,7 @@ namespace osu.Game.Online.Multiplayer
Room.Users.Remove(user);
PlayingUsers.Remove(user.UserID);
RoomChanged?.Invoke();
RoomUpdated?.Invoke();
}, false);
return Task.CompletedTask;
@ -278,7 +278,7 @@ namespace osu.Game.Online.Multiplayer
Room.Host = user;
apiRoom.Host.Value = user?.User;
RoomChanged?.Invoke();
RoomUpdated?.Invoke();
}, false);
return Task.CompletedTask;
@ -305,7 +305,7 @@ namespace osu.Game.Online.Multiplayer
if (state != MultiplayerUserState.Playing)
PlayingUsers.Remove(userId);
RoomChanged?.Invoke();
RoomUpdated?.Invoke();
}, false);
return Task.CompletedTask;
@ -419,7 +419,7 @@ namespace osu.Game.Online.Multiplayer
// In-order for the client to not display an outdated beatmap, the playlist is forcefully cleared here.
apiRoom.Playlist.Clear();
RoomChanged?.Invoke();
RoomUpdated?.Invoke();
var req = new GetBeatmapSetRequest(settings.BeatmapID, BeatmapSetLookupType.BeatmapId);
req.Success += res => updatePlaylist(settings, res);

View File

@ -56,11 +56,13 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
sampleReadyCount = audio.Samples.Get(@"SongSelect/select-difficulty");
}
protected override void OnRoomChanged()
protected override void OnRoomUpdated()
{
base.OnRoomChanged();
base.OnRoomUpdated();
// this method is called on leaving the room, so the local user may not exist in the room any more.
localUser = Room?.Users.SingleOrDefault(u => u.User?.Id == api.LocalUser.Value.Id);
localUser = Room?.Users.Single(u => u.User?.Id == api.LocalUser.Value.Id);
button.Enabled.Value = Client.Room?.State == MultiplayerRoomState.Open;
updateState();
}

View File

@ -19,18 +19,21 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
{
base.LoadComplete();
Client.RoomChanged += OnRoomChanged;
OnRoomChanged();
Client.RoomUpdated += OnRoomUpdated;
OnRoomUpdated();
}
protected virtual void OnRoomChanged()
/// <summary>
/// Invoked when any change occurs to the multiplayer room.
/// </summary>
protected virtual void OnRoomUpdated()
{
}
protected override void Dispose(bool isDisposing)
{
if (Client != null)
Client.RoomChanged -= OnRoomChanged;
Client.RoomUpdated -= OnRoomUpdated;
base.Dispose(isDisposing);
}

View File

@ -135,9 +135,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
};
}
protected override void OnRoomChanged()
protected override void OnRoomUpdated()
{
base.OnRoomChanged();
base.OnRoomUpdated();
if (Room == null)
return;

View File

@ -36,9 +36,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Participants
};
}
protected override void OnRoomChanged()
protected override void OnRoomUpdated()
{
base.OnRoomChanged();
base.OnRoomUpdated();
if (Room == null)
panels.Clear();