mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 08:20:00 +09: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:
@ -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);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user