mirror of
https://github.com/ppy/osu
synced 2024-12-11 17:42:28 +00:00
Introduce IStatisticRow interface
This commit is contained in:
parent
66fb5d4174
commit
927a2a3d2d
18
osu.Game/Screens/Ranking/Statistics/IStatisticRow.cs
Normal file
18
osu.Game/Screens/Ranking/Statistics/IStatisticRow.cs
Normal file
@ -0,0 +1,18 @@
|
||||
// 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.
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Ranking.Statistics
|
||||
{
|
||||
/// <summary>
|
||||
/// A row of statistics to be displayed on the results screen.
|
||||
/// </summary>
|
||||
public interface IStatisticRow
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates the visual representation of this row.
|
||||
/// </summary>
|
||||
Drawable CreateDrawableStatisticRow();
|
||||
}
|
||||
}
|
@ -1,19 +1,41 @@
|
||||
// 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.
|
||||
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
|
||||
namespace osu.Game.Screens.Ranking.Statistics
|
||||
{
|
||||
/// <summary>
|
||||
/// A row of statistics to be displayed in the results screen.
|
||||
/// A row of graphically detailed <see cref="StatisticItem"/>s to be displayed in the results screen.
|
||||
/// </summary>
|
||||
public class StatisticRow
|
||||
public class StatisticRow : IStatisticRow
|
||||
{
|
||||
/// <summary>
|
||||
/// The columns of this <see cref="StatisticRow"/>.
|
||||
/// </summary>
|
||||
[ItemNotNull]
|
||||
public StatisticItem[] Columns;
|
||||
|
||||
public Drawable CreateDrawableStatisticRow() => new GridContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Content = new[]
|
||||
{
|
||||
Columns?.Select(c => new StatisticContainer(c)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
}).Cast<Drawable>().ToArray()
|
||||
},
|
||||
ColumnDimensions = Enumerable.Range(0, Columns?.Length ?? 0)
|
||||
.Select(i => Columns[i].Dimension ?? new Dimension()).ToArray(),
|
||||
RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -96,27 +96,9 @@ namespace osu.Game.Screens.Ranking.Statistics
|
||||
Spacing = new Vector2(30, 15),
|
||||
};
|
||||
|
||||
foreach (var row in newScore.Ruleset.CreateInstance().CreateStatisticsForScore(newScore, playableBeatmap))
|
||||
{
|
||||
rows.Add(new GridContainer
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Content = new[]
|
||||
{
|
||||
row.Columns?.Select(c => new StatisticContainer(c)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
}).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) }
|
||||
});
|
||||
}
|
||||
rows.AddRange(newScore.Ruleset.CreateInstance()
|
||||
.CreateStatisticsForScore(newScore, playableBeatmap)
|
||||
.Select(row => row.CreateDrawableStatisticRow()));
|
||||
|
||||
LoadComponentAsync(rows, d =>
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user