From d90eb2cdce7386926b58439e65cb24ceacc8f904 Mon Sep 17 00:00:00 2001 From: FreezyLemon Date: Thu, 7 Dec 2017 16:26:28 +0100 Subject: [PATCH] Moved "Does this channel exist" check to ChatLine so that if a #name does not exist as a channel, it does not get added as a link (and does not contain a URL or anything else to prevent jankiness) --- osu.Game/Overlays/Chat/ChatLine.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Chat/ChatLine.cs b/osu.Game/Overlays/Chat/ChatLine.cs index 475a49b12e..db7c255eb4 100644 --- a/osu.Game/Overlays/Chat/ChatLine.cs +++ b/osu.Game/Overlays/Chat/ChatLine.cs @@ -102,8 +102,9 @@ namespace osu.Game.Overlays.Chat } [BackgroundDependencyLoader(true)] - private void load(OsuColour colours) + private void load(OsuColour colours, ChatOverlay chat) { + this.chat = chat; customUsernameColour = colours.ChatBlue; urlColour = colours.Blue; } @@ -204,6 +205,8 @@ namespace osu.Game.Overlays.Chat FinishTransforms(true); } + private ChatOverlay chat; + private void updateMessageContent() { this.FadeTo(message is LocalEchoMessage ? 0.4f : 1.0f, 500, Easing.OutQuint); @@ -232,6 +235,17 @@ namespace osu.Game.Overlays.Chat contentFlow.AddText(message.Content.Substring(prevIndex, link.Index - prevIndex)); prevIndex = link.Index + link.Length; + // If a channel doesn't exist, add it as normal text instead + if (link.Url.StartsWith("osu://chan/")) + { + var channelName = link.Url.Substring(11).Split('/')[0]; + if (chat.AvailableChannels.TrueForAll(c => c.Name != channelName)) + { + contentFlow.AddText(message.Content.Substring(link.Index, link.Length)); + continue; + } + } + contentFlow.AddLink(message.Content.Substring(link.Index, link.Length), link.Url, sprite => { if (message.IsAction)