2019-01-24 16:43:03 +08:00
|
|
|
// 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.
|
2018-12-21 13:01:06 +08:00
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 18:04:31 +08:00
|
|
|
using osu.Framework.Bindables;
|
2018-12-21 13:01:06 +08:00
|
|
|
using osu.Game.Online.Chat;
|
|
|
|
using osu.Game.Online.Multiplayer;
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Multi.Match.Components
|
|
|
|
{
|
|
|
|
public class MatchChatDisplay : StandAloneChatDisplay
|
|
|
|
{
|
2019-02-05 18:00:01 +08:00
|
|
|
[Resolved(typeof(Room), nameof(Room.RoomID))]
|
|
|
|
private Bindable<int?> roomId { get; set; }
|
|
|
|
|
|
|
|
[Resolved(typeof(Room), nameof(Room.ChannelId))]
|
|
|
|
private Bindable<int> channelId { get; set; }
|
2018-12-21 13:01:06 +08:00
|
|
|
|
2018-12-22 13:38:46 +08:00
|
|
|
[Resolved(CanBeNull = true)]
|
2018-12-21 13:01:06 +08:00
|
|
|
private ChannelManager channelManager { get; set; }
|
|
|
|
|
2019-02-05 18:00:01 +08:00
|
|
|
public MatchChatDisplay()
|
2018-12-21 13:01:06 +08:00
|
|
|
: base(true)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2019-02-22 16:06:49 +08:00
|
|
|
roomId.BindValueChanged(_ => updateChannel(), true);
|
2018-12-21 13:37:05 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
private void updateChannel()
|
|
|
|
{
|
2019-02-05 18:00:01 +08:00
|
|
|
if (roomId.Value != null)
|
2019-02-21 17:56:34 +08:00
|
|
|
Channel.Value = channelManager?.JoinChannel(new Channel { Id = channelId.Value, Type = ChannelType.Multiplayer, Name = $"#mp_{roomId.Value}" });
|
2018-12-21 13:01:06 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|