1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 15:27:24 +08:00

Merge pull request #26689 from myQwil/divisor_cycle

Prevent custom divisor ranges from halting divisor preset cycling
This commit is contained in:
Dean Herbert 2024-01-25 20:46:16 +09:00 committed by GitHub
commit baaf33d995
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 12 additions and 4 deletions

View File

@ -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")}", () =>

View File

@ -29,10 +29,11 @@ namespace osu.Game.Screens.Edit
/// 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;

View File

@ -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: