mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 07:42:57 +08:00
Fix WikiPanelContainer causing poor performance
This commit is contained in:
parent
612bc66e86
commit
26c97ef733
@ -3,7 +3,6 @@
|
||||
|
||||
#nullable disable
|
||||
|
||||
using System;
|
||||
using Markdig.Syntax;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
@ -22,29 +21,61 @@ using osuTK.Graphics;
|
||||
|
||||
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 bool isFullWidth;
|
||||
|
||||
public WikiPanelContainer(string text, bool isFullWidth = false)
|
||||
{
|
||||
this.text = text;
|
||||
this.isFullWidth = isFullWidth;
|
||||
|
||||
RelativeSizeAxes = Axes.X;
|
||||
Padding = new MarginPadding(3);
|
||||
}
|
||||
|
||||
private PanelBackground background;
|
||||
|
||||
[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
|
||||
{
|
||||
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,
|
||||
Masking = true,
|
||||
@ -60,22 +91,9 @@ namespace osu.Game.Overlays.Wiki
|
||||
{
|
||||
Colour = colourProvider.Background4,
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user