2019-01-24 08:43:03 +00:00
|
|
|
|
// 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.
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-11 05:48:48 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
2021-08-29 12:00:28 +00:00
|
|
|
|
using osu.Framework.Extensions.LocalisationExtensions;
|
2017-09-11 05:48:48 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2022-04-02 15:08:57 +00:00
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
|
|
|
|
using osu.Framework.Localisation;
|
2017-09-11 05:48:48 +00:00
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
2021-10-29 08:58:46 +00:00
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2021-08-12 17:19:03 +00:00
|
|
|
|
using osu.Game.Resources.Localisation.Web;
|
2017-09-11 05:48:48 +00:00
|
|
|
|
using osu.Game.Screens.Select.Details;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-25 09:26:27 +00:00
|
|
|
|
namespace osu.Game.Overlays.BeatmapSet
|
2017-09-11 05:48:48 +00:00
|
|
|
|
{
|
|
|
|
|
public class SuccessRate : Container
|
|
|
|
|
{
|
2019-06-13 09:44:00 +00:00
|
|
|
|
protected readonly FailRetryGraph Graph;
|
|
|
|
|
|
2017-09-11 05:48:48 +00:00
|
|
|
|
private readonly FillFlowContainer header;
|
2022-04-02 15:08:57 +00:00
|
|
|
|
private readonly SuccessRatePercentage successPercent;
|
2017-09-11 05:48:48 +00:00
|
|
|
|
private readonly Bar successRate;
|
|
|
|
|
private readonly Container percentContainer;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2021-10-29 08:58:46 +00:00
|
|
|
|
private APIBeatmap beatmap;
|
2019-02-28 04:31:40 +00:00
|
|
|
|
|
2021-10-29 08:58:46 +00:00
|
|
|
|
public APIBeatmap Beatmap
|
2017-09-11 05:48:48 +00:00
|
|
|
|
{
|
2021-10-29 08:58:46 +00:00
|
|
|
|
get => beatmap;
|
2017-09-11 05:48:48 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
2021-10-29 08:58:46 +00:00
|
|
|
|
if (value == beatmap) return;
|
2019-02-28 04:31:40 +00:00
|
|
|
|
|
2021-10-29 08:58:46 +00:00
|
|
|
|
beatmap = value;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-04-18 07:04:02 +00:00
|
|
|
|
updateDisplay();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateDisplay()
|
|
|
|
|
{
|
2021-10-29 08:58:46 +00:00
|
|
|
|
int passCount = beatmap?.PassCount ?? 0;
|
|
|
|
|
int playCount = beatmap?.PlayCount ?? 0;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2021-10-27 04:04:41 +00:00
|
|
|
|
float rate = playCount != 0 ? (float)passCount / playCount : 0;
|
2021-08-16 10:46:41 +00:00
|
|
|
|
successPercent.Text = rate.ToLocalisableString(@"0.#%");
|
2022-04-02 15:08:57 +00:00
|
|
|
|
successPercent.TooltipText = $"{passCount} / {playCount}";
|
2018-04-18 07:04:02 +00:00
|
|
|
|
successRate.Length = rate;
|
|
|
|
|
percentContainer.ResizeWidthTo(successRate.Length, 250, Easing.InOutCubic);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2021-10-29 08:58:46 +00:00
|
|
|
|
Graph.FailTimes = beatmap?.FailTimes;
|
2017-09-11 05:48:48 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-11 05:48:48 +00:00
|
|
|
|
public SuccessRate()
|
|
|
|
|
{
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
header = new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2020-02-04 11:00:18 +00:00
|
|
|
|
new OsuSpriteText
|
2017-09-11 05:48:48 +00:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
2021-08-12 17:19:03 +00:00
|
|
|
|
Text = BeatmapsetsStrings.ShowInfoSuccessRate,
|
2020-02-16 20:43:33 +00:00
|
|
|
|
Font = OsuFont.GetFont(size: 12)
|
2017-09-11 05:48:48 +00:00
|
|
|
|
},
|
|
|
|
|
successRate = new Bar
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Height = 5,
|
|
|
|
|
Margin = new MarginPadding { Top = 5 },
|
|
|
|
|
},
|
|
|
|
|
percentContainer = new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
2017-09-13 15:07:31 +00:00
|
|
|
|
Width = 0f,
|
2022-04-02 15:08:57 +00:00
|
|
|
|
Child = successPercent = new SuccessRatePercentage
|
2017-09-11 05:48:48 +00:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
2020-02-16 20:43:33 +00:00
|
|
|
|
Font = OsuFont.GetFont(size: 12),
|
2017-09-11 05:48:48 +00:00
|
|
|
|
},
|
|
|
|
|
},
|
2020-02-04 11:00:18 +00:00
|
|
|
|
new OsuSpriteText
|
2017-09-11 05:48:48 +00:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopCentre,
|
|
|
|
|
Origin = Anchor.TopCentre,
|
2021-08-12 17:19:03 +00:00
|
|
|
|
Text = BeatmapsetsStrings.ShowInfoPointsOfFailure,
|
2020-02-16 20:43:33 +00:00
|
|
|
|
Font = OsuFont.GetFont(size: 12),
|
2017-09-11 05:48:48 +00:00
|
|
|
|
Margin = new MarginPadding { Vertical = 20 },
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2019-06-13 09:44:00 +00:00
|
|
|
|
Graph = new FailRetryGraph
|
2017-09-11 05:48:48 +00:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-11 05:48:48 +00:00
|
|
|
|
[BackgroundDependencyLoader]
|
2020-02-04 18:55:19 +00:00
|
|
|
|
private void load(OsuColour colours, OverlayColourProvider colourProvider)
|
2017-09-11 05:48:48 +00:00
|
|
|
|
{
|
|
|
|
|
successRate.AccentColour = colours.Green;
|
2020-02-04 18:55:19 +00:00
|
|
|
|
successRate.BackgroundColour = colourProvider.Background6;
|
2018-04-18 07:04:02 +00:00
|
|
|
|
|
|
|
|
|
updateDisplay();
|
2017-09-11 05:48:48 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2017-09-11 05:48:48 +00:00
|
|
|
|
protected override void UpdateAfterChildren()
|
|
|
|
|
{
|
|
|
|
|
base.UpdateAfterChildren();
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-06-13 09:44:00 +00:00
|
|
|
|
Graph.Padding = new MarginPadding { Top = header.DrawHeight };
|
2017-09-11 05:48:48 +00:00
|
|
|
|
}
|
2022-04-02 15:08:57 +00:00
|
|
|
|
|
|
|
|
|
private class SuccessRatePercentage : OsuSpriteText, IHasTooltip
|
|
|
|
|
{
|
|
|
|
|
public LocalisableString TooltipText { get; set; }
|
|
|
|
|
}
|
2017-09-11 05:48:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|