mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 11:42:54 +08:00
Use existing next/previous methods (and remove looping behaviour)
This commit is contained in:
parent
15725fb186
commit
3a01498789
@ -51,9 +51,9 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
[Test]
|
||||
public void TestBindableBeatDivisor()
|
||||
{
|
||||
AddRepeatStep("move previous", () => bindableBeatDivisor.Previous(), 2);
|
||||
AddRepeatStep("move previous", () => bindableBeatDivisor.SelectPrevious(), 2);
|
||||
AddAssert("divisor is 4", () => bindableBeatDivisor.Value == 4);
|
||||
AddRepeatStep("move next", () => bindableBeatDivisor.Next(), 1);
|
||||
AddRepeatStep("move next", () => bindableBeatDivisor.SelectNext(), 1);
|
||||
AddAssert("divisor is 12", () => bindableBeatDivisor.Value == 8);
|
||||
}
|
||||
|
||||
@ -101,6 +101,9 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
public void TestBeatChevronNavigation()
|
||||
{
|
||||
switchBeatSnap(1);
|
||||
assertBeatSnap(16);
|
||||
|
||||
switchBeatSnap(-4);
|
||||
assertBeatSnap(1);
|
||||
|
||||
switchBeatSnap(3);
|
||||
@ -110,7 +113,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
assertBeatSnap(4);
|
||||
|
||||
switchBeatSnap(-3);
|
||||
assertBeatSnap(16);
|
||||
assertBeatSnap(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
@ -207,7 +210,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
}, Math.Abs(direction));
|
||||
|
||||
private void assertBeatSnap(int expected) => AddAssert($"beat snap is {expected}",
|
||||
() => bindableBeatDivisor.Value == expected);
|
||||
() => bindableBeatDivisor.Value, () => Is.EqualTo(expected));
|
||||
|
||||
private void switchPresets(int direction) => AddRepeatStep($"move presets {(direction > 0 ? "forward" : "backward")}", () =>
|
||||
{
|
||||
|
@ -59,16 +59,18 @@ namespace osu.Game.Screens.Edit
|
||||
Value = 1;
|
||||
}
|
||||
|
||||
public void Next()
|
||||
public void SelectNext()
|
||||
{
|
||||
var presets = ValidDivisors.Value.Presets;
|
||||
Value = presets.Cast<int?>().SkipWhile(preset => preset != Value).ElementAtOrDefault(1) ?? presets[0];
|
||||
if (presets.Cast<int?>().SkipWhile(preset => preset != Value).ElementAtOrDefault(1) is int newValue)
|
||||
Value = newValue;
|
||||
}
|
||||
|
||||
public void Previous()
|
||||
public void SelectPrevious()
|
||||
{
|
||||
var presets = ValidDivisors.Value.Presets;
|
||||
Value = presets.Cast<int?>().TakeWhile(preset => preset != Value).LastOrDefault() ?? presets[^1];
|
||||
if (presets.Cast<int?>().TakeWhile(preset => preset != Value).LastOrDefault() is int newValue)
|
||||
Value = newValue;
|
||||
}
|
||||
|
||||
protected override int DefaultPrecision => 1;
|
||||
|
@ -103,13 +103,13 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
new ChevronButton
|
||||
{
|
||||
Icon = FontAwesome.Solid.ChevronLeft,
|
||||
Action = beatDivisor.Previous
|
||||
Action = beatDivisor.SelectPrevious
|
||||
},
|
||||
new DivisorDisplay { BeatDivisor = { BindTarget = beatDivisor } },
|
||||
new ChevronButton
|
||||
{
|
||||
Icon = FontAwesome.Solid.ChevronRight,
|
||||
Action = beatDivisor.Next
|
||||
Action = beatDivisor.SelectNext
|
||||
}
|
||||
},
|
||||
},
|
||||
@ -227,11 +227,11 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
switch (e.Action)
|
||||
{
|
||||
case GlobalAction.EditorCycleNextBeatSnapDivisor:
|
||||
cycle(1);
|
||||
beatDivisor.SelectNext();
|
||||
return true;
|
||||
|
||||
case GlobalAction.EditorCyclePreviousBeatSnapDivisor:
|
||||
cycle(-1);
|
||||
beatDivisor.SelectPrevious();
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -474,12 +474,12 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
switch (e.Key)
|
||||
{
|
||||
case Key.Right:
|
||||
beatDivisor.Next();
|
||||
beatDivisor.SelectNext();
|
||||
OnUserChange(Current.Value);
|
||||
return true;
|
||||
|
||||
case Key.Left:
|
||||
beatDivisor.Previous();
|
||||
beatDivisor.SelectPrevious();
|
||||
OnUserChange(Current.Value);
|
||||
return true;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user