mirror of
https://github.com/ppy/osu
synced 2024-12-26 00:32:52 +00:00
Fix distance snap grid showing incorrect colouring
Now matches timeline colours (based on timing point).
This commit is contained in:
parent
9a2867d3d9
commit
29daabb40a
@ -85,64 +85,64 @@ namespace osu.Game.Tests.Visual.Editor
|
||||
{
|
||||
}
|
||||
|
||||
protected override void CreateContent(Vector2 startPosition)
|
||||
protected override void CreateContent()
|
||||
{
|
||||
AddInternal(new Circle
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(5),
|
||||
Position = startPosition
|
||||
Position = StartPosition
|
||||
});
|
||||
|
||||
int beatIndex = 0;
|
||||
int indexFromPlacement = 0;
|
||||
|
||||
for (float s = startPosition.X + DistanceSpacing; s <= DrawWidth && beatIndex < MaxIntervals; s += DistanceSpacing, beatIndex++)
|
||||
for (float s = StartPosition.X + DistanceSpacing; s <= DrawWidth && indexFromPlacement < MaxIntervals; s += DistanceSpacing, indexFromPlacement++)
|
||||
{
|
||||
AddInternal(new Circle
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(5, 10),
|
||||
Position = new Vector2(s, startPosition.Y),
|
||||
Colour = GetColourForBeatIndex(beatIndex)
|
||||
Position = new Vector2(s, StartPosition.Y),
|
||||
Colour = GetColourForIndexFromPlacement(indexFromPlacement)
|
||||
});
|
||||
}
|
||||
|
||||
beatIndex = 0;
|
||||
indexFromPlacement = 0;
|
||||
|
||||
for (float s = startPosition.X - DistanceSpacing; s >= 0 && beatIndex < MaxIntervals; s -= DistanceSpacing, beatIndex++)
|
||||
for (float s = StartPosition.X - DistanceSpacing; s >= 0 && indexFromPlacement < MaxIntervals; s -= DistanceSpacing, indexFromPlacement++)
|
||||
{
|
||||
AddInternal(new Circle
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(5, 10),
|
||||
Position = new Vector2(s, startPosition.Y),
|
||||
Colour = GetColourForBeatIndex(beatIndex)
|
||||
Position = new Vector2(s, StartPosition.Y),
|
||||
Colour = GetColourForIndexFromPlacement(indexFromPlacement)
|
||||
});
|
||||
}
|
||||
|
||||
beatIndex = 0;
|
||||
indexFromPlacement = 0;
|
||||
|
||||
for (float s = startPosition.Y + DistanceSpacing; s <= DrawHeight && beatIndex < MaxIntervals; s += DistanceSpacing, beatIndex++)
|
||||
for (float s = StartPosition.Y + DistanceSpacing; s <= DrawHeight && indexFromPlacement < MaxIntervals; s += DistanceSpacing, indexFromPlacement++)
|
||||
{
|
||||
AddInternal(new Circle
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(10, 5),
|
||||
Position = new Vector2(startPosition.X, s),
|
||||
Colour = GetColourForBeatIndex(beatIndex)
|
||||
Position = new Vector2(StartPosition.X, s),
|
||||
Colour = GetColourForIndexFromPlacement(indexFromPlacement)
|
||||
});
|
||||
}
|
||||
|
||||
beatIndex = 0;
|
||||
indexFromPlacement = 0;
|
||||
|
||||
for (float s = startPosition.Y - DistanceSpacing; s >= 0 && beatIndex < MaxIntervals; s -= DistanceSpacing, beatIndex++)
|
||||
for (float s = StartPosition.Y - DistanceSpacing; s >= 0 && indexFromPlacement < MaxIntervals; s -= DistanceSpacing, indexFromPlacement++)
|
||||
{
|
||||
AddInternal(new Circle
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Size = new Vector2(10, 5),
|
||||
Position = new Vector2(startPosition.X, s),
|
||||
Colour = GetColourForBeatIndex(beatIndex)
|
||||
Position = new Vector2(StartPosition.X, s),
|
||||
Colour = GetColourForIndexFromPlacement(indexFromPlacement)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
}
|
||||
|
||||
protected override void CreateContent(Vector2 startPosition)
|
||||
protected override void CreateContent()
|
||||
{
|
||||
const float crosshair_thickness = 1;
|
||||
const float crosshair_max_size = 10;
|
||||
@ -26,7 +26,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
new Box
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Position = startPosition,
|
||||
Position = StartPosition,
|
||||
Width = crosshair_thickness,
|
||||
EdgeSmoothness = new Vector2(1),
|
||||
Height = Math.Min(crosshair_max_size, DistanceSpacing * 2),
|
||||
@ -34,15 +34,15 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
new Box
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Position = startPosition,
|
||||
Position = StartPosition,
|
||||
EdgeSmoothness = new Vector2(1),
|
||||
Width = Math.Min(crosshair_max_size, DistanceSpacing * 2),
|
||||
Height = crosshair_thickness,
|
||||
}
|
||||
});
|
||||
|
||||
float dx = Math.Max(startPosition.X, DrawWidth - startPosition.X);
|
||||
float dy = Math.Max(startPosition.Y, DrawHeight - startPosition.Y);
|
||||
float dx = Math.Max(StartPosition.X, DrawWidth - StartPosition.X);
|
||||
float dy = Math.Max(StartPosition.Y, DrawHeight - StartPosition.Y);
|
||||
float maxDistance = new Vector2(dx, dy).Length;
|
||||
int requiredCircles = Math.Min(MaxIntervals, (int)(maxDistance / DistanceSpacing));
|
||||
|
||||
@ -53,11 +53,11 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
AddInternal(new CircularProgress
|
||||
{
|
||||
Origin = Anchor.Centre,
|
||||
Position = startPosition,
|
||||
Position = StartPosition,
|
||||
Current = { Value = 1 },
|
||||
Size = new Vector2(radius),
|
||||
InnerRadius = 4 * 1f / radius,
|
||||
Colour = GetColourForBeatIndex(i)
|
||||
Colour = GetColourForIndexFromPlacement(i)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Caching;
|
||||
using osu.Framework.Graphics;
|
||||
@ -106,7 +107,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
if (!gridCache.IsValid)
|
||||
{
|
||||
ClearInternal();
|
||||
CreateContent(StartPosition);
|
||||
CreateContent();
|
||||
gridCache.Validate();
|
||||
}
|
||||
}
|
||||
@ -114,7 +115,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// <summary>
|
||||
/// Creates the content which visualises the grid ticks.
|
||||
/// </summary>
|
||||
protected abstract void CreateContent(Vector2 startPosition);
|
||||
protected abstract void CreateContent();
|
||||
|
||||
/// <summary>
|
||||
/// Snaps a position to this grid.
|
||||
@ -126,13 +127,15 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// <summary>
|
||||
/// Retrieves the applicable colour for a beat index.
|
||||
/// </summary>
|
||||
/// <param name="index">The 0-based beat index.</param>
|
||||
/// <param name="placementIndex">The 0-based beat index from the point of placement.</param>
|
||||
/// <returns>The applicable colour.</returns>
|
||||
protected ColourInfo GetColourForBeatIndex(int index)
|
||||
protected ColourInfo GetColourForIndexFromPlacement(int placementIndex)
|
||||
{
|
||||
var colour = BindableBeatDivisor.GetColourFor(BindableBeatDivisor.GetDivisorForBeatIndex(index + 1, beatDivisor.Value), Colours);
|
||||
var timingPoint = beatmap.ControlPointInfo.TimingPointAt(StartTime);
|
||||
var beatIndex = (int)Math.Round((StartTime - timingPoint.Time) / timingPoint.BeatLength * beatDivisor.Value);
|
||||
var colour = BindableBeatDivisor.GetColourFor(BindableBeatDivisor.GetDivisorForBeatIndex(beatIndex + placementIndex + 1, beatDivisor.Value), Colours);
|
||||
|
||||
int repeatIndex = index / beatDivisor.Value;
|
||||
int repeatIndex = placementIndex / beatDivisor.Value;
|
||||
return colour.MultiplyAlpha(0.5f / (repeatIndex + 1));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user