mirror of
https://github.com/osukey/osukey.git
synced 2025-05-02 20:27:27 +09:00
Support SpriteText for LinkFlowContainer
This commit is contained in:
parent
38a7c590c4
commit
488001d570
@ -67,6 +67,13 @@ namespace osu.Game.Graphics.Containers
|
|||||||
createLink(text, new LinkDetails(action, linkArgument), tooltipText);
|
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)
|
public void AddUserLink(User user, Action<SpriteText> creationParameters = null)
|
||||||
=> createLink(AddText(user.Username, creationParameters), new LinkDetails(LinkAction.OpenUserProfile, user.Id.ToString()), "view profile");
|
=> 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.
|
// 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.
|
||||||
|
@ -31,6 +31,11 @@ namespace osu.Game.Online.Chat
|
|||||||
Parts = parts.ToList();
|
Parts = parts.ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public DrawableLinkCompiler(Drawable part)
|
||||||
|
{
|
||||||
|
Parts = new List<Drawable> { part };
|
||||||
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
|
@ -109,7 +109,7 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
difficultyIconContainer.Child = new DifficultyIcon(beatmap.Value, ruleset.Value, requiredMods) { Size = new Vector2(32) };
|
difficultyIconContainer.Child = new DifficultyIcon(beatmap.Value, ruleset.Value, requiredMods) { Size = new Vector2(32) };
|
||||||
|
|
||||||
beatmapText.Clear();
|
beatmapText.Clear();
|
||||||
beatmapText.AddLink(new List<SpriteText> { new OsuSpriteText { Text = Item.Beatmap.Value.ToRomanisableString() } },
|
beatmapText.AddLink(new OsuSpriteText { Text = Item.Beatmap.Value.ToRomanisableString() },
|
||||||
LinkAction.OpenBeatmap, Item.Beatmap.Value.OnlineBeatmapID.ToString());
|
LinkAction.OpenBeatmap, Item.Beatmap.Value.OnlineBeatmapID.ToString());
|
||||||
|
|
||||||
authorText.Clear();
|
authorText.Clear();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user