mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 18:52:55 +08:00
Fix incorrect DifficultyBindable binding implementation
This commit is contained in:
parent
d5d7dd0e74
commit
242982730f
@ -71,6 +71,12 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
}
|
}
|
||||||
|
|
||||||
public DifficultyBindable()
|
public DifficultyBindable()
|
||||||
|
: this(null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public DifficultyBindable(float? defaultValue = null)
|
||||||
|
: base(defaultValue)
|
||||||
{
|
{
|
||||||
ExtendedLimits.BindValueChanged(_ => updateMaxValue());
|
ExtendedLimits.BindValueChanged(_ => updateMaxValue());
|
||||||
}
|
}
|
||||||
@ -93,15 +99,22 @@ 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
|
public override void BindTo(Bindable<float?> them)
|
||||||
{
|
{
|
||||||
BindTarget = this,
|
if (!(them is DifficultyBindable otherDifficultyBindable))
|
||||||
CurrentNumber = { BindTarget = CurrentNumber },
|
throw new InvalidOperationException($"Cannot bind to a non-{nameof(DifficultyBindable)}.");
|
||||||
ExtendedLimits = { BindTarget = ExtendedLimits },
|
|
||||||
ReadCurrentFromDifficulty = ReadCurrentFromDifficulty,
|
base.BindTo(them);
|
||||||
|
|
||||||
|
CurrentNumber.BindTarget = otherDifficultyBindable.CurrentNumber;
|
||||||
|
ExtendedLimits.BindTarget = otherDifficultyBindable.ExtendedLimits;
|
||||||
|
ReadCurrentFromDifficulty = otherDifficultyBindable.ReadCurrentFromDifficulty;
|
||||||
|
|
||||||
// the following is only safe as long as these values are effectively constants.
|
// the following is only safe as long as these values are effectively constants.
|
||||||
MaxValue = maxValue,
|
MaxValue = otherDifficultyBindable.maxValue;
|
||||||
ExtendedMaxValue = extendedMaxValue
|
ExtendedMaxValue = otherDifficultyBindable.extendedMaxValue;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
public new DifficultyBindable GetBoundCopy() => new DifficultyBindable { BindTarget = this };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user