Change interface for creating statistic rows

This commit is contained in:
smoogipoo 2020-06-16 17:49:28 +09:00
parent 9442fc00ac
commit a2ddb4edb4
5 changed files with 59 additions and 13 deletions

View File

@ -29,6 +29,7 @@
using osu.Game.Scoring;
using osu.Game.Skinning;
using System;
using osu.Framework.Graphics.Containers;
using osu.Game.Rulesets.Osu.Statistics;
using osu.Game.Screens.Ranking.Statistics;
@ -189,16 +190,36 @@ public override IEnumerable<Mod> GetModsFor(ModType type)
public override IRulesetConfigManager CreateConfig(SettingsStore settings) => new OsuRulesetConfigManager(settings, RulesetInfo);
public override IEnumerable<StatisticContainer> CreateStatistics(ScoreInfo score) => new[]
public override StatisticRow[] CreateStatistics(ScoreInfo score) => new[]
{
new StatisticContainer("Timing Distribution")
new StatisticRow
{
Child = new TimingDistributionGraph((TimingDistribution)score.ExtraStatistics.GetValueOrDefault("timing_distribution"))
},
new StatisticContainer("Accuracy Heatmap")
{
Child = new Heatmap((List<HitOffset>)score.ExtraStatistics.GetValueOrDefault("hit_offsets"))
},
Content = new Drawable[]
{
new StatisticContainer("Timing Distribution")
{
RelativeSizeAxes = Axes.X,
Height = 130,
Child = new TimingDistributionGraph((TimingDistribution)score.ExtraStatistics.GetValueOrDefault("timing_distribution"))
{
RelativeSizeAxes = Axes.Both
}
},
new StatisticContainer("Accuracy Heatmap")
{
RelativeSizeAxes = Axes.Both,
Child = new Heatmap((List<HitOffset>)score.ExtraStatistics.GetValueOrDefault("hit_offsets"))
{
RelativeSizeAxes = Axes.Both
}
},
},
ColumnDimensions = new[]
{
new Dimension(),
new Dimension(GridSizeMode.Absolute, 130),
}
}
};
}
}

View File

@ -210,6 +210,6 @@ protected Ruleset()
/// <returns>An empty frame for the current ruleset, or null if unsupported.</returns>
public virtual IConvertibleReplayFrame CreateConvertibleReplayFrame() => null;
public virtual IEnumerable<StatisticContainer> CreateStatistics(ScoreInfo score) => Enumerable.Empty<StatisticContainer>();
public virtual StatisticRow[] CreateStatistics(ScoreInfo score) => Array.Empty<StatisticRow>();
}
}

View File

@ -21,7 +21,7 @@ public StatisticContainer(string name)
{
InternalChild = new GridContainer
{
RelativeSizeAxes = Axes.X,
RelativeSizeAxes = Axes.Both,
Content = new[]
{
new Drawable[]

View File

@ -0,0 +1,15 @@
// 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;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
namespace osu.Game.Screens.Ranking.Statistics
{
public class StatisticRow
{
public Drawable[] Content = Array.Empty<Drawable>();
public Dimension[] ColumnDimensions = Array.Empty<Dimension>();
}
}

View File

@ -17,7 +17,7 @@ public StatisticsPanel(ScoreInfo score)
// Todo: Not correct.
RelativeSizeAxes = Axes.Both;
Container<StatisticContainer> statistics;
FillFlowContainer statisticRows;
InternalChildren = new Drawable[]
{
@ -41,16 +41,26 @@ public StatisticsPanel(ScoreInfo score)
Left = ScorePanel.EXPANDED_WIDTH + 30 + 50,
Right = 50
},
Child = statistics = new FillFlowContainer<StatisticContainer>
Child = statisticRows = new FillFlowContainer
{
RelativeSizeAxes = Axes.Both,
Direction = FillDirection.Vertical,
Spacing = new Vector2(30, 15),
}
}
};
foreach (var s in score.Ruleset.CreateInstance().CreateStatistics(score))
statistics.Add(s);
{
statisticRows.Add(new GridContainer
{
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Content = new[] { s.Content },
ColumnDimensions = s.ColumnDimensions,
RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }
});
}
}
}
}