mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 20:12:57 +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[]
|
Columns = new[]
|
||||||
{
|
{
|
||||||
new StatisticItem("Timing Distribution", new HitEventTimingDistributionGraph(score.HitEvents)
|
new StatisticItem("Timing Distribution",
|
||||||
{
|
true,
|
||||||
RelativeSizeAxes = Axes.X,
|
() => new HitEventTimingDistributionGraph(score.HitEvents)
|
||||||
Height = 250
|
{
|
||||||
}),
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = 250
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new StatisticRow
|
new StatisticRow
|
||||||
{
|
{
|
||||||
Columns = new[]
|
Columns = new[]
|
||||||
{
|
{
|
||||||
new StatisticItem(string.Empty, new SimpleStatisticTable(3, new SimpleStatisticItem[]
|
new StatisticItem(string.Empty,
|
||||||
{
|
true,
|
||||||
new UnstableRate(score.HitEvents)
|
() => new SimpleStatisticTable(3, new SimpleStatisticItem[]
|
||||||
}))
|
{
|
||||||
|
new UnstableRate(score.HitEvents)
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -278,7 +278,8 @@ namespace osu.Game.Rulesets.Osu
|
|||||||
Columns = new[]
|
Columns = new[]
|
||||||
{
|
{
|
||||||
new StatisticItem("Timing Distribution",
|
new StatisticItem("Timing Distribution",
|
||||||
new HitEventTimingDistributionGraph(timedHitEvents)
|
true,
|
||||||
|
() => new HitEventTimingDistributionGraph(timedHitEvents)
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
Height = 250
|
Height = 250
|
||||||
@ -289,21 +290,25 @@ namespace osu.Game.Rulesets.Osu
|
|||||||
{
|
{
|
||||||
Columns = new[]
|
Columns = new[]
|
||||||
{
|
{
|
||||||
new StatisticItem("Accuracy Heatmap", new AccuracyHeatmap(score, playableBeatmap)
|
new StatisticItem("Accuracy Heatmap",
|
||||||
{
|
true,
|
||||||
RelativeSizeAxes = Axes.X,
|
() => new AccuracyHeatmap(score, playableBeatmap)
|
||||||
Height = 250
|
{
|
||||||
}),
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = 250
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new StatisticRow
|
new StatisticRow
|
||||||
{
|
{
|
||||||
Columns = new[]
|
Columns = new[]
|
||||||
{
|
{
|
||||||
new StatisticItem(string.Empty, new SimpleStatisticTable(3, new SimpleStatisticItem[]
|
new StatisticItem(string.Empty,
|
||||||
{
|
true,
|
||||||
new UnstableRate(timedHitEvents)
|
() => new SimpleStatisticTable(3, new SimpleStatisticItem[]
|
||||||
}))
|
{
|
||||||
|
new UnstableRate(timedHitEvents)
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -213,21 +213,25 @@ namespace osu.Game.Rulesets.Taiko
|
|||||||
{
|
{
|
||||||
Columns = new[]
|
Columns = new[]
|
||||||
{
|
{
|
||||||
new StatisticItem("Timing Distribution", new HitEventTimingDistributionGraph(timedHitEvents)
|
new StatisticItem("Timing Distribution",
|
||||||
{
|
true,
|
||||||
RelativeSizeAxes = Axes.X,
|
() => new HitEventTimingDistributionGraph(timedHitEvents)
|
||||||
Height = 250
|
{
|
||||||
}),
|
RelativeSizeAxes = Axes.X,
|
||||||
|
Height = 250
|
||||||
|
}),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new StatisticRow
|
new StatisticRow
|
||||||
{
|
{
|
||||||
Columns = new[]
|
Columns = new[]
|
||||||
{
|
{
|
||||||
new StatisticItem(string.Empty, new SimpleStatisticTable(3, new SimpleStatisticItem[]
|
new StatisticItem(string.Empty,
|
||||||
{
|
true,
|
||||||
new UnstableRate(timedHitEvents)
|
() => new SimpleStatisticTable(3, new SimpleStatisticItem[]
|
||||||
}))
|
{
|
||||||
|
new UnstableRate(timedHitEvents)
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -43,7 +43,7 @@ namespace osu.Game.Screens.Ranking.Statistics
|
|||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Margin = new MarginPadding { Top = 15 },
|
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.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
@ -20,22 +21,29 @@ namespace osu.Game.Screens.Ranking.Statistics
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <see cref="Drawable"/> content to be displayed.
|
/// The <see cref="Drawable"/> content to be displayed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly Drawable Content;
|
public readonly Func<Drawable> Content;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <see cref="Dimension"/> of this row. This can be thought of as the column dimension of an encompassing <see cref="GridContainer"/>.
|
/// The <see cref="Dimension"/> of this row. This can be thought of as the column dimension of an encompassing <see cref="GridContainer"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public readonly Dimension Dimension;
|
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>
|
/// <summary>
|
||||||
/// Creates a new <see cref="StatisticItem"/>, to be displayed inside a <see cref="StatisticRow"/> in the results screen.
|
/// Creates a new <see cref="StatisticItem"/>, to be displayed inside a <see cref="StatisticRow"/> in the results screen.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="name">The name of the item. Can be <see cref="string.Empty"/> to hide the item header.</param>
|
/// <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="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>
|
/// <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;
|
Name = name;
|
||||||
|
RequiresHitEvents = requiresHitEvents;
|
||||||
Content = content;
|
Content = content;
|
||||||
Dimension = dimension;
|
Dimension = dimension;
|
||||||
}
|
}
|
||||||
|
@ -118,6 +118,10 @@ namespace osu.Game.Screens.Ranking.Statistics
|
|||||||
|
|
||||||
foreach (var row in newScore.Ruleset.CreateInstance().CreateStatisticsForScore(newScore, playableBeatmap))
|
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
|
rows.Add(new GridContainer
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopCentre,
|
Anchor = Anchor.TopCentre,
|
||||||
@ -126,14 +130,14 @@ namespace osu.Game.Screens.Ranking.Statistics
|
|||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Content = new[]
|
Content = new[]
|
||||||
{
|
{
|
||||||
row.Columns?.Select(c => new StatisticContainer(c)
|
columnsToDisplay?.Select(c => new StatisticContainer(c)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.Centre,
|
Anchor = Anchor.Centre,
|
||||||
Origin = Anchor.Centre,
|
Origin = Anchor.Centre,
|
||||||
}).Cast<Drawable>().ToArray()
|
}).Cast<Drawable>().ToArray()
|
||||||
},
|
},
|
||||||
ColumnDimensions = Enumerable.Range(0, row.Columns?.Length ?? 0)
|
ColumnDimensions = Enumerable.Range(0, columnsToDisplay?.Length ?? 0)
|
||||||
.Select(i => row.Columns[i].Dimension ?? new Dimension()).ToArray(),
|
.Select(i => columnsToDisplay?[i].Dimension ?? new Dimension()).ToArray(),
|
||||||
RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }
|
RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user