2019-01-24 16:43:03 +08: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 17:19:50 +08:00
|
|
|
|
|
2019-11-20 20:19:49 +08:00
|
|
|
|
using System;
|
2018-04-13 17:19:50 +08: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 12:31:40 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
public BeatmapMetrics Metrics
|
|
|
|
|
{
|
2019-02-28 12:58:19 +08:00
|
|
|
|
get => metrics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (value == metrics) return;
|
2019-02-28 12:31:40 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
metrics = value;
|
|
|
|
|
|
2019-11-28 21:41:29 +08:00
|
|
|
|
var retries = Metrics?.Retries ?? Array.Empty<int>();
|
|
|
|
|
var fails = Metrics?.Fails ?? Array.Empty<int>();
|
2020-08-25 02:41:31 +08:00
|
|
|
|
var retriesAndFails = sumRetriesAndFails(retries, fails);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-08-25 02:41:31 +08:00
|
|
|
|
float maxValue = retriesAndFails.Any() ? retriesAndFails.Max() : 0;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
failGraph.MaxValue = maxValue;
|
|
|
|
|
retryGraph.MaxValue = maxValue;
|
|
|
|
|
|
2020-08-25 02:41:31 +08:00
|
|
|
|
failGraph.Values = fails.Select(v => (float)v);
|
|
|
|
|
retryGraph.Values = retriesAndFails.Select(v => (float)v);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-25 02:41:31 +08:00
|
|
|
|
private int[] sumRetriesAndFails(int[] retries, int[] fails)
|
|
|
|
|
{
|
|
|
|
|
var result = new int[Math.Max(retries.Length, fails.Length)];
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < retries.Length; ++i)
|
|
|
|
|
result[i] = retries[i];
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < fails.Length; ++i)
|
|
|
|
|
result[i] += fails[i];
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|