2021-06-04 02:28:31 +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-06-04 04:09:20 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using osu.Framework.Allocation;
|
2021-06-04 03:16:49 +00:00
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2021-06-04 03:17:38 +00:00
|
|
|
using osu.Framework.Graphics.Containers.Markdown;
|
2021-06-04 03:16:49 +00:00
|
|
|
using osu.Game.Graphics;
|
2021-06-04 04:09:20 +00:00
|
|
|
using osu.Game.Graphics.Containers;
|
2021-06-04 03:16:49 +00:00
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
2021-06-04 02:28:31 +00:00
|
|
|
namespace osu.Game.Overlays.Wiki
|
|
|
|
{
|
|
|
|
public class WikiSidebar : OverlaySidebar
|
|
|
|
{
|
2021-06-04 03:16:49 +00:00
|
|
|
private FillFlowContainer tableOfContents;
|
|
|
|
|
|
|
|
protected override Drawable CreateContent() => new FillFlowContainer
|
|
|
|
{
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
|
|
|
new OsuSpriteText
|
|
|
|
{
|
|
|
|
Text = "CONTENTS",
|
|
|
|
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
|
|
|
|
},
|
|
|
|
tableOfContents = new FillFlowContainer
|
|
|
|
{
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|
2021-06-04 03:17:38 +00:00
|
|
|
|
|
|
|
public void AddToc(string title, MarkdownHeading heading, int level)
|
|
|
|
{
|
|
|
|
switch (level)
|
|
|
|
{
|
|
|
|
case 2:
|
2021-06-04 04:09:20 +00:00
|
|
|
tableOfContents.Add(new TocTitle(title));
|
2021-06-04 03:17:38 +00:00
|
|
|
break;
|
2021-06-04 04:12:42 +00:00
|
|
|
|
|
|
|
case 3:
|
|
|
|
tableOfContents.Add(new TocTitle(title, true));
|
|
|
|
break;
|
2021-06-04 03:17:38 +00:00
|
|
|
}
|
|
|
|
}
|
2021-06-04 04:09:20 +00:00
|
|
|
|
|
|
|
private class TocTitle : OsuHoverContainer
|
|
|
|
{
|
|
|
|
private readonly OsuSpriteText spriteText;
|
|
|
|
|
2021-06-04 04:12:42 +00:00
|
|
|
public TocTitle(string text, bool subtitle = false)
|
2021-06-04 04:09:20 +00:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
AutoSizeAxes = Axes.Y;
|
|
|
|
Child = spriteText = new OsuSpriteText
|
|
|
|
{
|
|
|
|
Text = text,
|
2021-06-04 04:12:42 +00:00
|
|
|
Font = OsuFont.GetFont(size: subtitle ? 12 : 15),
|
2021-06-04 04:09:20 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override IEnumerable<Drawable> EffectTargets => new Drawable[] { spriteText };
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(OverlayColourProvider colourProvider)
|
|
|
|
{
|
|
|
|
IdleColour = colourProvider.Light2;
|
|
|
|
HoverColour = colourProvider.Light1;
|
|
|
|
}
|
|
|
|
}
|
2021-06-04 02:28:31 +00:00
|
|
|
}
|
|
|
|
}
|