1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-07 05:47:18 +08:00

43 lines
1.2 KiB
C#
Raw Normal View History

// 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 14:01:06 +09:00
using osu.Framework.Allocation;
2019-02-21 19:04:31 +09:00
using osu.Framework.Bindables;
2018-12-21 14:01:06 +09: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 19:00:01 +09: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 14:01:06 +09:00
[Resolved(CanBeNull = true)]
2018-12-21 14:01:06 +09:00
private ChannelManager channelManager { get; set; }
2019-02-05 19:00:01 +09:00
public MatchChatDisplay()
2018-12-21 14:01:06 +09:00
: base(true)
{
}
protected override void LoadComplete()
{
base.LoadComplete();
channelId.BindValueChanged(_ => updateChannel(), true);
2018-12-21 14:37:05 +09:00
}
private void updateChannel()
{
if (roomId.Value == null || channelId.Value == 0)
return;
Channel.Value = channelManager?.JoinChannel(new Channel { Id = channelId.Value, Type = ChannelType.Multiplayer, Name = $"#lazermp_{roomId.Value}" });
2018-12-21 14:01:06 +09:00
}
}
}