1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-15 02:42:54 +08:00

Tidy up implementation and ensure non-solid ticks start at zero alpha

This commit is contained in:
Dean Herbert 2023-05-24 13:49:29 +09:00
parent 8f1f1955df
commit 561b759bf9

View File

@ -400,12 +400,13 @@ namespace osu.Game.Screens.Edit.Compose.Components
CurrentNumber.ValueChanged -= moveMarker; CurrentNumber.ValueChanged -= moveMarker;
int largestDivisor = beatDivisor.ValidDivisors.Value.Presets.Last(); int largestDivisor = beatDivisor.ValidDivisors.Value.Presets.Last();
for (int tickIndex = 0; tickIndex <= largestDivisor; tickIndex++) for (int tickIndex = 0; tickIndex <= largestDivisor; tickIndex++)
{ {
int divisor = BindableBeatDivisor.GetDivisorForBeatIndex(tickIndex, largestDivisor, (int[])beatDivisor.ValidDivisors.Value.Presets); int divisor = BindableBeatDivisor.GetDivisorForBeatIndex(tickIndex, largestDivisor, (int[])beatDivisor.ValidDivisors.Value.Presets);
bool isSolidTick = divisor * (largestDivisor - tickIndex) == largestDivisor; bool isSolidTick = divisor * (largestDivisor - tickIndex) == largestDivisor;
AddInternal(new Tick(isSolidTick, divisor) AddInternal(new Tick(divisor, isSolidTick)
{ {
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.Centre, Origin = Anchor.Centre,
@ -424,10 +425,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
{ {
marker.MoveToX(getMappedPosition(divisor.NewValue), 100, Easing.OutQuint); marker.MoveToX(getMappedPosition(divisor.NewValue), 100, Easing.OutQuint);
foreach (Tick child in InternalChildren.OfType<Tick>()) foreach (Tick tick in InternalChildren.OfType<Tick>().Where(t => !t.AlwaysDisplayed))
{ {
float newAlpha = child.IsSolid ? 1f : divisor.NewValue % child.Divisor == 0 ? 0.2f : 0f; tick.FadeTo(divisor.NewValue % tick.Divisor == 0 ? 0.2f : 0f, 100, Easing.OutQuint);
child.FadeTo(newAlpha);
} }
} }
@ -498,13 +498,18 @@ namespace osu.Game.Screens.Edit.Compose.Components
private partial class Tick : Circle private partial class Tick : Circle
{ {
public bool IsSolid; public readonly bool AlwaysDisplayed;
public int Divisor;
public Tick(bool isSolid, int divisor) public readonly int Divisor;
public Tick(int divisor, bool alwaysDisplayed)
{ {
IsSolid = isSolid; AlwaysDisplayed = alwaysDisplayed;
Divisor = divisor; Divisor = divisor;
Size = new Vector2(6f, 12) * BindableBeatDivisor.GetSize(divisor); Size = new Vector2(6f, 12) * BindableBeatDivisor.GetSize(divisor);
Alpha = alwaysDisplayed ? 1 : 0;
InternalChild = new Box { RelativeSizeAxes = Axes.Both }; InternalChild = new Box { RelativeSizeAxes = Axes.Both };
} }
} }