mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 16:02:58 +08:00
Allow customizing link style by override in LinkFlowContainer
This commit is contained in:
parent
2c6ee0ebf7
commit
9637326f0c
@ -87,23 +87,25 @@ namespace osu.Game.Graphics.Containers
|
|||||||
|
|
||||||
private void createLink(IEnumerable<Drawable> drawables, LinkDetails link, string tooltipText, Action action = null)
|
private void createLink(IEnumerable<Drawable> drawables, LinkDetails link, string tooltipText, Action action = null)
|
||||||
{
|
{
|
||||||
AddInternal(new DrawableLinkCompiler(drawables.OfType<SpriteText>().ToList())
|
var linkCompiler = CreateLinkCompiler(drawables.OfType<SpriteText>());
|
||||||
|
linkCompiler.RelativeSizeAxes = Axes.Both;
|
||||||
|
linkCompiler.TooltipText = tooltipText;
|
||||||
|
linkCompiler.Action = () =>
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
if (action != null)
|
||||||
TooltipText = tooltipText,
|
action();
|
||||||
Action = () =>
|
else if (game != null)
|
||||||
{
|
game.HandleLink(link);
|
||||||
if (action != null)
|
// fallback to handle cases where OsuGame is not available, ie. tournament client.
|
||||||
action();
|
else if (link.Action == LinkAction.External)
|
||||||
else if (game != null)
|
host.OpenUrlExternally(link.Argument);
|
||||||
game.HandleLink(link);
|
};
|
||||||
// fallback to handle cases where OsuGame is not available, ie. tournament client.
|
|
||||||
else if (link.Action == LinkAction.External)
|
AddInternal(linkCompiler);
|
||||||
host.OpenUrlExternally(link.Argument);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual DrawableLinkCompiler CreateLinkCompiler(IEnumerable<SpriteText> parts) => new DrawableLinkCompiler(parts);
|
||||||
|
|
||||||
// We want the compilers to always be visible no matter where they are, so RelativeSizeAxes is used.
|
// 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.
|
// 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.
|
// Since the compilers don't display any content and don't affect the layout, it's simplest to exclude them from the flow.
|
||||||
|
Loading…
Reference in New Issue
Block a user