mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 02:22:56 +08:00
Move beat index colour retrieval to static function
This commit is contained in:
parent
508b92e611
commit
df665c3a3c
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
@ -80,5 +80,26 @@ namespace osu.Game.Screens.Edit
|
|||||||
return Color4.Red;
|
return Color4.Red;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Retrieves the applicable divisor for a specific beat index.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="index">The 0-based beat index.</param>
|
||||||
|
/// <param name="beatDivisor">The beat divisor.</param>
|
||||||
|
/// <returns>The applicable divisor.</returns>
|
||||||
|
public static int GetDivisorForBeatIndex(int index, int beatDivisor)
|
||||||
|
{
|
||||||
|
int beat = index % beatDivisor;
|
||||||
|
|
||||||
|
for (int i = 0; i < BindableBeatDivisor.VALID_DIVISORS.Length; i++)
|
||||||
|
{
|
||||||
|
int divisor = BindableBeatDivisor.VALID_DIVISORS[i];
|
||||||
|
|
||||||
|
if ((beat * divisor) % beatDivisor == 0)
|
||||||
|
return divisor;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -130,19 +130,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
/// <returns>The applicable colour.</returns>
|
/// <returns>The applicable colour.</returns>
|
||||||
protected ColourInfo GetColourForBeatIndex(int index)
|
protected ColourInfo GetColourForBeatIndex(int index)
|
||||||
{
|
{
|
||||||
int beat = (index + 1) % beatDivisor.Value;
|
var colour = BindableBeatDivisor.GetColourFor(BindableBeatDivisor.GetDivisorForBeatIndex(index + 1, beatDivisor.Value), Colours);
|
||||||
ColourInfo colour = Colours.Gray5;
|
|
||||||
|
|
||||||
for (int i = 0; i < BindableBeatDivisor.VALID_DIVISORS.Length; i++)
|
|
||||||
{
|
|
||||||
int divisor = BindableBeatDivisor.VALID_DIVISORS[i];
|
|
||||||
|
|
||||||
if ((beat * divisor) % beatDivisor.Value == 0)
|
|
||||||
{
|
|
||||||
colour = BindableBeatDivisor.GetColourFor(divisor, Colours);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int repeatIndex = index / beatDivisor.Value;
|
int repeatIndex = index / beatDivisor.Value;
|
||||||
return colour.MultiplyAlpha(0.5f / (repeatIndex + 1));
|
return colour.MultiplyAlpha(0.5f / (repeatIndex + 1));
|
||||||
|
Loading…
Reference in New Issue
Block a user