1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-07 05:38:21 +08:00
osu-lazer/osu.Game/Screens/Ranking/Statistics/StatisticItem.cs

61 lines
2.7 KiB
C#
Raw Normal View History

2020-06-19 19:31:52 +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
2022-02-02 13:29:18 +08:00
using System;
2020-06-19 19:31:52 +08:00
using JetBrains.Annotations;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Localisation;
2020-06-19 19:31:52 +08:00
namespace osu.Game.Screens.Ranking.Statistics
{
/// <summary>
/// An item to be displayed in a row of statistics inside the results screen.
/// </summary>
2020-06-19 19:31:52 +08:00
public class StatisticItem
{
/// <summary>
/// The name of this item.
/// </summary>
2022-08-21 09:48:35 +08:00
public readonly LocalisableString Name;
/// <summary>
2022-02-02 17:29:03 +08:00
/// A function returning the <see cref="Drawable"/> content to be displayed.
/// </summary>
2022-02-02 17:29:03 +08:00
public readonly Func<Drawable> CreateContent;
/// <summary>
/// The <see cref="Dimension"/> of this row. This can be thought of as the column dimension of an encompassing <see cref="GridContainer"/>.
/// </summary>
2020-06-19 19:31:52 +08:00
public readonly Dimension Dimension;
2022-02-02 13:29:18 +08:00
/// <summary>
2022-02-02 17:29:03 +08:00
/// Whether this item requires hit events. If true, <see cref="CreateContent"/> will not be called if no hit events are available.
2022-02-02 13:29:18 +08:00
/// </summary>
public readonly bool RequiresHitEvents;
[Obsolete("Use constructor which takes creation function instead.")] // Can be removed 20220803.
public StatisticItem([NotNull] string name, [NotNull] Drawable content, [CanBeNull] Dimension dimension = null)
: this(name, () => content, true, dimension)
{
}
/// <summary>
/// Creates a new <see cref="StatisticItem"/>, to be displayed inside a <see cref="StatisticRow"/> in the results screen.
/// </summary>
2022-08-18 04:03:35 +08:00
/// <param name="name">The name of the item. Can be <see langword="null"/> to hide the item header.</param>
2022-02-02 17:29:03 +08:00
/// <param name="createContent">A function returning the <see cref="Drawable"/> content to be displayed.</param>
/// <param name="requiresHitEvents">Whether this item requires hit events. If true, <see cref="CreateContent"/> will not be called if no hit events are available.</param>
2020-06-19 20:41:48 +08:00
/// <param name="dimension">The <see cref="Dimension"/> of this item. This can be thought of as the column dimension of an encompassing <see cref="GridContainer"/>.</param>
2022-08-21 09:48:35 +08:00
public StatisticItem(LocalisableString name, [NotNull] Func<Drawable> createContent, bool requiresHitEvents = false, [CanBeNull] Dimension dimension = null)
2020-06-19 19:31:52 +08:00
{
Name = name;
2022-02-02 13:29:18 +08:00
RequiresHitEvents = requiresHitEvents;
2022-02-02 17:29:03 +08:00
CreateContent = createContent;
2020-06-19 19:31:52 +08:00
Dimension = dimension;
}
}
}