mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 08:32:57 +08:00
Show hit error on results screen
Leading up to implementation of "local offset", this feels like a good thing to have visible first and foremost.
This commit is contained in:
parent
97de36d849
commit
a41e1c80f1
@ -394,6 +394,7 @@ namespace osu.Game.Rulesets.Mania
|
||||
{
|
||||
new StatisticItem(string.Empty, () => new SimpleStatisticTable(3, new SimpleStatisticItem[]
|
||||
{
|
||||
new AverageHitError(score.HitEvents),
|
||||
new UnstableRate(score.HitEvents)
|
||||
}), true)
|
||||
}
|
||||
|
@ -314,6 +314,7 @@ namespace osu.Game.Rulesets.Osu
|
||||
{
|
||||
new StatisticItem(string.Empty, () => new SimpleStatisticTable(3, new SimpleStatisticItem[]
|
||||
{
|
||||
new AverageHitError(timedHitEvents),
|
||||
new UnstableRate(timedHitEvents)
|
||||
}), true)
|
||||
}
|
||||
|
@ -237,6 +237,7 @@ namespace osu.Game.Rulesets.Taiko
|
||||
{
|
||||
new StatisticItem(string.Empty, () => new SimpleStatisticTable(3, new SimpleStatisticItem[]
|
||||
{
|
||||
new AverageHitError(timedHitEvents),
|
||||
new UnstableRate(timedHitEvents)
|
||||
}), true)
|
||||
}
|
||||
|
@ -22,6 +22,9 @@ namespace osu.Game.Rulesets.Scoring
|
||||
return 10 * standardDeviation(timeOffsets);
|
||||
}
|
||||
|
||||
public static double? CalculateAverageHitError(this IEnumerable<HitEvent> hitEvents) =>
|
||||
hitEvents.Where(affectsUnstableRate).Select(ev => ev.TimeOffset).Average();
|
||||
|
||||
private static bool affectsUnstableRate(HitEvent e) => !(e.HitObject.HitWindows is HitWindows.EmptyHitWindows) && e.Result.IsHit();
|
||||
|
||||
private static double? standardDeviation(double[] timeOffsets)
|
||||
|
27
osu.Game/Screens/Ranking/Statistics/AverageHitError.cs
Normal file
27
osu.Game/Screens/Ranking/Statistics/AverageHitError.cs
Normal file
@ -0,0 +1,27 @@
|
||||
// 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.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Rulesets.Scoring;
|
||||
|
||||
namespace osu.Game.Screens.Ranking.Statistics
|
||||
{
|
||||
/// <summary>
|
||||
/// Displays the unstable rate statistic for a given play.
|
||||
/// </summary>
|
||||
public class AverageHitError : SimpleStatisticItem<double?>
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates and computes an <see cref="AverageHitError"/> statistic.
|
||||
/// </summary>
|
||||
/// <param name="hitEvents">Sequence of <see cref="HitEvent"/>s to calculate the unstable rate based on.</param>
|
||||
public AverageHitError(IEnumerable<HitEvent> hitEvents)
|
||||
: base("Average Hit Error")
|
||||
{
|
||||
Value = hitEvents.CalculateAverageHitError();
|
||||
}
|
||||
|
||||
protected override string DisplayValue(double? value) => value == null ? "(not available)" : $"{Math.Abs(value.Value):N2} ms {(value.Value < 0 ? "early" : "late")}";
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user