1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 06:03:08 +08:00

Update statistics item display logic

This commit is contained in:
Henry Lin 2022-02-02 13:41:51 +08:00
parent c5c4c85006
commit 3ba5d88914

View File

@ -74,85 +74,92 @@ namespace osu.Game.Screens.Ranking.Statistics
if (newScore == null) if (newScore == null)
return; return;
if (newScore.HitEvents.Count == 0) spinner.Show();
var localCancellationSource = loadCancellation = new CancellationTokenSource();
IBeatmap playableBeatmap = null;
// Todo: The placement of this is temporary. Eventually we'll both generate the playable beatmap _and_ run through it in a background task to generate the hit events.
Task.Run(() =>
{ {
content.Add(new FillFlowContainer playableBeatmap = beatmapManager.GetWorkingBeatmap(newScore.BeatmapInfo).GetPlayableBeatmap(newScore.Ruleset, newScore.Mods);
}, loadCancellation.Token).ContinueWith(t => Schedule(() =>
{
var rows = new FillFlowContainer
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Children = new Drawable[] Spacing = new Vector2(30, 15),
Alpha = 0
};
bool panelIsEmpty = true;
bool hitEventsAvailable = newScore.HitEvents.Count != 0;
foreach (var row in newScore.Ruleset.CreateInstance().CreateStatisticsForScore(newScore, playableBeatmap))
{
var columnsToDisplay = hitEventsAvailable
? row.Columns
: row.Columns?.Where(c => !c.RequiresHitEvents).ToArray();
if (columnsToDisplay?.Any() ?? false)
panelIsEmpty = false;
rows.Add(new GridContainer
{ {
new MessagePlaceholder("Extended statistics are only available after watching a replay!"), Anchor = Anchor.TopCentre,
new ReplayDownloadButton(newScore) Origin = Anchor.TopCentre,
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Content = new[]
{ {
Scale = new Vector2(1.5f), columnsToDisplay?.Select(c => new StatisticContainer(c)
Anchor = Anchor.Centre, {
Origin = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre,
}).Cast<Drawable>().ToArray()
}, },
} ColumnDimensions = Enumerable.Range(0, columnsToDisplay?.Length ?? 0)
}); .Select(i => columnsToDisplay?[i].Dimension ?? new Dimension()).ToArray(),
} RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) }
else });
{ }
spinner.Show();
var localCancellationSource = loadCancellation = new CancellationTokenSource(); if (!hitEventsAvailable)
IBeatmap playableBeatmap = null;
// Todo: The placement of this is temporary. Eventually we'll both generate the playable beatmap _and_ run through it in a background task to generate the hit events.
Task.Run(() =>
{ {
playableBeatmap = beatmapManager.GetWorkingBeatmap(newScore.BeatmapInfo).GetPlayableBeatmap(newScore.Ruleset, newScore.Mods); rows.Add(new FillFlowContainer
}, loadCancellation.Token).ContinueWith(t => Schedule(() =>
{
var rows = new FillFlowContainer
{ {
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Spacing = new Vector2(30, 15), Children = new Drawable[]
Alpha = 0
};
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, new MessagePlaceholder(panelIsEmpty
Origin = Anchor.TopCentre, ? "Extended statistics are only available after watching a replay!"
RelativeSizeAxes = Axes.X, : "More statistics available after watching a replay!"),
AutoSizeAxes = Axes.Y, new ReplayDownloadButton(newScore)
Content = new[]
{ {
columnsToDisplay?.Select(c => new StatisticContainer(c) Scale = new Vector2(1.5f),
{ Anchor = Anchor.Centre,
Anchor = Anchor.Centre, Origin = Anchor.Centre,
Origin = Anchor.Centre,
}).Cast<Drawable>().ToArray()
}, },
ColumnDimensions = Enumerable.Range(0, columnsToDisplay?.Length ?? 0) }
.Select(i => columnsToDisplay?[i].Dimension ?? new Dimension()).ToArray(), });
RowDimensions = new[] { new Dimension(GridSizeMode.AutoSize) } }
});
}
LoadComponentAsync(rows, d => LoadComponentAsync(rows, d =>
{ {
if (!Score.Value.Equals(newScore)) if (!Score.Value.Equals(newScore))
return; return;
spinner.Hide(); spinner.Hide();
content.Add(d); content.Add(d);
d.FadeIn(250, Easing.OutQuint); d.FadeIn(250, Easing.OutQuint);
}, localCancellationSource.Token); }, localCancellationSource.Token);
}), localCancellationSource.Token); }), localCancellationSource.Token);
}
} }
protected override bool OnClick(ClickEvent e) protected override bool OnClick(ClickEvent e)