Prevent custom divisor ranges from halting preset cycling

A custom divisor like 24 or 32 will result in a range containing
many divisors that are already in the `Common` and `Triplets` presets.
When this happens, it can become impossible to cycle between presets,
because the preset can only be changed if the new divisor isn't already
contained within the current preset's range.
This commit is contained in:
Mike Will 2024-01-24 08:01:41 -05:00
parent b272d34960
commit 9e1c242713
3 changed files with 12 additions and 4 deletions

View File

@ -210,6 +210,13 @@ namespace osu.Game.Tests.Visual.Editing
switchPresets(-1); switchPresets(-1);
assertPreset(BeatDivisorType.Custom, 15); assertPreset(BeatDivisorType.Custom, 15);
assertBeatSnap(15); assertBeatSnap(15);
setDivisorViaInput(24);
assertPreset(BeatDivisorType.Custom, 24);
switchPresets(1);
assertPreset(BeatDivisorType.Common);
switchPresets(-2);
assertPreset(BeatDivisorType.Triplets);
} }
private void switchBeatSnap(int direction) => AddRepeatStep($"move snap {(direction > 0 ? "forward" : "backward")}", () => private void switchBeatSnap(int direction) => AddRepeatStep($"move snap {(direction > 0 ? "forward" : "backward")}", () =>

View File

@ -29,10 +29,11 @@ namespace osu.Game.Screens.Edit
/// Set a divisor, updating the valid divisor range appropriately. /// Set a divisor, updating the valid divisor range appropriately.
/// </summary> /// </summary>
/// <param name="divisor">The intended divisor.</param> /// <param name="divisor">The intended divisor.</param>
public void SetArbitraryDivisor(int divisor) /// <param name="force">Ignores the current valid divisor range when true.</param>
public void SetArbitraryDivisor(int divisor, bool force = false)
{ {
// If the current valid divisor range doesn't contain the proposed value, attempt to find one which does. // If the current valid divisor range doesn't contain the proposed value, attempt to find one which does.
if (!ValidDivisors.Value.Presets.Contains(divisor)) if (force || !ValidDivisors.Value.Presets.Contains(divisor))
{ {
if (BeatDivisorPresetCollection.COMMON.Presets.Contains(divisor)) if (BeatDivisorPresetCollection.COMMON.Presets.Contains(divisor))
ValidDivisors.Value = BeatDivisorPresetCollection.COMMON; ValidDivisors.Value = BeatDivisorPresetCollection.COMMON;

View File

@ -208,11 +208,11 @@ namespace osu.Game.Screens.Edit.Compose.Components
switch (currentType) switch (currentType)
{ {
case BeatDivisorType.Common: case BeatDivisorType.Common:
beatDivisor.SetArbitraryDivisor(4); beatDivisor.SetArbitraryDivisor(4, true);
break; break;
case BeatDivisorType.Triplets: case BeatDivisorType.Triplets:
beatDivisor.SetArbitraryDivisor(6); beatDivisor.SetArbitraryDivisor(6, true);
break; break;
case BeatDivisorType.Custom: case BeatDivisorType.Custom: