mirror of https://github.com/ppy/osu
Adjust displays to use new results/orderings
This commit is contained in:
parent
1c4baa4e2a
commit
a07597c369
|
@ -92,10 +92,8 @@ private TableColumn[] createHeaders(ScoreInfo score)
|
|||
new TableColumn("max combo", Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 70, maxSize: 120))
|
||||
};
|
||||
|
||||
foreach (var statistic in score.SortedStatistics.Take(score.SortedStatistics.Count() - 1))
|
||||
columns.Add(new TableColumn(statistic.Key.GetDescription(), Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 35, maxSize: 60)));
|
||||
|
||||
columns.Add(new TableColumn(score.SortedStatistics.LastOrDefault().Key.GetDescription(), Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 45, maxSize: 95)));
|
||||
foreach (var (key, _, _) in score.GetStatisticsForDisplay())
|
||||
columns.Add(new TableColumn(key.GetDescription(), Anchor.CentreLeft, new Dimension(GridSizeMode.Distributed, minSize: 35, maxSize: 60)));
|
||||
|
||||
if (showPerformancePoints)
|
||||
columns.Add(new TableColumn("pp", Anchor.CentreLeft, new Dimension(GridSizeMode.Absolute, 30)));
|
||||
|
@ -148,13 +146,13 @@ private Drawable[] createContent(int index, ScoreInfo score)
|
|||
}
|
||||
};
|
||||
|
||||
foreach (var kvp in score.SortedStatistics)
|
||||
foreach (var (_, value, maxCount) in score.GetStatisticsForDisplay())
|
||||
{
|
||||
content.Add(new OsuSpriteText
|
||||
{
|
||||
Text = $"{kvp.Value}",
|
||||
Text = maxCount == null ? $"{value}" : $"{value}/{maxCount}",
|
||||
Font = OsuFont.GetFont(size: text_size),
|
||||
Colour = kvp.Value == 0 ? Color4.Gray : Color4.White
|
||||
Colour = value == 0 ? Color4.Gray : Color4.White
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ public ScoreInfo Score
|
|||
ppColumn.Alpha = value.Beatmap?.Status == BeatmapSetOnlineStatus.Ranked ? 1 : 0;
|
||||
ppColumn.Text = $@"{value.PP:N0}";
|
||||
|
||||
statisticsColumns.ChildrenEnumerable = value.SortedStatistics.Select(kvp => createStatisticsColumn(kvp.Key, kvp.Value));
|
||||
statisticsColumns.ChildrenEnumerable = value.GetStatisticsForDisplay().Select(s => createStatisticsColumn(s.result, s.count, s.maxCount));
|
||||
modsColumn.Mods = value.Mods;
|
||||
|
||||
if (scoreManager != null)
|
||||
|
@ -125,9 +125,9 @@ public ScoreInfo Score
|
|||
}
|
||||
}
|
||||
|
||||
private TextColumn createStatisticsColumn(HitResult hitResult, int count) => new TextColumn(hitResult.GetDescription(), smallFont, bottom_columns_min_width)
|
||||
private TextColumn createStatisticsColumn(HitResult hitResult, int count, int? maxCount) => new TextColumn(hitResult.GetDescription(), smallFont, bottom_columns_min_width)
|
||||
{
|
||||
Text = count.ToString()
|
||||
Text = maxCount == null ? $"{count}" : $"{count}/{maxCount}"
|
||||
};
|
||||
|
||||
private class InfoColumn : CompositeDrawable
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
using System.Linq;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
using osu.Framework.Extensions;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Database;
|
||||
using osu.Game.Rulesets;
|
||||
|
@ -147,8 +148,6 @@ public long? UserID
|
|||
[JsonProperty("statistics")]
|
||||
public Dictionary<HitResult, int> Statistics = new Dictionary<HitResult, int>();
|
||||
|
||||
public IOrderedEnumerable<KeyValuePair<HitResult, int>> SortedStatistics => Statistics.OrderByDescending(pair => pair.Key);
|
||||
|
||||
[JsonIgnore]
|
||||
[Column("Statistics")]
|
||||
public string StatisticsJson
|
||||
|
@ -186,6 +185,48 @@ public string StatisticsJson
|
|||
[JsonProperty("position")]
|
||||
public int? Position { get; set; }
|
||||
|
||||
public IEnumerable<(HitResult result, int count, int? maxCount)> GetStatisticsForDisplay()
|
||||
{
|
||||
foreach (var key in OrderAttributeUtils.GetValuesInOrder<HitResult>())
|
||||
{
|
||||
if (key.IsBonus())
|
||||
continue;
|
||||
|
||||
int value = Statistics.GetOrDefault(key);
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case HitResult.SmallTickHit:
|
||||
{
|
||||
int total = value + Statistics.GetOrDefault(HitResult.SmallTickMiss);
|
||||
if (total > 0)
|
||||
yield return (key, value, total);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case HitResult.LargeTickHit:
|
||||
{
|
||||
int total = value + Statistics.GetOrDefault(HitResult.LargeTickMiss);
|
||||
if (total > 0)
|
||||
yield return (key, value, total);
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case HitResult.SmallTickMiss:
|
||||
case HitResult.LargeTickMiss:
|
||||
break;
|
||||
|
||||
default:
|
||||
if (value > 0 || key == HitResult.Miss)
|
||||
yield return (key, value, null);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
protected class DeserializedMod : IMod
|
||||
{
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
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;
|
||||
|
@ -116,7 +117,7 @@ private void load()
|
|||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0, 5),
|
||||
ChildrenEnumerable = score.SortedStatistics.Select(s => createStatistic(s.Key.GetDescription(), s.Value.ToString()))
|
||||
ChildrenEnumerable = score.GetStatisticsForDisplay().Select(s => createStatistic(s.result, s.count, s.maxCount))
|
||||
},
|
||||
new FillFlowContainer
|
||||
{
|
||||
|
@ -198,6 +199,9 @@ private void load()
|
|||
};
|
||||
}
|
||||
|
||||
private Drawable createStatistic(HitResult result, int count, int? maxCount)
|
||||
=> createStatistic(result.GetDescription(), maxCount == null ? $"{count}" : $"{count}/{maxCount}");
|
||||
|
||||
private Drawable createStatistic(string key, string value) => new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
|
|
|
@ -65,8 +65,9 @@ private void load()
|
|||
};
|
||||
|
||||
var bottomStatistics = new List<StatisticDisplay>();
|
||||
foreach (var stat in score.SortedStatistics)
|
||||
bottomStatistics.Add(new HitResultStatistic(stat.Key, stat.Value));
|
||||
|
||||
foreach (var (key, value, maxCount) in score.GetStatisticsForDisplay())
|
||||
bottomStatistics.Add(new HitResultStatistic(key, value, maxCount));
|
||||
|
||||
statisticDisplays.AddRange(topStatistics);
|
||||
statisticDisplays.AddRange(bottomStatistics);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
|
@ -16,6 +17,7 @@ namespace osu.Game.Screens.Ranking.Expanded.Statistics
|
|||
public class CounterStatistic : StatisticDisplay
|
||||
{
|
||||
private readonly int count;
|
||||
private readonly int? maxCount;
|
||||
|
||||
private RollingCounter<int> counter;
|
||||
|
||||
|
@ -24,10 +26,12 @@ public class CounterStatistic : StatisticDisplay
|
|||
/// </summary>
|
||||
/// <param name="header">The name of the statistic.</param>
|
||||
/// <param name="count">The value to display.</param>
|
||||
public CounterStatistic(string header, int count)
|
||||
/// <param name="maxCount">The maximum value of <paramref name="count"/>. Not displayed if null.</param>
|
||||
public CounterStatistic(string header, int count, int? maxCount = null)
|
||||
: base(header)
|
||||
{
|
||||
this.count = count;
|
||||
this.maxCount = maxCount;
|
||||
}
|
||||
|
||||
public override void Appear()
|
||||
|
@ -36,7 +40,33 @@ public override void Appear()
|
|||
counter.Current.Value = count;
|
||||
}
|
||||
|
||||
protected override Drawable CreateContent() => counter = new Counter();
|
||||
protected override Drawable CreateContent()
|
||||
{
|
||||
var container = new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Child = counter = new Counter
|
||||
{
|
||||
Anchor = Anchor.TopCentre,
|
||||
Origin = Anchor.TopCentre
|
||||
}
|
||||
};
|
||||
|
||||
if (maxCount != null)
|
||||
{
|
||||
container.Add(new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.BottomCentre,
|
||||
Origin = Anchor.BottomCentre,
|
||||
Font = OsuFont.Torus.With(size: 12, fixedWidth: true),
|
||||
Spacing = new Vector2(-2, 0),
|
||||
Text = $"/{maxCount}"
|
||||
});
|
||||
}
|
||||
|
||||
return container;
|
||||
}
|
||||
|
||||
private class Counter : RollingCounter<int>
|
||||
{
|
||||
|
|
|
@ -12,8 +12,8 @@ public class HitResultStatistic : CounterStatistic
|
|||
{
|
||||
private readonly HitResult result;
|
||||
|
||||
public HitResultStatistic(HitResult result, int count)
|
||||
: base(result.GetDescription(), count)
|
||||
public HitResultStatistic(HitResult result, int count, int? maxCount = null)
|
||||
: base(result.GetDescription(), count, maxCount)
|
||||
{
|
||||
this.result = result;
|
||||
}
|
||||
|
|
|
@ -37,6 +37,12 @@ public TestScoreInfo(RulesetInfo ruleset)
|
|||
Statistics[HitResult.Meh] = 50;
|
||||
Statistics[HitResult.Good] = 100;
|
||||
Statistics[HitResult.Great] = 300;
|
||||
Statistics[HitResult.SmallTickHit] = 50;
|
||||
Statistics[HitResult.SmallTickMiss] = 25;
|
||||
Statistics[HitResult.LargeTickHit] = 100;
|
||||
Statistics[HitResult.LargeTickMiss] = 50;
|
||||
Statistics[HitResult.SmallBonus] = 10;
|
||||
Statistics[HitResult.SmallBonus] = 50;
|
||||
|
||||
Position = 1;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue