1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 05:27:23 +08:00

Reintroduce SimpleStatisticRow as a data class

This commit is contained in:
Bartłomiej Dach 2020-08-26 19:30:49 +02:00
parent f5e52c80b4
commit 7c3368ecbe
2 changed files with 36 additions and 1 deletions

View File

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics;
@ -28,7 +29,7 @@ namespace osu.Game.Screens.Ranking.Statistics
/// </summary>
/// <param name="columnCount">The number of columns to layout the <paramref name="items"/> into.</param>
/// <param name="items">The <see cref="SimpleStatisticItem"/>s to display in this row.</param>
public DrawableSimpleStatisticRow(int columnCount, IEnumerable<SimpleStatisticItem> items)
public DrawableSimpleStatisticRow(int columnCount, [ItemNotNull] IEnumerable<SimpleStatisticItem> items)
{
if (columnCount < 1)
throw new ArgumentOutOfRangeException(nameof(columnCount));

View File

@ -0,0 +1,34 @@
// 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 JetBrains.Annotations;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
namespace osu.Game.Screens.Ranking.Statistics
{
/// <summary>
/// Contains textual statistic data to display in a <see cref="DrawableSimpleStatisticRow"/>.
/// </summary>
public class SimpleStatisticRow : IStatisticRow
{
/// <summary>
/// The number of columns to layout the <see cref="Items"/> in.
/// </summary>
public int Columns { get; set; }
/// <summary>
/// The <see cref="StatisticItem"/>s that this row should contain.
/// </summary>
[ItemNotNull]
public SimpleStatisticItem[] Items { get; set; }
public Drawable CreateDrawableStatisticRow() => new Container
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Padding = new MarginPadding(20),
Child = new DrawableSimpleStatisticRow(Columns, Items)
};
}
}