mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 08:02:55 +08:00
Don't bind to RoomId where it's expected to be constant
This commit is contained in:
parent
df170afbc4
commit
16ddbcd208
@ -10,36 +10,36 @@ namespace osu.Game.Screens.OnlinePlay.Match.Components
|
||||
{
|
||||
public class MatchChatDisplay : StandAloneChatDisplay
|
||||
{
|
||||
private readonly IBindable<long?> roomId = new Bindable<long?>();
|
||||
private readonly IBindable<int> channelId = new Bindable<int>();
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private ChannelManager channelManager { get; set; }
|
||||
|
||||
private readonly Room room;
|
||||
private readonly bool leaveChannelOnDispose;
|
||||
|
||||
public MatchChatDisplay(Room room, bool leaveChannelOnDispose = true)
|
||||
: base(true)
|
||||
{
|
||||
this.room = room;
|
||||
this.leaveChannelOnDispose = leaveChannelOnDispose;
|
||||
|
||||
roomId.BindTo(room.RoomID);
|
||||
channelId.BindTo(room.ChannelId);
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
// Required for the time being since this component is created prior to the room being joined.
|
||||
channelId.BindTo(room.ChannelId);
|
||||
channelId.BindValueChanged(_ => updateChannel(), true);
|
||||
}
|
||||
|
||||
private void updateChannel()
|
||||
{
|
||||
if (roomId.Value == null || channelId.Value == 0)
|
||||
if (room.RoomID.Value == null || channelId.Value == 0)
|
||||
return;
|
||||
|
||||
Channel.Value = channelManager?.JoinChannel(new Channel { Id = channelId.Value, Type = ChannelType.Multiplayer, Name = $"#lazermp_{roomId.Value}" });
|
||||
Channel.Value = channelManager?.JoinChannel(new Channel { Id = channelId.Value, Type = ChannelType.Multiplayer, Name = $"#lazermp_{room.RoomID.Value}" });
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
|
@ -187,10 +187,11 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
|
||||
|
||||
protected override ResultsScreen CreateResults(ScoreInfo score)
|
||||
{
|
||||
Debug.Assert(RoomId.Value != null);
|
||||
Debug.Assert(Room.RoomID.Value != null);
|
||||
|
||||
return leaderboard.TeamScores.Count == 2
|
||||
? new MultiplayerTeamResultsScreen(score, RoomId.Value.Value, PlaylistItem, leaderboard.TeamScores)
|
||||
: new MultiplayerResultsScreen(score, RoomId.Value.Value, PlaylistItem);
|
||||
? new MultiplayerTeamResultsScreen(score, Room.RoomID.Value.Value, PlaylistItem, leaderboard.TeamScores)
|
||||
: new MultiplayerResultsScreen(score, Room.RoomID.Value.Value, PlaylistItem);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
|
@ -51,8 +51,8 @@ namespace osu.Game.Screens.OnlinePlay.Playlists
|
||||
|
||||
protected override ResultsScreen CreateResults(ScoreInfo score)
|
||||
{
|
||||
Debug.Assert(RoomId.Value != null);
|
||||
return new PlaylistsResultsScreen(score, RoomId.Value.Value, PlaylistItem, true);
|
||||
Debug.Assert(Room.RoomID.Value != null);
|
||||
return new PlaylistsResultsScreen(score, Room.RoomID.Value.Value, PlaylistItem, true);
|
||||
}
|
||||
|
||||
protected override async Task PrepareScoreForResultsAsync(Score score)
|
||||
|
@ -1,7 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Bindables;
|
||||
using System.Diagnostics;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Scoring;
|
||||
@ -13,8 +13,6 @@ namespace osu.Game.Screens.Play
|
||||
/// </summary>
|
||||
public abstract class RoomSubmittingPlayer : SubmittingPlayer
|
||||
{
|
||||
protected readonly IBindable<long?> RoomId = new Bindable<long?>();
|
||||
|
||||
protected readonly PlaylistItem PlaylistItem;
|
||||
protected readonly Room Room;
|
||||
|
||||
@ -23,18 +21,20 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
Room = room;
|
||||
PlaylistItem = playlistItem;
|
||||
|
||||
RoomId.BindTo(room.RoomID);
|
||||
}
|
||||
|
||||
protected override APIRequest<APIScoreToken> CreateTokenRequest()
|
||||
{
|
||||
if (!(RoomId.Value is long roomId))
|
||||
if (!(Room.RoomID.Value is long roomId))
|
||||
return null;
|
||||
|
||||
return new CreateRoomScoreRequest(roomId, PlaylistItem.ID, Game.VersionHash);
|
||||
}
|
||||
|
||||
protected override APIRequest<MultiplayerScore> CreateSubmissionRequest(Score score, long token) => new SubmitRoomScoreRequest(token, RoomId.Value ?? 0, PlaylistItem.ID, score.ScoreInfo);
|
||||
protected override APIRequest<MultiplayerScore> CreateSubmissionRequest(Score score, long token)
|
||||
{
|
||||
Debug.Assert(Room.RoomID.Value != null);
|
||||
return new SubmitRoomScoreRequest(token, Room.RoomID.Value.Value, PlaylistItem.ID, score.ScoreInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user