1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-16 19:13:22 +08:00
osu-lazer/osu.Game/Screens/Multi/Match/Components/MatchChatDisplay.cs
Dean Herbert 452caabd40
Apply suggestions from code review
Co-Authored-By: smoogipoo <1329837+smoogipoo@users.noreply.github.com>
2019-02-22 17:06:49 +09:00

41 lines
1.2 KiB
C#

// 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.Allocation;
using osu.Framework.Bindables;
using osu.Game.Online.Chat;
using osu.Game.Online.Multiplayer;
namespace osu.Game.Screens.Multi.Match.Components
{
public class MatchChatDisplay : StandAloneChatDisplay
{
[Resolved(typeof(Room), nameof(Room.RoomID))]
private Bindable<int?> roomId { get; set; }
[Resolved(typeof(Room), nameof(Room.ChannelId))]
private Bindable<int> channelId { get; set; }
[Resolved(CanBeNull = true)]
private ChannelManager channelManager { get; set; }
public MatchChatDisplay()
: base(true)
{
}
protected override void LoadComplete()
{
base.LoadComplete();
roomId.BindValueChanged(_ => updateChannel(), true);
}
private void updateChannel()
{
if (roomId.Value != null)
Channel.Value = channelManager?.JoinChannel(new Channel { Id = channelId.Value, Type = ChannelType.Multiplayer, Name = $"#mp_{roomId.Value}" });
}
}
}