mirror of
https://github.com/ppy/osu.git
synced 2025-02-12 13:22:56 +08:00
Do not store direct references to original bindable
`DifficultyAdjustSettingsControl` and its inner `SliderControl` were holding different references to `DifficultyBindable`s from the difficulty adjust mod, therefore leading to bindings being lost to the framework-side automatic unbind logic if the mod was toggled off and back on in rapid succession. Resolve by adding a shadowed implementation of `GetBoundCopy()` and using it to isolate the controls from the mod bindable.
This commit is contained in:
parent
79d546afa2
commit
32b4f5fbd6
@ -41,10 +41,10 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
{
|
{
|
||||||
// Intercept and extract the internal number bindable from DifficultyBindable.
|
// Intercept and extract the internal number bindable from DifficultyBindable.
|
||||||
// This will provide bounds and precision specifications for the slider bar.
|
// This will provide bounds and precision specifications for the slider bar.
|
||||||
difficultyBindable = (DifficultyBindable)value;
|
difficultyBindable = ((DifficultyBindable)value).GetBoundCopy();
|
||||||
sliderDisplayCurrent.BindTo(difficultyBindable.CurrentNumber);
|
sliderDisplayCurrent.BindTo(difficultyBindable.CurrentNumber);
|
||||||
|
|
||||||
base.Current = value;
|
base.Current = difficultyBindable;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,5 +92,16 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
{
|
{
|
||||||
CurrentNumber.MaxValue = ExtendedLimits.Value && extendedMaxValue != null ? extendedMaxValue.Value : maxValue;
|
CurrentNumber.MaxValue = ExtendedLimits.Value && extendedMaxValue != null ? extendedMaxValue.Value : maxValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public new DifficultyBindable GetBoundCopy() => new DifficultyBindable
|
||||||
|
{
|
||||||
|
BindTarget = this,
|
||||||
|
CurrentNumber = { BindTarget = CurrentNumber },
|
||||||
|
ExtendedLimits = { BindTarget = ExtendedLimits },
|
||||||
|
ReadCurrentFromDifficulty = ReadCurrentFromDifficulty,
|
||||||
|
// the following is only safe as long as these values are effectively constants.
|
||||||
|
MaxValue = maxValue,
|
||||||
|
ExtendedMaxValue = extendedMaxValue
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user