mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 00:09:55 +09:00
Support SpriteText for LinkFlowContainer
This commit is contained in:
@ -67,6 +67,13 @@ namespace osu.Game.Graphics.Containers
|
||||
createLink(text, new LinkDetails(action, linkArgument), tooltipText);
|
||||
}
|
||||
|
||||
public void AddLink(SpriteText text, LinkAction action = LinkAction.External, string linkArgument = null, string tooltipText = null)
|
||||
{
|
||||
AddArbitraryDrawable(text);
|
||||
|
||||
createLink(text, new LinkDetails(action, linkArgument), tooltipText);
|
||||
}
|
||||
|
||||
public void AddUserLink(User user, Action<SpriteText> creationParameters = null)
|
||||
=> createLink(AddText(user.Username, creationParameters), new LinkDetails(LinkAction.OpenUserProfile, user.Id.ToString()), "view profile");
|
||||
|
||||
@ -86,6 +93,22 @@ namespace osu.Game.Graphics.Containers
|
||||
});
|
||||
}
|
||||
|
||||
private void createLink(Drawable drawable, LinkDetails link, string tooltipText, Action action = null)
|
||||
{
|
||||
AddInternal(new DrawableLinkCompiler(drawable)
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
TooltipText = tooltipText,
|
||||
Action = () =>
|
||||
{
|
||||
if (action != null)
|
||||
action();
|
||||
else
|
||||
game?.HandleLink(link);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
// We want the compilers to always be visible no matter where they are, so RelativeSizeAxes is used.
|
||||
// However due to https://github.com/ppy/osu-framework/issues/2073, it's possible for the compilers to be relative size in the flow's auto-size axes - an unsupported operation.
|
||||
// Since the compilers don't display any content and don't affect the layout, it's simplest to exclude them from the flow.
|
||||
|
Reference in New Issue
Block a user