mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 17:13:06 +08:00
fix(SegmentedGraph): update graphNeedsUpdate
variable during Update()
loop
This commit is contained in:
parent
624e90b213
commit
5694487a7b
@ -54,49 +54,43 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
private void sinFunction(int size = 100)
|
||||
{
|
||||
const int max_value = 255;
|
||||
int[] values = new int[size];
|
||||
graph.Values = new int[size];
|
||||
|
||||
float step = 2 * MathF.PI / size;
|
||||
float x = 0;
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
values[i] = (int)(max_value * MathF.Sin(x));
|
||||
graph.Values[i] = (int)(max_value * MathF.Sin(x));
|
||||
x += step;
|
||||
}
|
||||
|
||||
graph.Values = values;
|
||||
}
|
||||
|
||||
private void bumps(int size = 100)
|
||||
{
|
||||
const int max_value = 255;
|
||||
int[] values = new int[size];
|
||||
graph.Values = new int[size];
|
||||
|
||||
float step = 2 * MathF.PI / size;
|
||||
float x = 0;
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
values[i] = (int)(max_value * Math.Abs(MathF.Sin(x)));
|
||||
graph.Values[i] = (int)(max_value * Math.Abs(MathF.Sin(x)));
|
||||
x += step;
|
||||
}
|
||||
|
||||
graph.Values = values;
|
||||
}
|
||||
|
||||
private void randomValues(int size = 100)
|
||||
{
|
||||
Random rng = new Random();
|
||||
|
||||
int[] values = new int[size];
|
||||
graph.Values = new int[size];
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
values[i] = rng.Next(255);
|
||||
graph.Values[i] = rng.Next(255);
|
||||
}
|
||||
|
||||
graph.Values = values;
|
||||
}
|
||||
|
||||
private void beatmapDensity(int granularity = 200)
|
||||
@ -106,7 +100,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
IEnumerable<HitObject> objects = beatmap.HitObjects;
|
||||
|
||||
// Taken from SongProgressGraph
|
||||
int[] values = new int[granularity];
|
||||
graph.Values = new int[granularity];
|
||||
|
||||
if (!objects.Any())
|
||||
return;
|
||||
@ -128,10 +122,8 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
int startRange = (int)((h.StartTime - firstHit) / interval);
|
||||
int endRange = (int)((endTime - firstHit) / interval);
|
||||
for (int i = startRange; i <= endRange; i++)
|
||||
values[i]++;
|
||||
graph.Values[i]++;
|
||||
}
|
||||
|
||||
graph.Values = values;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,9 +41,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
if (value == values) return;
|
||||
|
||||
values = value;
|
||||
recalculateTiers(values);
|
||||
graphNeedsUpdate = true;
|
||||
Invalidate(Invalidation.DrawNode);
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,8 +63,10 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
if (graphNeedsUpdate)
|
||||
{
|
||||
recalculateTiers(values);
|
||||
recalculateSegments();
|
||||
Invalidate(Invalidation.DrawNode);
|
||||
graphNeedsUpdate = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -170,6 +170,11 @@ namespace osu.Game.Graphics.UserInterface
|
||||
/// The value is a normalized float (from 0 to 1).
|
||||
/// </remarks>
|
||||
public float Length => End - Start;
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return $"({Tier}, {Start * 100}%, {End * 100}%)";
|
||||
}
|
||||
}
|
||||
|
||||
private class SegmentedGraphDrawNode : DrawNode
|
||||
|
Loading…
Reference in New Issue
Block a user