2018-11-16 13:22:42 +08:00
|
|
|
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
|
|
using System.Linq;
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Configuration;
|
|
|
|
using osu.Game.Online.Chat;
|
2019-02-02 17:29:20 +08:00
|
|
|
using osu.Game.Overlays.Chat;
|
2018-11-16 18:43:54 +08:00
|
|
|
using osu.Game.Tournament.IPC;
|
2018-11-22 09:25:30 +08:00
|
|
|
using osuTK.Graphics;
|
2018-11-16 13:22:42 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Tournament.Components
|
|
|
|
{
|
2018-12-20 15:50:38 +08:00
|
|
|
public class MatchChatDisplay : StandAloneChatDisplay
|
2018-11-16 13:22:42 +08:00
|
|
|
{
|
2018-11-16 18:43:54 +08:00
|
|
|
private readonly Bindable<string> chatChannel = new Bindable<string>();
|
|
|
|
|
2019-02-02 17:29:20 +08:00
|
|
|
protected override ChatLine CreateMessage(Message message) => new MatchMessage(message);
|
2018-12-20 15:50:38 +08:00
|
|
|
|
2018-11-16 18:43:54 +08:00
|
|
|
private ChannelManager manager;
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader(true)]
|
|
|
|
private void load(MatchIPCInfo ipc)
|
|
|
|
{
|
|
|
|
if (ipc != null)
|
|
|
|
{
|
|
|
|
chatChannel.BindTo(ipc.ChatChannel);
|
|
|
|
chatChannel.BindValueChanged(channelString =>
|
|
|
|
{
|
|
|
|
if (string.IsNullOrWhiteSpace(channelString))
|
|
|
|
return;
|
|
|
|
|
|
|
|
int id = int.Parse(channelString);
|
|
|
|
|
2018-11-17 09:40:44 +08:00
|
|
|
if (id <= 0) return;
|
|
|
|
|
|
|
|
if (manager == null)
|
|
|
|
{
|
|
|
|
AddInternal(manager = new ChannelManager());
|
|
|
|
Channel.BindTo(manager.CurrentChannel);
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach (var ch in manager.JoinedChannels.ToList())
|
|
|
|
manager.LeaveChannel(ch);
|
|
|
|
|
|
|
|
var channel = new Channel
|
2018-11-16 18:43:54 +08:00
|
|
|
{
|
|
|
|
Id = id,
|
|
|
|
Type = ChannelType.Public
|
|
|
|
};
|
|
|
|
|
|
|
|
manager.JoinChannel(channel);
|
|
|
|
manager.CurrentChannel.Value = channel;
|
|
|
|
}, true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-20 15:50:38 +08:00
|
|
|
protected class MatchMessage : StandAloneMessage
|
2018-11-16 13:22:42 +08:00
|
|
|
{
|
|
|
|
public MatchMessage(Message message)
|
2018-12-20 15:50:38 +08:00
|
|
|
: base(message)
|
2018-11-16 13:22:42 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(LadderInfo info)
|
|
|
|
{
|
2019-02-02 17:29:20 +08:00
|
|
|
//if (info.CurrentMatch.Value.Team1.Value.Players.Any(u => u.Id == Message.Sender.Id))
|
|
|
|
// ColourBox.Colour = red;
|
|
|
|
//else if (info.CurrentMatch.Value.Team2.Value.Players.Any(u => u.Id == Message.Sender.Id))
|
|
|
|
// ColourBox.Colour = blue;
|
|
|
|
//else if (Message.Sender.Colour != null)
|
|
|
|
// SenderText.Colour = ColourBox.Colour = OsuColour.FromHex(Message.Sender.Colour);
|
2018-11-16 13:22:42 +08:00
|
|
|
}
|
2018-11-17 20:27:02 +08:00
|
|
|
|
2018-12-20 15:50:38 +08:00
|
|
|
private readonly Color4 red = new Color4(186, 0, 18, 255);
|
|
|
|
private readonly Color4 blue = new Color4(17, 136, 170, 255);
|
2018-11-17 20:27:02 +08:00
|
|
|
}
|
2018-11-16 13:22:42 +08:00
|
|
|
}
|
|
|
|
}
|