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

Fix extended values in difficulty adjust being truncated to 10 on beatmap change #21541

Merged
merged 2 commits into from
Dec 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,21 @@ public void TestUserOverrideMaintainedOnBeatmapChange()
checkBindableAtValue("Circle Size", 9);
}

[Test]
public void TestExtendedLimitsRetainedAfterBoundCopyCreation()
{
setExtendedLimits(true);
setSliderValue("Circle Size", 11);

checkSliderAtValue("Circle Size", 11);
checkBindableAtValue("Circle Size", 11);

AddStep("create bound copy", () => _ = modDifficultyAdjust.CircleSize.GetBoundCopy());

checkSliderAtValue("Circle Size", 11);
checkBindableAtValue("Circle Size", 11);
}

[Test]
public void TestResetToDefault()
{
Expand Down
9 changes: 8 additions & 1 deletion osu.Game/Rulesets/Mods/DifficultyBindable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,18 @@ public override void BindTo(Bindable<float?> them)
if (!(them is DifficultyBindable otherDifficultyBindable))
throw new InvalidOperationException($"Cannot bind to a non-{nameof(DifficultyBindable)}.");

// ensure that MaxValue and ExtendedMaxValue are copied across first before continuing.
// not doing so may cause the value of CurrentNumber to be truncated to 10.
otherDifficultyBindable.CopyTo(this);

// set up mutual binding for ExtendedLimits to correctly set the upper bound of CurrentNumber.
ExtendedLimits.BindTarget = otherDifficultyBindable.ExtendedLimits;

// the actual values need to be copied after the max value constraints.
// set up mutual binding for CurrentNumber. this must happen after all of the above.
CurrentNumber.BindTarget = otherDifficultyBindable.CurrentNumber;

// finish up the binding by setting up weak references via the base call.
// unfortunately this will call `.CopyTo()` again, but fixing that is problematic and messy.
base.BindTo(them);
}

Expand Down