Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent custom divisor ranges from halting divisor preset cycling #26689

Merged
merged 2 commits into from Jan 25, 2024

Conversation

myQwil
Copy link
Contributor

@myQwil myQwil commented Jan 24, 2024

In the editor, if we enter a custom divisor of 24, it creates a custom divisor preset with the range:

{1, 2, 3, 4, 6, 8, 12, 24}

Then, when we try to switch back to the "common" or "triplets" presets, the divisor changes to the default value of those presets, but we're still stuck in the custom preset.

This happens because the custom preset contains both 4 and 6, and the preset will not change if the current valid divisor range already contains the proposed value. So the only way to manually break out of the custom preset is to enter a new custom divisor whose preset range won't contain 4 or 6.

This PR allows the current valid divisor range check to be skipped when cycling through presets.

Copy link
Collaborator

@bdach bdach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add tests

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.
@peppy
Copy link
Sponsor Member

peppy commented Jan 25, 2024

Please avoid force pushing in the future.

@@ -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="force">Ignores the current valid divisor range when true.</param>
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This reads wrong. Don't you mean "forces changing the valid divisors to a common preset"? I'd probably name this variable preferKnownPresets or experiment with extracting the logic out to a second method for this, called something like SetPresetsForDivisor(int divisor).

@peppy peppy self-requested a review January 25, 2024 11:45
@peppy peppy merged commit baaf33d into ppy:master Jan 25, 2024
2 checks passed
@myQwil myQwil deleted the divisor_cycle branch February 20, 2024 05:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants