1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-21 18:42:56 +08:00
osu-lazer/osu.Game/Screens/Ranking/Expanded/Statistics/StatisticDisplay.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

102 lines
3.5 KiB
C#
Raw Normal View History

2020-03-17 16:25:24 +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.
2022-06-17 15:37:17 +08:00
#nullable disable
2020-03-17 16:25:24 +08:00
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Extensions.LocalisationExtensions;
2020-03-17 16:25:24 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
2020-03-18 16:21:57 +08:00
using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
2020-03-17 16:25:24 +08:00
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
namespace osu.Game.Screens.Ranking.Expanded.Statistics
{
2020-03-17 16:34:16 +08:00
/// <summary>
/// A statistic from the score to be displayed in the <see cref="ExpandedPanelMiddleContent"/>.
/// </summary>
2020-03-17 16:25:24 +08:00
public abstract partial class StatisticDisplay : CompositeDrawable
{
2020-03-18 16:21:57 +08:00
protected SpriteText HeaderText { get; private set; }
2020-03-17 16:25:24 +08:00
private readonly LocalisableString header;
2020-03-17 16:25:24 +08:00
private Drawable content;
2020-03-17 16:34:16 +08:00
/// <summary>
/// Creates a new <see cref="StatisticDisplay"/>.
/// </summary>
/// <param name="header">The name of the statistic.</param>
protected StatisticDisplay(LocalisableString header)
2020-03-17 16:25:24 +08:00
{
this.header = header;
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
}
[BackgroundDependencyLoader]
private void load()
{
InternalChild = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical,
Children = new[]
{
new CircularContainer
{
RelativeSizeAxes = Axes.X,
Height = 12,
Masking = true,
Children = new Drawable[]
{
new Box
{
RelativeSizeAxes = Axes.Both,
Colour = Color4Extensions.FromHex("#222")
},
2020-03-18 16:21:57 +08:00
HeaderText = new OsuSpriteText
2020-03-17 16:25:24 +08:00
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Font = OsuFont.Torus.With(size: 12, weight: FontWeight.SemiBold),
Text = header.ToUpper(),
2020-03-17 16:25:24 +08:00
}
}
},
new Container
{
Anchor = Anchor.TopCentre,
Origin = Anchor.TopCentre,
AutoSizeAxes = Axes.Both,
Children = new[]
{
content = CreateContent().With(d =>
{
d.Anchor = Anchor.TopCentre;
d.Origin = Anchor.TopCentre;
d.Alpha = 0;
d.AlwaysPresent = true;
}),
}
}
}
};
}
2020-03-17 16:34:16 +08:00
/// <summary>
/// Shows the statistic value.
/// </summary>
2020-03-17 16:25:24 +08:00
public virtual void Appear() => content.FadeIn(100);
2020-03-17 16:34:16 +08:00
/// <summary>
/// Creates the content for this <see cref="StatisticDisplay"/>.
/// </summary>
2020-03-17 16:25:24 +08:00
protected abstract Drawable CreateContent();
}
}