1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-23 12:47:24 +08:00
osu-lazer/osu.Game.Tournament/Components/TournamentMatchChatDisplay.cs

94 lines
3.0 KiB
C#
Raw Normal View History

2019-03-04 12:24:19 +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-11-16 13:22:42 +08:00
using System.Linq;
using osu.Framework.Allocation;
2019-03-02 12:40:43 +08:00
using osu.Framework.Bindables;
2019-06-14 15:57:29 +08:00
using osu.Framework.Graphics;
2018-11-16 13:22:42 +08:00
using osu.Game.Online.Chat;
using osu.Game.Overlays.Chat;
using osu.Game.Tournament.IPC;
2019-06-18 13:51:48 +08:00
using osu.Game.Tournament.Models;
2019-06-14 15:57:29 +08:00
using osuTK;
using osuTK.Graphics;
2018-11-16 13:22:42 +08:00
namespace osu.Game.Tournament.Components
{
2019-06-18 12:44:38 +08:00
public class TournamentMatchChatDisplay : StandAloneChatDisplay
2018-11-16 13:22:42 +08:00
{
private readonly Bindable<string> chatChannel = new Bindable<string>();
private ChannelManager manager;
2019-06-18 12:44:38 +08:00
public TournamentMatchChatDisplay()
2019-06-14 15:57:29 +08:00
{
RelativeSizeAxes = Axes.X;
Y = 100;
Size = new Vector2(0.45f, 112);
Margin = new MarginPadding(10);
Anchor = Anchor.BottomCentre;
Origin = Anchor.BottomCentre;
}
[BackgroundDependencyLoader(true)]
private void load(MatchIPCInfo ipc)
{
if (ipc != null)
{
chatChannel.BindTo(ipc.ChatChannel);
2019-03-02 12:40:43 +08:00
chatChannel.BindValueChanged(c =>
{
2019-03-02 12:40:43 +08:00
if (string.IsNullOrWhiteSpace(c.NewValue))
return;
2019-03-02 12:40:43 +08:00
int id = int.Parse(c.NewValue);
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
{
Id = id,
Type = ChannelType.Public
};
manager.JoinChannel(channel);
manager.CurrentChannel.Value = channel;
}, true);
}
}
2019-06-13 16:04:57 +08:00
protected override ChatLine CreateMessage(Message message) => new MatchMessage(message);
protected class MatchMessage : StandAloneMessage
2018-11-16 13:22:42 +08:00
{
public MatchMessage(Message message)
: base(message)
2018-11-16 13:22:42 +08:00
{
}
[BackgroundDependencyLoader]
private void load(LadderInfo info)
{
//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
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
}
}