mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 04:13:00 +08:00
refactor(SegmentedGraph): adjust tierCount based on passed Colours
This commit is contained in:
parent
7cbc03dce6
commit
bb2ece5c71
@ -52,6 +52,28 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
AddStep("beatmap density with granularity of 200", () => beatmapDensity());
|
AddStep("beatmap density with granularity of 200", () => beatmapDensity());
|
||||||
AddStep("beatmap density with granularity of 300", () => beatmapDensity(300));
|
AddStep("beatmap density with granularity of 300", () => beatmapDensity(300));
|
||||||
AddStep("reversed values from 1-10", () => graph.Values = Enumerable.Range(1, 10).Reverse().ToArray());
|
AddStep("reversed values from 1-10", () => graph.Values = Enumerable.Range(1, 10).Reverse().ToArray());
|
||||||
|
AddStep("change colour", () =>
|
||||||
|
{
|
||||||
|
graph.TierColours = new[]
|
||||||
|
{
|
||||||
|
Colour4.White,
|
||||||
|
Colour4.LightBlue,
|
||||||
|
Colour4.Aqua,
|
||||||
|
Colour4.Blue
|
||||||
|
};
|
||||||
|
});
|
||||||
|
AddStep("reset colour", () =>
|
||||||
|
{
|
||||||
|
graph.TierColours = new[]
|
||||||
|
{
|
||||||
|
Colour4.Red,
|
||||||
|
Colour4.OrangeRed,
|
||||||
|
Colour4.Orange,
|
||||||
|
Colour4.Yellow,
|
||||||
|
Colour4.YellowGreen,
|
||||||
|
Colour4.Green
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sinFunction(int size = 100)
|
private void sinFunction(int size = 100)
|
||||||
|
@ -24,12 +24,15 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
private int[] tiers = Array.Empty<int>();
|
private int[] tiers = Array.Empty<int>();
|
||||||
private readonly SegmentManager segments;
|
private readonly SegmentManager segments;
|
||||||
|
|
||||||
private readonly int tierCount;
|
private int tierCount;
|
||||||
|
|
||||||
public SegmentedGraph(int tierCount)
|
public SegmentedGraph(int tierCount = 1)
|
||||||
{
|
{
|
||||||
this.tierCount = tierCount;
|
this.tierCount = tierCount;
|
||||||
tierColours = new Colour4[tierCount];
|
tierColours = new[]
|
||||||
|
{
|
||||||
|
new Colour4(0, 0, 0, 0)
|
||||||
|
};
|
||||||
segments = new SegmentManager(tierCount);
|
segments = new SegmentManager(tierCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,25 +58,8 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
if (value.Length == 0 || value == tierColours)
|
if (value.Length == 0 || value == tierColours)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (value.Length == tierCount)
|
tierCount = value.Length;
|
||||||
{
|
tierColours = value;
|
||||||
tierColours = value;
|
|
||||||
}
|
|
||||||
else if (value.Length < tierCount)
|
|
||||||
{
|
|
||||||
var colourList = new List<Colour4>(value);
|
|
||||||
|
|
||||||
for (int i = value.Length; i < tierCount; i++)
|
|
||||||
{
|
|
||||||
colourList.Add(value.Last());
|
|
||||||
}
|
|
||||||
|
|
||||||
tierColours = colourList.ToArray();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
tierColours = value[..tierCount];
|
|
||||||
}
|
|
||||||
|
|
||||||
graphNeedsUpdate = true;
|
graphNeedsUpdate = true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user