1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 07:27:25 +08:00

Add previous/next divisor button actions

This commit is contained in:
smoogipoo 2018-03-19 19:55:49 +09:00
parent 070db63157
commit fbc92bfa01

View File

@ -16,7 +16,10 @@ namespace osu.Game.Screens.Edit.Screens.Compose.BeatSnap
{ {
public class BeatSnapVisualiser : CompositeDrawable public class BeatSnapVisualiser : CompositeDrawable
{ {
private static readonly int[] available_divisors = { 1, 2, 3, 4, 6, 8, 12, 16 };
public readonly Bindable<int> Divisor = new Bindable<int>(1); public readonly Bindable<int> Divisor = new Bindable<int>(1);
private int currentDivisorIndex = 0;
private TickContainer tickContainer; private TickContainer tickContainer;
private DivisorText text; private DivisorText text;
@ -75,11 +78,13 @@ namespace osu.Game.Screens.Edit.Screens.Compose.BeatSnap
new DivisorButton new DivisorButton
{ {
Icon = FontAwesome.fa_chevron_left, Icon = FontAwesome.fa_chevron_left,
Action = selectPrevious
}, },
text = new DivisorText(), text = new DivisorText(),
new DivisorButton new DivisorButton
{ {
Icon = FontAwesome.fa_chevron_right, Icon = FontAwesome.fa_chevron_right,
Action = selectNext
} }
}, },
new Drawable[] new Drawable[]
@ -116,6 +121,20 @@ namespace osu.Game.Screens.Edit.Screens.Compose.BeatSnap
text.Divisor.BindTo(Divisor); text.Divisor.BindTo(Divisor);
} }
private void selectPrevious()
{
if (currentDivisorIndex == 0)
return;
Divisor.Value = available_divisors[--currentDivisorIndex];
}
private void selectNext()
{
if (currentDivisorIndex == available_divisors.Length - 1)
return;
Divisor.Value = available_divisors[++currentDivisorIndex];
}
private class DivisorText : SpriteText private class DivisorText : SpriteText
{ {
public readonly Bindable<int> Divisor = new Bindable<int>(); public readonly Bindable<int> Divisor = new Bindable<int>();