1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 16:27:26 +08:00

Consume display name logic

This commit is contained in:
Dean Herbert 2020-10-07 15:35:04 +09:00
parent 6020ec9ca3
commit e281d724b8
5 changed files with 25 additions and 25 deletions

View File

@ -60,7 +60,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
/// <summary> /// <summary>
/// The statistics that appear in the table, in order of appearance. /// The statistics that appear in the table, in order of appearance.
/// </summary> /// </summary>
private readonly List<HitResult> statisticResultTypes = new List<HitResult>(); private readonly List<(HitResult result, string displayName)> statisticResultTypes = new List<(HitResult, string)>();
private bool showPerformancePoints; private bool showPerformancePoints;
@ -101,15 +101,19 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
}; };
// All statistics across all scores, unordered. // 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>()) foreach (var result in OrderAttributeUtils.GetValuesInOrder<HitResult>())
{ {
if (!allScoreStatistics.Contains(result)) if (!allScoreStatistics.Contains(result))
continue; continue;
columns.Add(new TableColumn(result.GetDescription(), Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 35, maxSize: 60))); string displayName = ruleset.GetDisplayNameForHitResult(result);
statisticResultTypes.Add(result);
columns.Add(new TableColumn(displayName, Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 35, maxSize: 60)));
statisticResultTypes.Add((result, displayName));
} }
if (showPerformancePoints) 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) foreach (var result in statisticResultTypes)
{ {
if (!availableStatistics.TryGetValue(result, out var stat)) if (!availableStatistics.TryGetValue(result.result, out var stat))
stat = (result, 0, null); stat = new HitResultDisplayStatistic(result.result, 0, null, result.displayName);
content.Add(new OsuSpriteText 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), Font = OsuFont.GetFont(size: text_size),
Colour = stat.count == 0 ? Color4.Gray : Color4.White Colour = stat.Count == 0 ? Color4.Gray : Color4.White
}); });
} }

View File

@ -5,7 +5,6 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables; using osu.Framework.Bindables;
using osu.Framework.Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
@ -15,7 +14,6 @@ using osu.Game.Beatmaps;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.UI; using osu.Game.Rulesets.UI;
using osu.Game.Scoring; using osu.Game.Scoring;
using osuTK; using osuTK;
@ -117,7 +115,7 @@ namespace osu.Game.Overlays.BeatmapSet.Scores
ppColumn.Alpha = value.Beatmap?.Status == BeatmapSetOnlineStatus.Ranked ? 1 : 0; ppColumn.Alpha = value.Beatmap?.Status == BeatmapSetOnlineStatus.Ranked ? 1 : 0;
ppColumn.Text = $@"{value.PP:N0}"; 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; modsColumn.Mods = value.Mods;
if (scoreManager != null) 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 private class InfoColumn : CompositeDrawable

View File

@ -3,7 +3,6 @@
using System.Linq; using System.Linq;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Colour;
@ -13,7 +12,6 @@ using osu.Framework.Graphics.Shapes;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Online.Leaderboards; using osu.Game.Online.Leaderboards;
using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Screens.Play.HUD; using osu.Game.Screens.Play.HUD;
using osu.Game.Users; using osu.Game.Users;
@ -117,7 +115,7 @@ namespace osu.Game.Screens.Ranking.Contracted
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Spacing = new Vector2(0, 5), Spacing = new Vector2(0, 5),
ChildrenEnumerable = score.GetStatisticsForDisplay().Select(s => createStatistic(s.result, s.count, s.maxCount)) ChildrenEnumerable = score.GetStatisticsForDisplay().Select(createStatistic)
}, },
new FillFlowContainer new FillFlowContainer
{ {
@ -199,8 +197,8 @@ namespace osu.Game.Screens.Ranking.Contracted
}; };
} }
private Drawable createStatistic(HitResult result, int count, int? maxCount) private Drawable createStatistic(HitResultDisplayStatistic result)
=> createStatistic(result.GetDescription(), maxCount == null ? $"{count}" : $"{count}/{maxCount}"); => createStatistic(result.DisplayName, result.MaxCount == null ? $"{result.Count}" : $"{result.Count}/{result.MaxCount}");
private Drawable createStatistic(string key, string value) => new Container private Drawable createStatistic(string key, string value) => new Container
{ {

View File

@ -66,8 +66,8 @@ namespace osu.Game.Screens.Ranking.Expanded
var bottomStatistics = new List<StatisticDisplay>(); var bottomStatistics = new List<StatisticDisplay>();
foreach (var (key, value, maxCount) in score.GetStatisticsForDisplay()) foreach (var result in score.GetStatisticsForDisplay())
bottomStatistics.Add(new HitResultStatistic(key, value, maxCount)); bottomStatistics.Add(new HitResultStatistic(result));
statisticDisplays.AddRange(topStatistics); statisticDisplays.AddRange(topStatistics);
statisticDisplays.AddRange(bottomStatistics); statisticDisplays.AddRange(bottomStatistics);

View File

@ -2,9 +2,9 @@
// 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 osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.Scoring;
using osu.Game.Scoring;
namespace osu.Game.Screens.Ranking.Expanded.Statistics namespace osu.Game.Screens.Ranking.Expanded.Statistics
{ {
@ -12,10 +12,10 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics
{ {
private readonly HitResult result; private readonly HitResult result;
public HitResultStatistic(HitResult result, int count, int? maxCount = null) public HitResultStatistic(HitResultDisplayStatistic result)
: base(result.GetDescription(), count, maxCount) : base(result.DisplayName, result.Count, result.MaxCount)
{ {
this.result = result; this.result = result.Result;
} }
[BackgroundDependencyLoader] [BackgroundDependencyLoader]