1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:52:53 +08:00

Add method to add arbitrary drawables as links

This commit is contained in:
smoogipoo 2018-12-20 20:01:58 +09:00
parent deaf4ab4a1
commit f8d25a1b6c

View File

@ -7,6 +7,7 @@ using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics.Sprites;
using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Framework.Logging;
using osu.Game.Overlays;
using osu.Game.Overlays.Notifications;
@ -61,8 +62,19 @@ namespace osu.Game.Graphics.Containers
}
public void AddLink(string text, string url, LinkAction linkType = LinkAction.External, string linkArgument = null, string tooltipText = null, Action<SpriteText> creationParameters = null)
=> createLink(AddText(text, creationParameters), text, url, linkType, linkArgument, tooltipText);
public void AddLink(IEnumerable<SpriteText> text, string url, LinkAction linkType = LinkAction.External, string linkArgument = null, string tooltipText = null)
{
AddInternal(new DrawableLinkCompiler(AddText(text, creationParameters).OfType<SpriteText>().ToList())
foreach (var t in text)
AddArbitraryDrawable(t);
createLink(text, null, url, linkType, linkArgument, tooltipText);
}
private void createLink(IEnumerable<Drawable> drawables, string text, string url, LinkAction linkType = LinkAction.External, string linkArgument = null, string tooltipText = null)
{
AddInternal(new DrawableLinkCompiler(drawables.OfType<SpriteText>().ToList())
{
TooltipText = tooltipText ?? (url != text ? url : string.Empty),
Action = () =>