1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-26 03:52:57 +08:00
osu-lazer/osu.Game/Overlays/Wiki/WikiArticlePage.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

81 lines
2.6 KiB
C#
Raw Normal View History

2021-06-04 10:29:10 +08:00
// 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 System;
using Markdig.Syntax;
2021-06-04 10:29:10 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Containers.Markdown;
2021-06-04 10:29:10 +08:00
using osu.Game.Overlays.Wiki.Markdown;
namespace osu.Game.Overlays.Wiki
{
public class WikiArticlePage : CompositeDrawable
2021-06-04 10:29:10 +08:00
{
public Container SidebarContainer { get; }
public WikiArticlePage(string currentPath, string markdown)
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
2021-06-04 12:35:23 +08:00
WikiSidebar sidebar;
InternalChild = new GridContainer
2021-06-04 10:29:10 +08:00
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
RowDimensions = new[]
2021-06-04 10:29:10 +08:00
{
new Dimension(GridSizeMode.AutoSize),
},
ColumnDimensions = new[]
{
new Dimension(GridSizeMode.AutoSize),
new Dimension(),
},
Content = new[]
{
new Drawable[]
2021-06-04 10:29:10 +08:00
{
SidebarContainer = new Container
2021-06-04 10:29:10 +08:00
{
AutoSizeAxes = Axes.X,
Child = sidebar = new WikiSidebar(),
2021-06-04 10:29:10 +08:00
},
new ArticleMarkdownContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
CurrentPath = currentPath,
Text = markdown,
DocumentMargin = new MarginPadding(0),
DocumentPadding = new MarginPadding
{
Vertical = 20,
Left = 30,
Right = 50,
},
OnAddHeading = sidebar.AddEntry,
}
},
2021-06-04 10:29:10 +08:00
},
};
}
private class ArticleMarkdownContainer : WikiMarkdownContainer
{
2021-06-04 16:21:44 +08:00
public Action<HeadingBlock, MarkdownHeading> OnAddHeading;
protected override MarkdownHeading CreateHeading(HeadingBlock headingBlock)
{
var heading = base.CreateHeading(headingBlock);
2021-06-04 16:21:44 +08:00
OnAddHeading(headingBlock, heading);
return heading;
}
}
2021-06-04 10:29:10 +08:00
}
}