update to everything

This commit is contained in:
Jorolf
2017-04-10 16:42:23 +02:00
parent bcef1ce2b6
commit 24b4b3ad7d
7 changed files with 140 additions and 173 deletions

View File

@ -11,6 +11,11 @@ namespace osu.Game.Graphics.UserInterface
{
public class BarGraph : FillFlowContainer<Bar>
{
/// <summary>
/// Manually sets the max value, if null <see cref="Enumerable.Max(IEnumerable{float})"/> is instead used
/// </summary>
public float? MaxValue { get; set; }
private BarDirection direction = BarDirection.BottomToTop;
public new BarDirection Direction
{
@ -30,6 +35,9 @@ namespace osu.Game.Graphics.UserInterface
}
}
/// <summary>
/// A list of floats that defines the length of each <see cref="Bar"/>
/// </summary>
public IEnumerable<float> Values
{
set
@ -39,7 +47,7 @@ namespace osu.Game.Graphics.UserInterface
for (int i = 0; i < values.Count; i++)
if (graphBars.Count > i)
{
graphBars[i].Length = values[i] / values.Max();
graphBars[i].Length = values[i] / (MaxValue ?? values.Max());
graphBars[i].Size = (direction & BarDirection.Horizontal) > 0 ? new Vector2(1, 1.0f / values.Count) : new Vector2(1.0f / values.Count, 1);
}
else
@ -47,9 +55,10 @@ namespace osu.Game.Graphics.UserInterface
{
RelativeSizeAxes = Axes.Both,
Size = (direction & BarDirection.Horizontal) > 0 ? new Vector2(1, 1.0f / values.Count) : new Vector2(1.0f / values.Count, 1),
Length = values[i] / values.Max(),
Length = values[i] / (MaxValue ?? values.Max()),
Direction = Direction,
});
Remove(Children.Where((bar, index) => index >= values.Count));
}
}
}