Moved random graph values to test case, added null handling for graph values

This commit is contained in:
DrabWeb
2017-02-09 19:08:23 -04:00
parent ac6726ee2e
commit 843b58c8f4
3 changed files with 25 additions and 14 deletions

View File

@ -9,15 +9,17 @@ using osu.Framework.GameModes.Testing;
using osu.Framework.Graphics.Sprites;
using osu.Framework.GameModes.Testing;
using osu.Framework.Graphics.Colour;
using System.Collections.Generic;
namespace osu.Desktop.VisualTests
{
public class TestCaseSongProgress : TestCase
{
public override string Name => @"Song Progress";
public override string Description => @"With real data";
private SongProgress progress;
public override void Reset()
{
base.Reset();
@ -27,12 +29,22 @@ namespace osu.Desktop.VisualTests
Colour = Color4.Gray,
RelativeSizeAxes = Axes.Both
});
Add(new SongProgress
Add(progress = new SongProgress
{
Anchor = Anchor.BottomCentre,
Origin = Anchor.BottomCentre,
RelativeSizeAxes = Axes.X
});
var random = new Random();
List<int> newValues = new List<int>();
for (int i = 0; i < 1000; i++)
{
newValues.Add(random.Next(1, 11));
}
progress.DisplayValues(newValues);
}
}
}

View File

@ -84,18 +84,7 @@ namespace osu.Game.Screens.Play
current?.Track?.Start();
}
}
};
// TODO: Remove
var random = new Random();
List<int> newValues = new List<int>();
for (int i = 0; i < 1000; i++)
{
newValues.Add(random.Next(1, 11));
}
DisplayValues(newValues);
};
}
}
}

View File

@ -72,6 +72,16 @@ namespace osu.Game.Screens.Play
{
calculatedValues.RemoveAll(delegate { return true; });
if (values == null)
{
for (float i = 0; i < ColumnCount; i++)
{
calculatedValues.Add(0);
}
return;
}
float step = (float)values.Count / (float)ColumnCount;
for (float i = 0; i < values.Count; i += step)