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
|
|
|
|
|
2018-11-20 07:51:59 +00:00
|
|
|
|
using osuTK;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.UserInterface;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
|
|
|
|
|
namespace osu.Game.Screens.Select.Details
|
|
|
|
|
{
|
|
|
|
|
public class FailRetryGraph : Container
|
|
|
|
|
{
|
|
|
|
|
private readonly BarGraph retryGraph, failGraph;
|
|
|
|
|
|
|
|
|
|
private BeatmapMetrics metrics;
|
2019-02-28 04:31:40 +00:00
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
public BeatmapMetrics Metrics
|
|
|
|
|
{
|
2019-02-28 04:58:19 +00:00
|
|
|
|
get => metrics;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value == metrics) return;
|
2019-02-28 04:31:40 +00:00
|
|
|
|
|
2018-04-13 09:19:50 +00:00
|
|
|
|
metrics = value;
|
|
|
|
|
|
2018-04-18 07:04:02 +00:00
|
|
|
|
var retries = Metrics?.Retries ?? new int[0];
|
|
|
|
|
var fails = Metrics?.Fails ?? new int[0];
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2018-04-18 07:04:02 +00:00
|
|
|
|
float maxValue = fails.Any() ? fails.Zip(retries, (fail, retry) => fail + retry).Max() : 0;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
failGraph.MaxValue = maxValue;
|
|
|
|
|
retryGraph.MaxValue = maxValue;
|
|
|
|
|
|
|
|
|
|
failGraph.Values = fails.Select(f => (float)f);
|
|
|
|
|
retryGraph.Values = retries.Zip(fails, (retry, fail) => retry + MathHelper.Clamp(fail, 0, maxValue));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public FailRetryGraph()
|
|
|
|
|
{
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
retryGraph = new BarGraph
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
|
|
|
|
failGraph = new BarGraph
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
|
|
|
|
retryGraph.Colour = colours.Yellow;
|
|
|
|
|
failGraph.Colour = colours.YellowDarker;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|