osu/osu.Game.Tournament/Components/TournamentMatchChatDisplay.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

106 lines
3.4 KiB
C#
Raw Normal View History

2019-03-04 04:24:19 +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-11-16 05:22:42 +00:00
2022-06-17 07:37:17 +00:00
#nullable disable
2018-11-16 05:22:42 +00:00
using System.Linq;
using osu.Framework.Allocation;
2019-03-02 04:40:43 +00:00
using osu.Framework.Bindables;
2019-06-14 07:57:29 +00:00
using osu.Framework.Graphics;
using osu.Game.Online.API;
2018-11-16 05:22:42 +00:00
using osu.Game.Online.Chat;
using osu.Game.Overlays.Chat;
using osu.Game.Tournament.IPC;
2019-06-18 05:51:48 +00:00
using osu.Game.Tournament.Models;
2018-11-16 05:22:42 +00:00
namespace osu.Game.Tournament.Components
{
2019-06-18 04:44:38 +00:00
public partial class TournamentMatchChatDisplay : StandAloneChatDisplay
2018-11-16 05:22:42 +00:00
{
private readonly Bindable<string> chatChannel = new Bindable<string>();
private ChannelManager manager;
2019-06-18 04:44:38 +00:00
public TournamentMatchChatDisplay()
2019-06-14 07:57:29 +00:00
{
RelativeSizeAxes = Axes.X;
Height = 144;
2020-03-07 06:28:19 +00:00
Anchor = Anchor.BottomLeft;
Origin = Anchor.BottomLeft;
CornerRadius = 0;
2019-06-14 07:57:29 +00:00
}
[BackgroundDependencyLoader(true)]
private void load(MatchIPCInfo ipc, IAPIProvider api)
{
if (ipc != null)
{
chatChannel.BindTo(ipc.ChatChannel);
2019-03-02 04:40:43 +00:00
chatChannel.BindValueChanged(c =>
{
2019-03-02 04:40:43 +00:00
if (string.IsNullOrWhiteSpace(c.NewValue))
return;
2019-03-02 04:40:43 +00:00
int id = int.Parse(c.NewValue);
if (id <= 0) return;
if (manager == null)
{
AddInternal(manager = new ChannelManager(api));
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);
}
}
public void Expand() => this.FadeIn(300);
public void Contract() => this.FadeOut(200);
2019-06-13 08:04:57 +00:00
protected override ChatLine CreateMessage(Message message) => new MatchMessage(message);
protected override StandAloneDrawableChannel CreateDrawableChannel(Channel channel) => new MatchChannel(channel);
public partial class MatchChannel : StandAloneDrawableChannel
{
public MatchChannel(Channel channel)
: base(channel)
{
ScrollbarVisible = false;
}
}
protected partial class MatchMessage : StandAloneMessage
2018-11-16 05:22:42 +00:00
{
public MatchMessage(Message message)
: base(message)
2018-11-16 05:22:42 +00:00
{
}
private void load(LadderInfo info)
{
2020-03-07 06:28:19 +00:00
// if (info.CurrentMatch.Value.Team1.Value.Players.Any(u => u.Id == Message.Sender.Id))
// SenderText.Colour = TournamentGame.COLOUR_RED;
// else if (info.CurrentMatch.Value.Team2.Value.Players.Any(u => u.Id == Message.Sender.Id))
// SenderText.Colour = TournamentGame.COLOUR_BLUE;
// else if (Message.Sender.Colour != null)
// SenderText.Colour = ColourBox.Colour = Color4Extensions.FromHex(Message.Sender.Colour);
2018-11-16 05:22:42 +00:00
}
2018-11-17 12:27:02 +00:00
}
2018-11-16 05:22:42 +00:00
}
}