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
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
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;
|
2022-06-08 17:54:23 +08:00
|
|
|
using osu.Game.Online.API;
|
2018-11-16 13:22:42 +08:00
|
|
|
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;
|
2019-06-18 13:51:48 +08:00
|
|
|
using osu.Game.Tournament.Models;
|
2018-11-16 13:22:42 +08:00
|
|
|
|
|
|
|
namespace osu.Game.Tournament.Components
|
|
|
|
{
|
2022-11-24 13:32:20 +08:00
|
|
|
public partial class TournamentMatchChatDisplay : 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>();
|
|
|
|
|
|
|
|
private ChannelManager manager;
|
|
|
|
|
2019-06-18 12:44:38 +08:00
|
|
|
public TournamentMatchChatDisplay()
|
2019-06-14 15:57:29 +08:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X;
|
2020-03-08 13:46:09 +08:00
|
|
|
Height = 144;
|
2020-03-07 14:28:19 +08:00
|
|
|
Anchor = Anchor.BottomLeft;
|
|
|
|
Origin = Anchor.BottomLeft;
|
|
|
|
|
|
|
|
CornerRadius = 0;
|
2019-06-14 15:57:29 +08:00
|
|
|
}
|
|
|
|
|
2018-11-16 18:43:54 +08:00
|
|
|
[BackgroundDependencyLoader(true)]
|
2022-06-08 17:54:23 +08:00
|
|
|
private void load(MatchIPCInfo ipc, IAPIProvider api)
|
2018-11-16 18:43:54 +08:00
|
|
|
{
|
|
|
|
if (ipc != null)
|
|
|
|
{
|
|
|
|
chatChannel.BindTo(ipc.ChatChannel);
|
2019-03-02 12:40:43 +08:00
|
|
|
chatChannel.BindValueChanged(c =>
|
2018-11-16 18:43:54 +08:00
|
|
|
{
|
2019-03-02 12:40:43 +08:00
|
|
|
if (string.IsNullOrWhiteSpace(c.NewValue))
|
2018-11-16 18:43:54 +08:00
|
|
|
return;
|
|
|
|
|
2019-03-02 12:40:43 +08:00
|
|
|
int id = int.Parse(c.NewValue);
|
2018-11-16 18:43:54 +08:00
|
|
|
|
2018-11-17 09:40:44 +08:00
|
|
|
if (id <= 0) return;
|
|
|
|
|
|
|
|
if (manager == null)
|
|
|
|
{
|
2022-11-04 17:51:00 +08:00
|
|
|
AddInternal(manager = new ChannelManager(api));
|
2018-11-17 09:40:44 +08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-08 17:11:57 +08:00
|
|
|
public void Expand() => this.FadeIn(300);
|
|
|
|
|
|
|
|
public void Contract() => this.FadeOut(200);
|
|
|
|
|
2019-06-13 16:04:57 +08:00
|
|
|
protected override ChatLine CreateMessage(Message message) => new MatchMessage(message);
|
|
|
|
|
2020-03-23 11:03:33 +08:00
|
|
|
protected override StandAloneDrawableChannel CreateDrawableChannel(Channel channel) => new MatchChannel(channel);
|
|
|
|
|
2022-11-24 13:32:20 +08:00
|
|
|
public partial class MatchChannel : StandAloneDrawableChannel
|
2020-03-23 11:03:33 +08:00
|
|
|
{
|
|
|
|
public MatchChannel(Channel channel)
|
|
|
|
: base(channel)
|
|
|
|
{
|
|
|
|
ScrollbarVisible = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-11-24 13:32:20 +08:00
|
|
|
protected partial 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
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
private void load(LadderInfo info)
|
|
|
|
{
|
2020-03-07 14:28:19 +08: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)
|
2020-03-11 09:18:41 +08:00
|
|
|
// SenderText.Colour = ColourBox.Colour = Color4Extensions.FromHex(Message.Sender.Colour);
|
2018-11-16 13:22:42 +08:00
|
|
|
}
|
2018-11-17 20:27:02 +08:00
|
|
|
}
|
2018-11-16 13:22:42 +08:00
|
|
|
}
|
|
|
|
}
|