2019-01-24 08:43:03 +00: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 05:01:06 +00:00
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
2019-02-21 10:04:31 +00:00
|
|
|
using osu.Framework.Bindables;
|
2018-12-21 05:01:06 +00:00
|
|
|
using osu.Game.Online.Chat;
|
2020-12-25 04:38:11 +00:00
|
|
|
using osu.Game.Online.Rooms;
|
2018-12-21 05:01:06 +00:00
|
|
|
|
2020-12-25 15:50:00 +00:00
|
|
|
namespace osu.Game.Screens.OnlinePlay.Match.Components
|
2018-12-21 05:01:06 +00:00
|
|
|
{
|
|
|
|
public class MatchChatDisplay : StandAloneChatDisplay
|
|
|
|
{
|
2019-02-05 10:00:01 +00: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 05:01:06 +00:00
|
|
|
|
2018-12-22 05:38:46 +00:00
|
|
|
[Resolved(CanBeNull = true)]
|
2018-12-21 05:01:06 +00:00
|
|
|
private ChannelManager channelManager { get; set; }
|
|
|
|
|
2019-02-05 10:00:01 +00:00
|
|
|
public MatchChatDisplay()
|
2018-12-21 05:01:06 +00:00
|
|
|
: base(true)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2019-03-07 06:35:57 +00:00
|
|
|
channelId.BindValueChanged(_ => updateChannel(), true);
|
2018-12-21 05:37:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void updateChannel()
|
|
|
|
{
|
2019-03-07 06:35:57 +00:00
|
|
|
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 05:01:06 +00:00
|
|
|
}
|
2021-01-21 06:42:23 +00:00
|
|
|
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
{
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
channelManager?.LeaveChannel(Channel.Value);
|
|
|
|
}
|
2018-12-21 05:01:06 +00:00
|
|
|
}
|
|
|
|
}
|