initial wiki notice container

This commit is contained in:
Gagah Pangeran Rosfatiputra 2021-05-21 16:04:08 +07:00
parent 5c1c43dea3
commit 292f314fee
No known key found for this signature in database
GPG Key ID: 25F6F17FD29031E2
2 changed files with 38 additions and 0 deletions

View File

@ -1,6 +1,9 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using Markdig.Extensions.Yaml;
using Markdig.Syntax;
using osu.Framework.Graphics.Containers;
using osu.Game.Graphics.Containers.Markdown;
namespace osu.Game.Overlays.Wiki.Markdown
@ -11,5 +14,21 @@ namespace osu.Game.Overlays.Wiki.Markdown
{
set => Schedule(() => DocumentUrl += $"wiki/{value}");
}
protected override void AddMarkdownComponent(IMarkdownObject markdownObject, FillFlowContainer container, int level)
{
switch (markdownObject)
{
case YamlFrontMatterBlock yamlFrontMatterBlock:
container.Add(CreateNotice(yamlFrontMatterBlock));
break;
default:
base.AddMarkdownComponent(markdownObject, container, level);
break;
}
}
protected virtual FillFlowContainer CreateNotice(YamlFrontMatterBlock yamlFrontMatterBlock) => new WikiNoticeContainer(yamlFrontMatterBlock);
}
}

View File

@ -0,0 +1,19 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using Markdig.Extensions.Yaml;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
namespace osu.Game.Overlays.Wiki.Markdown
{
public class WikiNoticeContainer : FillFlowContainer
{
public WikiNoticeContainer(YamlFrontMatterBlock yamlFrontMatterBlock)
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
Direction = FillDirection.Vertical;
}
}
}