mirror of
https://github.com/ppy/osu.git
synced 2024-11-14 17:57:38 +08:00
63 lines
1.8 KiB
C#
63 lines
1.8 KiB
C#
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
using osuTK;
|
|
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;
|
|
public BeatmapMetrics Metrics
|
|
{
|
|
get { return metrics; }
|
|
set
|
|
{
|
|
if (value == metrics) return;
|
|
metrics = value;
|
|
|
|
var retries = Metrics?.Retries ?? new int[0];
|
|
var fails = Metrics?.Fails ?? new int[0];
|
|
|
|
float maxValue = fails.Any() ? fails.Zip(retries, (fail, retry) => fail + retry).Max() : 0;
|
|
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;
|
|
}
|
|
}
|
|
}
|