mirror of https://github.com/ppy/osu
Merge pull request #26689 from myQwil/divisor_cycle
Prevent custom divisor ranges from halting divisor preset cycling
This commit is contained in:
commit
baaf33d995
|
@ -210,6 +210,13 @@ public void TestBeatPresetNavigation()
|
|||
switchPresets(-1);
|
||||
assertPreset(BeatDivisorType.Custom, 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")}", () =>
|
||||
|
|
|
@ -29,10 +29,11 @@ public BindableBeatDivisor(int value = 1)
|
|||
/// Set a divisor, updating the valid divisor range appropriately.
|
||||
/// </summary>
|
||||
/// <param name="divisor">The intended divisor.</param>
|
||||
public void SetArbitraryDivisor(int divisor)
|
||||
/// <param name="preferKnownPresets">Forces changing the valid divisors to a known preset.</param>
|
||||
public void SetArbitraryDivisor(int divisor, bool preferKnownPresets = false)
|
||||
{
|
||||
// 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 (preferKnownPresets || !ValidDivisors.Value.Presets.Contains(divisor))
|
||||
{
|
||||
if (BeatDivisorPresetCollection.COMMON.Presets.Contains(divisor))
|
||||
ValidDivisors.Value = BeatDivisorPresetCollection.COMMON;
|
||||
|
|
|
@ -208,11 +208,11 @@ private void cycleDivisorType(int direction)
|
|||
switch (currentType)
|
||||
{
|
||||
case BeatDivisorType.Common:
|
||||
beatDivisor.SetArbitraryDivisor(4);
|
||||
beatDivisor.SetArbitraryDivisor(4, true);
|
||||
break;
|
||||
|
||||
case BeatDivisorType.Triplets:
|
||||
beatDivisor.SetArbitraryDivisor(6);
|
||||
beatDivisor.SetArbitraryDivisor(6, true);
|
||||
break;
|
||||
|
||||
case BeatDivisorType.Custom:
|
||||
|
|
Loading…
Reference in New Issue