From 9e1c24271394770313e5b06e6b89ed1e73da5056 Mon Sep 17 00:00:00 2001 From: Mike Will Date: Wed, 24 Jan 2024 08:01:41 -0500 Subject: [PATCH] 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. --- .../Visual/Editing/TestSceneBeatDivisorControl.cs | 7 +++++++ osu.Game/Screens/Edit/BindableBeatDivisor.cs | 5 +++-- .../Screens/Edit/Compose/Components/BeatDivisorControl.cs | 4 ++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/osu.Game.Tests/Visual/Editing/TestSceneBeatDivisorControl.cs b/osu.Game.Tests/Visual/Editing/TestSceneBeatDivisorControl.cs index f2b3351533..6c36e6729e 100644 --- a/osu.Game.Tests/Visual/Editing/TestSceneBeatDivisorControl.cs +++ b/osu.Game.Tests/Visual/Editing/TestSceneBeatDivisorControl.cs @@ -210,6 +210,13 @@ namespace osu.Game.Tests.Visual.Editing 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")}", () => diff --git a/osu.Game/Screens/Edit/BindableBeatDivisor.cs b/osu.Game/Screens/Edit/BindableBeatDivisor.cs index ffa4f01e75..87cb191a82 100644 --- a/osu.Game/Screens/Edit/BindableBeatDivisor.cs +++ b/osu.Game/Screens/Edit/BindableBeatDivisor.cs @@ -29,10 +29,11 @@ namespace osu.Game.Screens.Edit /// Set a divisor, updating the valid divisor range appropriately. /// /// The intended divisor. - public void SetArbitraryDivisor(int divisor) + /// Ignores the current valid divisor range when true. + 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 (!ValidDivisors.Value.Presets.Contains(divisor)) + if (force || !ValidDivisors.Value.Presets.Contains(divisor)) { if (BeatDivisorPresetCollection.COMMON.Presets.Contains(divisor)) ValidDivisors.Value = BeatDivisorPresetCollection.COMMON; diff --git a/osu.Game/Screens/Edit/Compose/Components/BeatDivisorControl.cs b/osu.Game/Screens/Edit/Compose/Components/BeatDivisorControl.cs index b33edb9edb..da1a37d57f 100644 --- a/osu.Game/Screens/Edit/Compose/Components/BeatDivisorControl.cs +++ b/osu.Game/Screens/Edit/Compose/Components/BeatDivisorControl.cs @@ -208,11 +208,11 @@ namespace osu.Game.Screens.Edit.Compose.Components 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: