osu/osu.Game/Overlays/Comments/CommentMarkdownContainer.cs

49 lines
1.5 KiB
C#
Raw Normal View History

2021-07-26 11:18:33 +00: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.
2021-07-26 14:07:35 +00:00
using Markdig.Syntax;
2021-07-26 11:18:33 +00:00
using Markdig.Syntax.Inlines;
using osu.Framework.Graphics.Containers.Markdown;
using osu.Game.Graphics.Containers.Markdown;
namespace osu.Game.Overlays.Comments
{
public class CommentMarkdownContainer : OsuMarkdownContainer
{
public override MarkdownTextFlowContainer CreateTextFlow() => new CommentMarkdownTextFlowContainer();
2021-07-26 14:07:35 +00:00
protected override MarkdownHeading CreateHeading(HeadingBlock headingBlock) => new CommentMarkdownHeading(headingBlock);
2021-07-26 11:18:33 +00:00
private class CommentMarkdownTextFlowContainer : OsuMarkdownTextFlowContainer
{
// Don't render image in comment for now
protected override void AddImage(LinkInline linkInline) { }
}
2021-07-26 14:07:35 +00:00
private class CommentMarkdownHeading : OsuMarkdownHeading
{
public CommentMarkdownHeading(HeadingBlock headingBlock)
: base(headingBlock)
{
}
protected override float GetFontSizeByLevel(int level)
{
float defaultFontSize = base.GetFontSizeByLevel(6);
2021-07-26 14:07:35 +00:00
switch (level)
{
case 1:
return 1.2f * defaultFontSize;
case 2:
return 1.1f * defaultFontSize;
default:
return defaultFontSize;
}
}
}
2021-07-26 11:18:33 +00:00
}
}