mirror of
https://github.com/ppy/osu.git
synced 2025-02-20 09:03:00 +08:00
Lazily create content of StatisticItem
This commit is contained in:
parent
4b646709c1
commit
c5c4c85006
@ -370,21 +370,25 @@ namespace osu.Game.Rulesets.Mania
|
||||
{
|
||||
Columns = new[]
|
||||
{
|
||||
new StatisticItem("Timing Distribution", new HitEventTimingDistributionGraph(score.HitEvents)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 250
|
||||
}),
|
||||
new StatisticItem("Timing Distribution",
|
||||
true,
|
||||
() => new HitEventTimingDistributionGraph(score.HitEvents)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 250
|
||||
}),
|
||||
}
|
||||
},
|
||||
new StatisticRow
|
||||
{
|
||||
Columns = new[]
|
||||
{
|
||||
new StatisticItem(string.Empty, new SimpleStatisticTable(3, new SimpleStatisticItem[]
|
||||
{
|
||||
new UnstableRate(score.HitEvents)
|
||||
}))
|
||||
new StatisticItem(string.Empty,
|
||||
true,
|
||||
() => new SimpleStatisticTable(3, new SimpleStatisticItem[]
|
||||
{
|
||||
new UnstableRate(score.HitEvents)
|
||||
}))
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -278,7 +278,8 @@ namespace osu.Game.Rulesets.Osu
|
||||
Columns = new[]
|
||||
{
|
||||
new StatisticItem("Timing Distribution",
|
||||
new HitEventTimingDistributionGraph(timedHitEvents)
|
||||
true,
|
||||
() => new HitEventTimingDistributionGraph(timedHitEvents)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 250
|
||||
@ -289,21 +290,25 @@ namespace osu.Game.Rulesets.Osu
|
||||
{
|
||||
Columns = new[]
|
||||
{
|
||||
new StatisticItem("Accuracy Heatmap", new AccuracyHeatmap(score, playableBeatmap)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 250
|
||||
}),
|
||||
new StatisticItem("Accuracy Heatmap",
|
||||
true,
|
||||
() => new AccuracyHeatmap(score, playableBeatmap)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 250
|
||||
}),
|
||||
}
|
||||
},
|
||||
new StatisticRow
|
||||
{
|
||||
Columns = new[]
|
||||
{
|
||||
new StatisticItem(string.Empty, new SimpleStatisticTable(3, new SimpleStatisticItem[]
|
||||
{
|
||||
new UnstableRate(timedHitEvents)
|
||||
}))
|
||||
new StatisticItem(string.Empty,
|
||||
true,
|
||||
() => new SimpleStatisticTable(3, new SimpleStatisticItem[]
|
||||
{
|
||||
new UnstableRate(timedHitEvents)
|
||||
}))
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -213,21 +213,25 @@ namespace osu.Game.Rulesets.Taiko
|
||||
{
|
||||
Columns = new[]
|
||||
{
|
||||
new StatisticItem("Timing Distribution", new HitEventTimingDistributionGraph(timedHitEvents)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 250
|
||||
}),
|
||||
new StatisticItem("Timing Distribution",
|
||||
true,
|
||||
() => new HitEventTimingDistributionGraph(timedHitEvents)
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = 250
|
||||
}),
|
||||
}
|
||||
},
|
||||
new StatisticRow
|
||||
{
|
||||
Columns = new[]
|
||||
{
|
||||
new StatisticItem(string.Empty, new SimpleStatisticTable(3, new SimpleStatisticItem[]
|
||||
{
|
||||
new UnstableRate(timedHitEvents)
|
||||
}))
|
||||
new StatisticItem(string.Empty,
|
||||
true,
|
||||
() => new SimpleStatisticTable(3, new SimpleStatisticItem[]
|
||||
{
|
||||
new UnstableRate(timedHitEvents)
|
||||
}))
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -43,7 +43,7 @@ namespace osu.Game.Screens.Ranking.Statistics
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Margin = new MarginPadding { Top = 15 },
|
||||
Child = item.Content
|
||||
Child = item.Content()
|
||||
}
|
||||
},
|
||||
},
|
||||
|
@ -1,6 +1,7 @@
|
||||
// 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 JetBrains.Annotations;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -20,22 +21,29 @@ namespace osu.Game.Screens.Ranking.Statistics
|
||||
/// <summary>
|
||||
/// The <see cref="Drawable"/> content to be displayed.
|
||||
/// </summary>
|
||||
public readonly Drawable Content;
|
||||
public readonly Func<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>
|
||||
/// Whether this item requires hit events. If true, the <see cref="Content"/> will not be created if no hit events are available.
|
||||
/// </summary>
|
||||
public readonly bool RequiresHitEvents;
|
||||
|
||||
/// <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 the item. Can be <see cref="string.Empty"/> to hide the item header.</param>
|
||||
/// <param name="requiresHitEvents">Whether this item requires hit events. If true, the <see cref="Content"/> will not be created if no hit events are available.</param>
|
||||
/// <param name="content">The <see cref="Drawable"/> content to be displayed.</param>
|
||||
/// <param name="dimension">The <see cref="Dimension"/> of this item. 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)
|
||||
public StatisticItem([NotNull] string name, bool requiresHitEvents, [NotNull] Func<Drawable> content, [CanBeNull] Dimension dimension = null)
|
||||
{
|
||||
Name = name;
|
||||
RequiresHitEvents = requiresHitEvents;
|
||||
Content = content;
|
||||
Dimension = dimension;
|
||||
}
|
||||
|
@ -118,6 +118,10 @@ namespace osu.Game.Screens.Ranking.Statistics
|
||||
|
||||
foreach (var row in newScore.Ruleset.CreateInstance().CreateStatisticsForScore(newScore, playableBeatmap))
|
||||
{
|
||||
var columnsToDisplay = newScore.HitEvents.Count == 0
|
||||
? row.Columns?.Where(c => !c.RequiresHitEvents).ToArray()
|
||||
: row.Columns;
|
||||
|
||||
rows.Add(new GridContainer
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
@ -126,14 +130,14 @@ namespace osu.Game.Screens.Ranking.Statistics
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Content = new[]
|
||||
{
|
||||
row.Columns?.Select(c => new StatisticContainer(c)
|
||||
columnsToDisplay?.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(),
|
||||
ColumnDimensions = Enumerable.Range(0, columnsToDisplay?.Length ?? 0)
|
||||
.Select(i => columnsToDisplay?[i].Dimension ?? new Dimension()).ToArray(),
|
||||
RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user