mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 19:22:54 +08:00
Added new OsuLinkSpriteText.TextColour property that sets the internal content (OsuHoverContainer)'s colour instead of the whole container, so that text colour is always changed through that (e.g. link colouring, link hover fade).
Implemented it to be used when adding text to an OsuLinkTextFlowContainer.
This commit is contained in:
parent
319f43e209
commit
cf96323980
@ -1,6 +1,8 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// 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();
|
||||
|
||||
/// <summary>
|
||||
/// The colour for normal text (links ignore this). This should be set before text is added.
|
||||
/// <para>Default is white.</para>
|
||||
/// </summary>
|
||||
public ColourInfo? TextColour;
|
||||
|
||||
public void AddLink(string text, string url, Action<SpriteText> creationParameters = null)
|
||||
{
|
||||
AddText(text, link =>
|
||||
@ -40,5 +48,16 @@ namespace osu.Game.Graphics.Containers
|
||||
creationParameters?.Invoke(link);
|
||||
});
|
||||
}
|
||||
|
||||
public IEnumerable<SpriteText> AddText(string text, Action<SpriteText> creationParameters = null)
|
||||
{
|
||||
return base.AddText(text, sprite =>
|
||||
{
|
||||
if (TextColour.HasValue)
|
||||
((OsuLinkSpriteText)sprite).TextColour = TextColour.Value;
|
||||
|
||||
creationParameters?.Invoke(sprite);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user