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