mirror of
https://github.com/ppy/osu.git
synced 2025-03-17 15:47:20 +08:00
Consume display name logic
This commit is contained in:
parent
6020ec9ca3
commit
e281d724b8
@ -60,7 +60,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
/// <summary>
|
||||
/// The statistics that appear in the table, in order of appearance.
|
||||
/// </summary>
|
||||
private readonly List<HitResult> statisticResultTypes = new List<HitResult>();
|
||||
private readonly List<(HitResult result, string displayName)> statisticResultTypes = new List<(HitResult, string)>();
|
||||
|
||||
private bool showPerformancePoints;
|
||||
|
||||
@ -101,15 +101,19 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
};
|
||||
|
||||
// All statistics across all scores, unordered.
|
||||
var allScoreStatistics = scores.SelectMany(s => s.GetStatisticsForDisplay().Select(stat => stat.result)).ToHashSet();
|
||||
var allScoreStatistics = scores.SelectMany(s => s.GetStatisticsForDisplay().Select(stat => stat.Result)).ToHashSet();
|
||||
|
||||
var ruleset = scores.First().Ruleset.CreateInstance();
|
||||
|
||||
foreach (var result in OrderAttributeUtils.GetValuesInOrder<HitResult>())
|
||||
{
|
||||
if (!allScoreStatistics.Contains(result))
|
||||
continue;
|
||||
|
||||
columns.Add(new TableColumn(result.GetDescription(), Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 35, maxSize: 60)));
|
||||
statisticResultTypes.Add(result);
|
||||
string displayName = ruleset.GetDisplayNameForHitResult(result);
|
||||
|
||||
columns.Add(new TableColumn(displayName, Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 35, maxSize: 60)));
|
||||
statisticResultTypes.Add((result, displayName));
|
||||
}
|
||||
|
||||
if (showPerformancePoints)
|
||||
@ -163,18 +167,18 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
}
|
||||
};
|
||||
|
||||
var availableStatistics = score.GetStatisticsForDisplay().ToDictionary(tuple => tuple.result);
|
||||
var availableStatistics = score.GetStatisticsForDisplay().ToDictionary(tuple => tuple.Result);
|
||||
|
||||
foreach (var result in statisticResultTypes)
|
||||
{
|
||||
if (!availableStatistics.TryGetValue(result, out var stat))
|
||||
stat = (result, 0, null);
|
||||
if (!availableStatistics.TryGetValue(result.result, out var stat))
|
||||
stat = new HitResultDisplayStatistic(result.result, 0, null, result.displayName);
|
||||
|
||||
content.Add(new OsuSpriteText
|
||||
{
|
||||
Text = stat.maxCount == null ? $"{stat.count}" : $"{stat.count}/{stat.maxCount}",
|
||||
Text = stat.MaxCount == null ? $"{stat.Count}" : $"{stat.Count}/{stat.MaxCount}",
|
||||
Font = OsuFont.GetFont(size: text_size),
|
||||
Colour = stat.count == 0 ? Color4.Gray : Color4.White
|
||||
Colour = stat.Count == 0 ? Color4.Gray : Color4.White
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -5,7 +5,6 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
@ -15,7 +14,6 @@ using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Scoring;
|
||||
using osuTK;
|
||||
@ -117,7 +115,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
ppColumn.Alpha = value.Beatmap?.Status == BeatmapSetOnlineStatus.Ranked ? 1 : 0;
|
||||
ppColumn.Text = $@"{value.PP:N0}";
|
||||
|
||||
statisticsColumns.ChildrenEnumerable = value.GetStatisticsForDisplay().Select(s => createStatisticsColumn(s.result, s.count, s.maxCount));
|
||||
statisticsColumns.ChildrenEnumerable = value.GetStatisticsForDisplay().Select(createStatisticsColumn);
|
||||
modsColumn.Mods = value.Mods;
|
||||
|
||||
if (scoreManager != null)
|
||||
@ -125,9 +123,9 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
|
||||
}
|
||||
}
|
||||
|
||||
private TextColumn createStatisticsColumn(HitResult hitResult, int count, int? maxCount) => new TextColumn(hitResult.GetDescription(), smallFont, bottom_columns_min_width)
|
||||
private TextColumn createStatisticsColumn(HitResultDisplayStatistic stat) => new TextColumn(stat.DisplayName, smallFont, bottom_columns_min_width)
|
||||
{
|
||||
Text = maxCount == null ? $"{count}" : $"{count}/{maxCount}"
|
||||
Text = stat.MaxCount == null ? $"{stat.Count}" : $"{stat.Count}/{stat.MaxCount}"
|
||||
};
|
||||
|
||||
private class InfoColumn : CompositeDrawable
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
@ -13,7 +12,6 @@ using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Online.Leaderboards;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Play.HUD;
|
||||
using osu.Game.Users;
|
||||
@ -117,7 +115,7 @@ namespace osu.Game.Screens.Ranking.Contracted
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0, 5),
|
||||
ChildrenEnumerable = score.GetStatisticsForDisplay().Select(s => createStatistic(s.result, s.count, s.maxCount))
|
||||
ChildrenEnumerable = score.GetStatisticsForDisplay().Select(createStatistic)
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
@ -199,8 +197,8 @@ namespace osu.Game.Screens.Ranking.Contracted
|
||||
};
|
||||
}
|
||||
|
||||
private Drawable createStatistic(HitResult result, int count, int? maxCount)
|
||||
=> createStatistic(result.GetDescription(), maxCount == null ? $"{count}" : $"{count}/{maxCount}");
|
||||
private Drawable createStatistic(HitResultDisplayStatistic result)
|
||||
=> createStatistic(result.DisplayName, result.MaxCount == null ? $"{result.Count}" : $"{result.Count}/{result.MaxCount}");
|
||||
|
||||
private Drawable createStatistic(string key, string value) => new Container
|
||||
{
|
||||
|
@ -66,8 +66,8 @@ namespace osu.Game.Screens.Ranking.Expanded
|
||||
|
||||
var bottomStatistics = new List<StatisticDisplay>();
|
||||
|
||||
foreach (var (key, value, maxCount) in score.GetStatisticsForDisplay())
|
||||
bottomStatistics.Add(new HitResultStatistic(key, value, maxCount));
|
||||
foreach (var result in score.GetStatisticsForDisplay())
|
||||
bottomStatistics.Add(new HitResultStatistic(result));
|
||||
|
||||
statisticDisplays.AddRange(topStatistics);
|
||||
statisticDisplays.AddRange(bottomStatistics);
|
||||
|
@ -2,9 +2,9 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
using osu.Game.Scoring;
|
||||
|
||||
namespace osu.Game.Screens.Ranking.Expanded.Statistics
|
||||
{
|
||||
@ -12,10 +12,10 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics
|
||||
{
|
||||
private readonly HitResult result;
|
||||
|
||||
public HitResultStatistic(HitResult result, int count, int? maxCount = null)
|
||||
: base(result.GetDescription(), count, maxCount)
|
||||
public HitResultStatistic(HitResultDisplayStatistic result)
|
||||
: base(result.DisplayName, result.Count, result.MaxCount)
|
||||
{
|
||||
this.result = result;
|
||||
this.result = result.Result;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
|
Loading…
x
Reference in New Issue
Block a user