1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 20:07:25 +08:00

Fix WikiPanelContainer causing poor performance

This commit is contained in:
Andrei Zavatski 2024-03-09 00:51:33 +03:00
parent 612bc66e86
commit 26c97ef733

View File

@ -3,7 +3,6 @@
#nullable disable #nullable disable
using System;
using Markdig.Syntax; using Markdig.Syntax;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
@ -22,29 +21,61 @@ using osuTK.Graphics;
namespace osu.Game.Overlays.Wiki namespace osu.Game.Overlays.Wiki
{ {
public partial class WikiPanelContainer : Container public partial class WikiPanelContainer : CompositeDrawable
{ {
private WikiPanelMarkdownContainer panelContainer; private const float padding = 3;
private readonly string text; private readonly string text;
private readonly bool isFullWidth; private readonly bool isFullWidth;
public WikiPanelContainer(string text, bool isFullWidth = false) public WikiPanelContainer(string text, bool isFullWidth = false)
{ {
this.text = text; this.text = text;
this.isFullWidth = isFullWidth; this.isFullWidth = isFullWidth;
RelativeSizeAxes = Axes.X;
Padding = new MarginPadding(3);
} }
private PanelBackground background;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider, IAPIProvider api) private void load(IAPIProvider api)
{ {
Children = new Drawable[] RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
InternalChildren = new Drawable[]
{ {
background = new PanelBackground
{
BypassAutoSizeAxes = Axes.Both
},
new Container new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Padding = new MarginPadding(padding),
Child = new WikiPanelMarkdownContainer(isFullWidth)
{
CurrentPath = $@"{api.WebsiteRootUrl}/wiki/",
Text = text,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y
}
}
};
}
protected override void Update()
{
base.Update();
background.Size = Parent!.DrawSize * new Vector2(Size.X, 1);
}
private partial class PanelBackground : CompositeDrawable
{
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
Padding = new MarginPadding(padding);
InternalChild = new Container
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Masking = true, Masking = true,
@ -60,22 +91,9 @@ namespace osu.Game.Overlays.Wiki
{ {
Colour = colourProvider.Background4, Colour = colourProvider.Background4,
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
}, }
}, };
panelContainer = new WikiPanelMarkdownContainer(isFullWidth) }
{
CurrentPath = $@"{api.WebsiteRootUrl}/wiki/",
Text = text,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
}
};
}
protected override void Update()
{
base.Update();
Height = Math.Max(panelContainer.Height, Parent!.DrawHeight);
} }
private partial class WikiPanelMarkdownContainer : WikiMarkdownContainer private partial class WikiPanelMarkdownContainer : WikiMarkdownContainer