diff --git a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs index 200c2ba786..9ea182c5c7 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseBeatmapDetails.cs @@ -42,9 +42,9 @@ namespace osu.Desktop.VisualTests.Tests StarDifficulty = 5.3f, Metric = new BeatmapMetric { - Ratings = Enumerable.Range(0,10).ToArray(), - Fails = Enumerable.Range(lastRange, 100).Select(i => i % 12 - 6).ToArray(), - Retries = Enumerable.Range(lastRange - 3, 100).Select(i => i % 12 - 6).ToArray(), + Ratings = Enumerable.Range(0,10).ToList(), + Fails = Enumerable.Range(lastRange, 100).Select(i => i % 12 - 6).ToList(), + Retries = Enumerable.Range(lastRange - 3, 100).Select(i => i % 12 - 6).ToList(), }, }, }); @@ -74,9 +74,9 @@ namespace osu.Desktop.VisualTests.Tests StarDifficulty = 5.3f, Metric = new BeatmapMetric { - Ratings = Enumerable.Range(0, 10).ToArray(), - Fails = Enumerable.Range(lastRange, 100).Select(i => i % 12 - 6).ToArray(), - Retries = Enumerable.Range(lastRange - 3, 100).Select(i => i % 12 - 6).ToArray(), + Ratings = Enumerable.Range(0, 10).ToList(), + Fails = Enumerable.Range(lastRange, 100).Select(i => i % 12 - 6).ToList(), + Retries = Enumerable.Range(lastRange - 3, 100).Select(i => i % 12 - 6).ToList(), }, }; lastRange += 100; diff --git a/osu.Desktop.VisualTests/Tests/TestCaseGraphAndBar.cs b/osu.Desktop.VisualTests/Tests/TestCaseGraph.cs similarity index 84% rename from osu.Desktop.VisualTests/Tests/TestCaseGraphAndBar.cs rename to osu.Desktop.VisualTests/Tests/TestCaseGraph.cs index 5ae64b5e73..7ac795f6f9 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseGraphAndBar.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseGraph.cs @@ -9,9 +9,9 @@ using System.Linq; namespace osu.Desktop.VisualTests.Tests { - internal class TestCaseGraphAndBar : TestCase + internal class TestCaseGraph : TestCase { - public override string Description => "graphs and bars, bars and graphs"; + public override string Description => "graph"; private BarGraph graph; @@ -31,6 +31,7 @@ namespace osu.Desktop.VisualTests.Tests }; AddStep("values from 1-10", () => graph.Values = Enumerable.Range(1,10).Select(i => (float)i)); + AddStep("values from 1-100", () => graph.Values = Enumerable.Range(1, 100).Select(i => (float)i)); AddStep("reversed values from 1-10", () => graph.Values = Enumerable.Range(1, 10).Reverse().Select(i => (float)i)); AddStep("Bottom to top", () => graph.Direction = BarDirection.BottomToTop); AddStep("Top to bottom", () => graph.Direction = BarDirection.TopToBottom); diff --git a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj index 44d823e50d..455e04ccec 100644 --- a/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj +++ b/osu.Desktop.VisualTests/osu.Desktop.VisualTests.csproj @@ -190,7 +190,7 @@ - + diff --git a/osu.Game/Database/BeatmapMetric.cs b/osu.Game/Database/BeatmapMetric.cs index 2302289047..6272e5d6b1 100644 --- a/osu.Game/Database/BeatmapMetric.cs +++ b/osu.Game/Database/BeatmapMetric.cs @@ -1,6 +1,8 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using System.Collections.Generic; + namespace osu.Game.Database { public class BeatmapMetric @@ -8,16 +10,16 @@ namespace osu.Game.Database /// /// Ratings for a beatmap, length should be 10 /// - public int[] Ratings { get; set; } + public List Ratings { get; set; } /// /// Fails for a beatmap, length should be 100 /// - public int[] Fails { get; set; } + public List Fails { get; set; } /// /// Retries for a beatmap, length should be 100 /// - public int[] Retries { get; set; } + public List Retries { get; set; } } } diff --git a/osu.Game/Graphics/UserInterface/BarGraph.cs b/osu.Game/Graphics/UserInterface/BarGraph.cs index b29726ab1c..41a00d7fec 100644 --- a/osu.Game/Graphics/UserInterface/BarGraph.cs +++ b/osu.Game/Graphics/UserInterface/BarGraph.cs @@ -58,7 +58,7 @@ namespace osu.Game.Graphics.UserInterface Length = values[i] / (MaxValue ?? values.Max()), Direction = Direction, }); - Remove(Children.Where((bar, index) => index >= values.Count)); + Remove(Children.Where((bar, index) => index >= values.Count).ToList()); } } } diff --git a/osu.Game/Screens/Select/BeatmapDetails.cs b/osu.Game/Screens/Select/BeatmapDetails.cs index 2414122d7b..fab36ba5a6 100644 --- a/osu.Game/Screens/Select/BeatmapDetails.cs +++ b/osu.Game/Screens/Select/BeatmapDetails.cs @@ -36,7 +36,7 @@ namespace osu.Game.Screens.Select private readonly OsuSpriteText positiveRatings; private readonly BarGraph ratingsGraph; - private readonly FillFlowContainer retryAndFailContainer; + private readonly FillFlowContainer retryFailContainer; private readonly BarGraph retryGraph; private readonly BarGraph failGraph; @@ -62,34 +62,34 @@ namespace osu.Game.Screens.Select approachRate.Value = beatmap.Difficulty.ApproachRate; stars.Value = (float)beatmap.StarDifficulty; - - List ratings = beatmap.Metric?.Ratings?.ToList() ?? new List(); - if (ratings.Count == 0) - ratingsContainer.Hide(); - else + if (beatmap.Metric?.Ratings.Count != 0) { + List ratings = beatmap.Metric?.Ratings; ratingsContainer.Show(); + negativeRatings.Text = ratings.GetRange(0, 5).Sum().ToString(); positiveRatings.Text = ratings.GetRange(5, 5).Sum().ToString(); ratingsBar.Length = (float)ratings.GetRange(0, 5).Sum() / ratings.Sum(); ratingsGraph.Values = ratings.Select(rating => (float)rating); } - - List retries = beatmap.Metric?.Retries?.ToList() ?? new List(); - List fails = beatmap.Metric?.Fails?.ToList() ?? new List(); - - if (fails.Count == 0 || retries.Count == 0) - retryAndFailContainer.Hide(); else + ratingsContainer.Hide(); + + if (beatmap.Metric?.Retries.Count != 0 && beatmap.Metric?.Fails.Count != 0) { - retryAndFailContainer.Show(); + List retries = beatmap.Metric?.Retries; + List fails = beatmap.Metric?.Fails; + + retryFailContainer.Show(); float maxValue = fails.Select((fail, index) => fail + retries[index]).Max(); failGraph.MaxValue = maxValue; retryGraph.MaxValue = maxValue; failGraph.Values = fails.Select(fail => (float)fail); retryGraph.Values = retries.Select((retry, index) => retry + MathHelper.Clamp(fails[index], 0, maxValue)); } + else + retryFailContainer.Hide(); } } @@ -233,7 +233,7 @@ namespace osu.Game.Screens.Select }, }, }, - retryAndFailContainer = new FillFlowContainer + retryFailContainer = new FillFlowContainer { RelativeSizeAxes = Axes.X, AutoSizeAxes = Axes.Y,