mirror of https://github.com/ppy/osu
Merge pull request #17613 from frenzibyte/sucess-rate-tooltip
Display pass/play count in success rate percentage tooltip
This commit is contained in:
commit
a2829b4fc7
|
@ -71,7 +71,9 @@ public void TestMetrics()
|
||||||
{
|
{
|
||||||
Fails = Enumerable.Range(1, 100).Select(_ => RNG.Next(10)).ToArray(),
|
Fails = Enumerable.Range(1, 100).Select(_ => RNG.Next(10)).ToArray(),
|
||||||
Retries = Enumerable.Range(-2, 100).Select(_ => RNG.Next(10)).ToArray(),
|
Retries = Enumerable.Range(-2, 100).Select(_ => RNG.Next(10)).ToArray(),
|
||||||
}
|
},
|
||||||
|
PassCount = RNG.Next(0, 999),
|
||||||
|
PlayCount = RNG.Next(1000, 1999),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
using osu.Framework.Extensions.LocalisationExtensions;
|
using osu.Framework.Extensions.LocalisationExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Cursor;
|
||||||
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
|
@ -19,7 +21,7 @@ public class SuccessRate : Container
|
||||||
protected readonly FailRetryGraph Graph;
|
protected readonly FailRetryGraph Graph;
|
||||||
|
|
||||||
private readonly FillFlowContainer header;
|
private readonly FillFlowContainer header;
|
||||||
private readonly OsuSpriteText successPercent;
|
private readonly SuccessRatePercentage successPercent;
|
||||||
private readonly Bar successRate;
|
private readonly Bar successRate;
|
||||||
private readonly Container percentContainer;
|
private readonly Container percentContainer;
|
||||||
|
|
||||||
|
@ -45,6 +47,7 @@ private void updateDisplay()
|
||||||
|
|
||||||
float rate = playCount != 0 ? (float)passCount / playCount : 0;
|
float rate = playCount != 0 ? (float)passCount / playCount : 0;
|
||||||
successPercent.Text = rate.ToLocalisableString(@"0.#%");
|
successPercent.Text = rate.ToLocalisableString(@"0.#%");
|
||||||
|
successPercent.TooltipText = $"{passCount} / {playCount}";
|
||||||
successRate.Length = rate;
|
successRate.Length = rate;
|
||||||
percentContainer.ResizeWidthTo(successRate.Length, 250, Easing.InOutCubic);
|
percentContainer.ResizeWidthTo(successRate.Length, 250, Easing.InOutCubic);
|
||||||
|
|
||||||
|
@ -80,7 +83,7 @@ public SuccessRate()
|
||||||
RelativeSizeAxes = Axes.X,
|
RelativeSizeAxes = Axes.X,
|
||||||
AutoSizeAxes = Axes.Y,
|
AutoSizeAxes = Axes.Y,
|
||||||
Width = 0f,
|
Width = 0f,
|
||||||
Child = successPercent = new OsuSpriteText
|
Child = successPercent = new SuccessRatePercentage
|
||||||
{
|
{
|
||||||
Anchor = Anchor.TopRight,
|
Anchor = Anchor.TopRight,
|
||||||
Origin = Anchor.TopCentre,
|
Origin = Anchor.TopCentre,
|
||||||
|
@ -121,5 +124,10 @@ protected override void UpdateAfterChildren()
|
||||||
|
|
||||||
Graph.Padding = new MarginPadding { Top = header.DrawHeight };
|
Graph.Padding = new MarginPadding { Top = header.DrawHeight };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class SuccessRatePercentage : OsuSpriteText, IHasTooltip
|
||||||
|
{
|
||||||
|
public LocalisableString TooltipText { get; set; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue