Merge branch 'markdown-link' into markdown-wiki

This commit is contained in:
Gagah Pangeran Rosfatiputra
2021-05-26 14:55:32 +07:00
2 changed files with 16 additions and 11 deletions

View File

@ -23,10 +23,14 @@ namespace osu.Game.Graphics.Containers.Markdown
LineSpacing = 21; LineSpacing = 21;
} }
[BackgroundDependencyLoader] protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
private void load(IAPIProvider api)
{ {
var api = parent.Get<IAPIProvider>();
// needs to be set before the base BDL call executes to avoid invalidating any already populated markdown content.
DocumentUrl = api.WebsiteRootUrl; DocumentUrl = api.WebsiteRootUrl;
return base.CreateChildDependencies(parent);
} }
protected override void AddMarkdownComponent(IMarkdownObject markdownObject, FillFlowContainer container, int level) protected override void AddMarkdownComponent(IMarkdownObject markdownObject, FillFlowContainer container, int level)

View File

@ -16,28 +16,29 @@ namespace osu.Game.Graphics.Containers.Markdown
[Resolved(canBeNull: true)] [Resolved(canBeNull: true)]
private OsuGame game { get; set; } private OsuGame game { get; set; }
protected string Text; private readonly string text;
protected string Title; private readonly string title;
public OsuMarkdownLinkText(string text, LinkInline linkInline) public OsuMarkdownLinkText(string text, LinkInline linkInline)
: base(text, linkInline) : base(text, linkInline)
{ {
Text = text; this.text = text;
Title = linkInline.Title; title = linkInline.Title;
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider) private void load()
{ {
var text = CreateSpriteText().With(t => t.Text = Text); var textDrawable = CreateSpriteText().With(t => t.Text = text);
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
text, textDrawable,
new OsuMarkdownLinkCompiler(new[] { text }) new OsuMarkdownLinkCompiler(new[] { textDrawable })
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Action = OnLinkPressed, Action = OnLinkPressed,
TooltipText = Title ?? Url, TooltipText = title ?? Url,
} }
}; };
} }