mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 15:52:54 +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.
|
||||
|
||||
using System;
|
||||
@ -80,5 +80,26 @@ namespace osu.Game.Screens.Edit
|
||||
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>
|
||||
protected ColourInfo GetColourForBeatIndex(int index)
|
||||
{
|
||||
int beat = (index + 1) % beatDivisor.Value;
|
||||
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;
|
||||
}
|
||||
}
|
||||
var colour = BindableBeatDivisor.GetColourFor(BindableBeatDivisor.GetDivisorForBeatIndex(index + 1, beatDivisor.Value), Colours);
|
||||
|
||||
int repeatIndex = index / beatDivisor.Value;
|
||||
return colour.MultiplyAlpha(0.5f / (repeatIndex + 1));
|
||||
|
Loading…
Reference in New Issue
Block a user