2021-04-30 10:43:05 +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.
|
|
|
|
|
2021-04-30 11:35:40 +08:00
|
|
|
using osu.Framework.Allocation;
|
2021-04-30 10:43:05 +08:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2021-04-30 11:35:40 +08:00
|
|
|
using osu.Framework.Graphics.Containers.Markdown;
|
2021-04-30 10:43:05 +08:00
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Graphics.Containers.Markdown
|
|
|
|
{
|
2021-04-30 11:12:43 +08:00
|
|
|
public class OsuMarkdownListItem : CompositeDrawable
|
2021-04-30 10:43:05 +08:00
|
|
|
{
|
2021-04-30 11:39:48 +08:00
|
|
|
private readonly int level;
|
2021-04-30 10:47:25 +08:00
|
|
|
private const float default_left_padding = 20;
|
|
|
|
|
2021-04-30 11:35:40 +08:00
|
|
|
[Resolved]
|
|
|
|
private IMarkdownTextComponent parentTextComponent { get; set; }
|
|
|
|
|
2021-04-30 11:12:43 +08:00
|
|
|
public FillFlowContainer Content { get; }
|
|
|
|
|
2021-04-30 11:39:48 +08:00
|
|
|
public OsuMarkdownListItem(int level)
|
2021-04-30 10:43:05 +08:00
|
|
|
{
|
2021-04-30 11:39:48 +08:00
|
|
|
this.level = level;
|
|
|
|
|
2021-04-30 10:43:05 +08:00
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
RelativeSizeAxes = Axes.X;
|
2021-04-30 10:47:25 +08:00
|
|
|
Padding = new MarginPadding { Left = default_left_padding };
|
2021-04-30 11:12:43 +08:00
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
Content = new FillFlowContainer
|
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
Spacing = new Vector2(10, 10),
|
|
|
|
}
|
|
|
|
};
|
2021-04-30 10:43:05 +08:00
|
|
|
}
|
2021-04-30 11:35:40 +08:00
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load()
|
|
|
|
{
|
|
|
|
var marker = parentTextComponent.CreateSpriteText();
|
2021-04-30 11:40:06 +08:00
|
|
|
marker.Text = createTextMarker();
|
2021-04-30 11:35:40 +08:00
|
|
|
marker.Font = OsuFont.GetFont(size: marker.Font.Size / 2);
|
|
|
|
marker.Origin = Anchor.Centre;
|
|
|
|
marker.X = -default_left_padding / 2;
|
|
|
|
marker.Y = marker.Font.Size;
|
|
|
|
|
|
|
|
AddInternal(marker);
|
|
|
|
}
|
2021-04-30 11:40:06 +08:00
|
|
|
|
|
|
|
private string createTextMarker()
|
|
|
|
{
|
|
|
|
switch (level)
|
|
|
|
{
|
|
|
|
case 1:
|
|
|
|
return "●";
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
return "○";
|
|
|
|
|
|
|
|
default:
|
|
|
|
return "■";
|
|
|
|
}
|
|
|
|
}
|
2021-04-30 10:43:05 +08:00
|
|
|
}
|
|
|
|
}
|