mirror of
https://github.com/ppy/osu
synced 2025-01-04 13:22:08 +00:00
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:
parent
b272d34960
commit
9e1c242713
@ -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")}", () =>
|
||||||
|
@ -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;
|
||||||
|
@ -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:
|
||||||
|
Loading…
Reference in New Issue
Block a user