1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 10:07:52 +08:00

Revert IStatisticRow changes

This commit is contained in:
Bartłomiej Dach 2020-08-27 20:07:30 +02:00
parent 1a04ec5375
commit f152e1b924
8 changed files with 30 additions and 78 deletions

View File

@ -314,7 +314,7 @@ namespace osu.Game.Rulesets.Mania
return (PlayfieldType)Enum.GetValues(typeof(PlayfieldType)).Cast<int>().OrderByDescending(i => i).First(v => variant >= v);
}
public override IStatisticRow[] CreateStatisticsForScore(ScoreInfo score, IBeatmap playableBeatmap) => new IStatisticRow[]
public override StatisticRow[] CreateStatisticsForScore(ScoreInfo score, IBeatmap playableBeatmap) => new[]
{
new StatisticRow
{
@ -327,14 +327,6 @@ namespace osu.Game.Rulesets.Mania
}),
}
},
new SimpleStatisticRow
{
Columns = 3,
Items = new SimpleStatisticItem[]
{
new UnstableRate(score.HitEvents)
}
}
};
}

View File

@ -193,11 +193,11 @@ namespace osu.Game.Rulesets.Osu
public override IRulesetConfigManager CreateConfig(SettingsStore settings) => new OsuRulesetConfigManager(settings, RulesetInfo);
public override IStatisticRow[] CreateStatisticsForScore(ScoreInfo score, IBeatmap playableBeatmap)
public override StatisticRow[] CreateStatisticsForScore(ScoreInfo score, IBeatmap playableBeatmap)
{
var timedHitEvents = score.HitEvents.Where(e => e.HitObject is HitCircle && !(e.HitObject is SliderTailCircle)).ToList();
return new IStatisticRow[]
return new[]
{
new StatisticRow
{
@ -222,14 +222,6 @@ namespace osu.Game.Rulesets.Osu
}),
}
},
new SimpleStatisticRow
{
Columns = 3,
Items = new SimpleStatisticItem[]
{
new UnstableRate(timedHitEvents)
}
}
};
}
}

View File

@ -161,11 +161,11 @@ namespace osu.Game.Rulesets.Taiko
public override IConvertibleReplayFrame CreateConvertibleReplayFrame() => new TaikoReplayFrame();
public override IStatisticRow[] CreateStatisticsForScore(ScoreInfo score, IBeatmap playableBeatmap)
public override StatisticRow[] CreateStatisticsForScore(ScoreInfo score, IBeatmap playableBeatmap)
{
var timedHitEvents = score.HitEvents.Where(e => e.HitObject is Hit).ToList();
return new IStatisticRow[]
return new[]
{
new StatisticRow
{
@ -178,14 +178,6 @@ namespace osu.Game.Rulesets.Taiko
}),
}
},
new SimpleStatisticRow
{
Columns = 3,
Items = new SimpleStatisticItem[]
{
new UnstableRate(timedHitEvents)
}
}
};
}
}

View File

@ -217,6 +217,6 @@ namespace osu.Game.Rulesets
/// <param name="playableBeatmap">The <see cref="IBeatmap"/>, converted for this <see cref="Ruleset"/> with all relevant <see cref="Mod"/>s applied.</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 IStatisticRow[] CreateStatisticsForScore(ScoreInfo score, IBeatmap playableBeatmap) => Array.Empty<IStatisticRow>();
public virtual StatisticRow[] CreateStatisticsForScore(ScoreInfo score, IBeatmap playableBeatmap) => Array.Empty<StatisticRow>();
}
}

View File

@ -1,18 +0,0 @@
// 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();
}
}

View File

@ -10,7 +10,7 @@ namespace osu.Game.Screens.Ranking.Statistics
/// <summary>
/// Contains textual statistic data to display in a <see cref="DrawableSimpleStatisticRow"/>.
/// </summary>
public class SimpleStatisticRow : IStatisticRow
public class SimpleStatisticRow
{
/// <summary>
/// The number of columns to layout the <see cref="Items"/> in.

View File

@ -1,39 +1,19 @@
// 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 graphically detailed <see cref="StatisticItem"/>s to be displayed in the results screen.
/// A row of statistics to be displayed in the results screen.
/// </summary>
public class StatisticRow : IStatisticRow
public class StatisticRow
{
/// <summary>
/// The columns of this <see cref="StatisticRow"/>.
/// </summary>
[ItemNotNull]
public StatisticItem[] Columns;
public Drawable CreateDrawableStatisticRow() => new GridContainer
{
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) }
};
}
}

View File

@ -97,13 +97,27 @@ namespace osu.Game.Screens.Ranking.Statistics
Alpha = 0
};
rows.AddRange(newScore.Ruleset.CreateInstance()
.CreateStatisticsForScore(newScore, playableBeatmap)
.Select(row => row.CreateDrawableStatisticRow().With(r =>
{
r.Anchor = Anchor.TopCentre;
r.Origin = Anchor.TopCentre;
})));
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) }
});
}
LoadComponentAsync(rows, d =>
{