diff --git a/osu.Game/Graphics/Containers/OsuLinkTextFlowContainer.cs b/osu.Game/Graphics/Containers/OsuLinkTextFlowContainer.cs index 821d1bd0ce..559b3eef17 100644 --- a/osu.Game/Graphics/Containers/OsuLinkTextFlowContainer.cs +++ b/osu.Game/Graphics/Containers/OsuLinkTextFlowContainer.cs @@ -1,6 +1,8 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using OpenTK.Graphics; +using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Sprites; using osu.Framework.Input; @@ -32,6 +34,12 @@ namespace osu.Game.Graphics.Containers protected override SpriteText CreateSpriteText() => new T(); + /// + /// The colour for normal text (links ignore this). This should be set before text is added. + /// Default is white. + /// + public ColourInfo? TextColour; + public void AddLink(string text, string url, Action creationParameters = null) { AddText(text, link => @@ -40,5 +48,16 @@ namespace osu.Game.Graphics.Containers creationParameters?.Invoke(link); }); } + + public IEnumerable AddText(string text, Action creationParameters = null) + { + return base.AddText(text, sprite => + { + if (TextColour.HasValue) + ((OsuLinkSpriteText)sprite).TextColour = TextColour.Value; + + creationParameters?.Invoke(sprite); + }); + } } } diff --git a/osu.Game/Graphics/Sprites/OsuLinkSpriteText.cs b/osu.Game/Graphics/Sprites/OsuLinkSpriteText.cs index ddce36c77d..3727b79322 100644 --- a/osu.Game/Graphics/Sprites/OsuLinkSpriteText.cs +++ b/osu.Game/Graphics/Sprites/OsuLinkSpriteText.cs @@ -4,6 +4,7 @@ using OpenTK.Graphics; using osu.Framework.Allocation; using osu.Framework.Graphics; +using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Containers; using osu.Framework.Input; using osu.Game.Beatmaps; @@ -58,6 +59,12 @@ namespace osu.Game.Graphics.Sprites }); } + public ColourInfo TextColour + { + get { return Content.Colour; } + set { Content.Colour = value; } + } + [BackgroundDependencyLoader] private void load(BeatmapSetOverlay beatmapSetOverlay, ChatOverlay chat) { diff --git a/osu.Game/Overlays/Chat/ChatLine.cs b/osu.Game/Overlays/Chat/ChatLine.cs index fda23ca679..b6da2fbbce 100644 --- a/osu.Game/Overlays/Chat/ChatLine.cs +++ b/osu.Game/Overlays/Chat/ChatLine.cs @@ -198,7 +198,7 @@ namespace osu.Game.Overlays.Chat } }; if (message.IsAction && senderHasBackground) - contentFlow.Colour = OsuColour.FromHex(message.Sender.Colour); + contentFlow.TextColour = OsuColour.FromHex(message.Sender.Colour); updateMessageContent(); FinishTransforms(true); @@ -237,9 +237,7 @@ namespace osu.Game.Overlays.Chat if (message.IsAction) sprite.Font = @"Exo2.0-MediumItalic"; - // TODO: Somehow check (if channel link) that this is a real channel - sprite.Colour = urlColour; - // We want to use something that is unique to every formatted link, so I just use the position of the link + // We want to use something that is unique to every formatted link PER MESSAGE ((ChatLinkSpriteText)sprite).LinkId = link.Index; }); }