changes and fixes

This commit is contained in:
Jorolf 2017-04-11 14:02:56 +02:00
parent ad41fd5c1a
commit fb5952186c
6 changed files with 30 additions and 27 deletions

View File

@ -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;

View File

@ -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);

View File

@ -190,7 +190,7 @@
<Compile Include="Tests\TestCaseBeatmapDetails.cs" />
<Compile Include="Tests\TestCaseDrawings.cs" />
<Compile Include="Tests\TestCaseGamefield.cs" />
<Compile Include="Tests\TestCaseGraphAndBar.cs" />
<Compile Include="Tests\TestCaseGraph.cs" />
<Compile Include="Tests\TestCaseMenuOverlays.cs" />
<Compile Include="Tests\TestCaseMusicController.cs" />
<Compile Include="Tests\TestCaseNotificationManager.cs" />

View File

@ -1,6 +1,8 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// 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
/// <summary>
/// Ratings for a beatmap, length should be 10
/// </summary>
public int[] Ratings { get; set; }
public List<int> Ratings { get; set; }
/// <summary>
/// Fails for a beatmap, length should be 100
/// </summary>
public int[] Fails { get; set; }
public List<int> Fails { get; set; }
/// <summary>
/// Retries for a beatmap, length should be 100
/// </summary>
public int[] Retries { get; set; }
public List<int> Retries { get; set; }
}
}

View File

@ -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());
}
}
}

View File

@ -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<int> ratings = beatmap.Metric?.Ratings?.ToList() ?? new List<int>();
if (ratings.Count == 0)
ratingsContainer.Hide();
else
if (beatmap.Metric?.Ratings.Count != 0)
{
List<int> 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<int> retries = beatmap.Metric?.Retries?.ToList() ?? new List<int>();
List<int> fails = beatmap.Metric?.Fails?.ToList() ?? new List<int>();
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<int> retries = beatmap.Metric?.Retries;
List<int> 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,