1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-26 19:32:55 +08:00

Fix statistics not being wrapped by containers

This commit is contained in:
smoogipoo 2020-06-19 20:53:43 +09:00
parent 34a8fcfd2f
commit 5ce2c712d3
5 changed files with 46 additions and 5 deletions

View File

@ -210,6 +210,11 @@ namespace osu.Game.Rulesets
/// <returns>An empty frame for the current ruleset, or null if unsupported.</returns>
public virtual IConvertibleReplayFrame CreateConvertibleReplayFrame() => null;
/// <summary>
/// Creates the statistics for a <see cref="ScoreInfo"/> to be displayed in the results screen.
/// </summary>
/// <param name="score">The <see cref="ScoreInfo"/> to create the statistics for. The score is guaranteed to have <see cref="ScoreInfo.HitEvents"/> populated.</param>
/// <returns>The <see cref="StatisticRow"/>s to display. Each <see cref="StatisticRow"/> may contain 0 or more <see cref="StatisticItem"/>.</returns>
[NotNull]
public virtual StatisticRow[] CreateStatistics(ScoreInfo score) => Array.Empty<StatisticRow>();
}

View File

@ -19,9 +19,13 @@ namespace osu.Game.Screens.Ranking.Statistics
public StatisticContainer(string name)
{
RelativeSizeAxes = Axes.X;
AutoSizeAxes = Axes.Y;
InternalChild = new GridContainer
{
RelativeSizeAxes = Axes.Both,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Content = new[]
{
new Drawable[]
@ -56,13 +60,15 @@ namespace osu.Game.Screens.Ranking.Statistics
{
content = new Container
{
RelativeSizeAxes = Axes.Both
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
}
},
},
RowDimensions = new[]
{
new Dimension(GridSizeMode.AutoSize),
new Dimension(GridSizeMode.AutoSize),
}
};
}

View File

@ -7,12 +7,32 @@ using osu.Framework.Graphics.Containers;
namespace osu.Game.Screens.Ranking.Statistics
{
/// <summary>
/// An item to be displayed in a row of statistics inside the results screen.
/// </summary>
public class StatisticItem
{
/// <summary>
/// The name of this item.
/// </summary>
public readonly string Name;
/// <summary>
/// The <see cref="Drawable"/> content to be displayed.
/// </summary>
public readonly Drawable Content;
/// <summary>
/// The <see cref="Dimension"/> of this row. This can be thought of as the column dimension of an encompassing <see cref="GridContainer"/>.
/// </summary>
public readonly Dimension Dimension;
/// <summary>
/// Creates a new <see cref="StatisticItem"/>, to be displayed inside a <see cref="StatisticRow"/> in the results screen.
/// </summary>
/// <param name="name">The name of this item.</param>
/// <param name="content">The <see cref="Drawable"/> content to be displayed.</param>
/// <param name="dimension">The <see cref="Dimension"/> of this row. This can be thought of as the column dimension of an encompassing <see cref="GridContainer"/>.</param>
public StatisticItem([NotNull] string name, [NotNull] Drawable content, [CanBeNull] Dimension dimension = null)
{
Name = name;

View File

@ -5,12 +5,15 @@ using JetBrains.Annotations;
namespace osu.Game.Screens.Ranking.Statistics
{
/// <summary>
/// A row of statistics to be displayed in the results screen.
/// </summary>
public class StatisticRow
{
/// <summary>
/// The columns of this <see cref="StatisticRow"/>.
/// </summary>
[ItemCanBeNull]
[ItemNotNull]
public StatisticItem[] Columns;
}
}

View File

@ -81,8 +81,15 @@ namespace osu.Game.Screens.Ranking.Statistics
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Content = new[] { row.Columns?.Select(c => c?.Content).ToArray() },
ColumnDimensions = Enumerable.Range(0, row.Columns?.Length ?? 0).Select(i => row.Columns[i]?.Dimension ?? new Dimension()).ToArray(),
Content = new[]
{
row.Columns?.Select(c => new StatisticContainer(c.Name)
{
Child = c.Content
}).Cast<Drawable>().ToArray()
},
ColumnDimensions = Enumerable.Range(0, row.Columns?.Length ?? 0)
.Select(i => row.Columns[i].Dimension ?? new Dimension()).ToArray(),
RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }
});
}