Override `CreateInstance()` in osu! bindable subclasses

Three bindables are left which don't have this overriden due to them
already not having a value-only constructor and not supporting
`GetBoundCopy()` properly:
 - `BeatmapDifficultyCache.BindableStarDifficulty`.
 - `TotalScoreBindable`
 - `TotalScoreStringBindable`

I could add support for them by passing the required data to them, as
they seem to be able to have that shared, but I'm hesitant to support
something which was already broken and never used, not sure.
This commit is contained in:
Salman Ahmed 2021-08-18 04:16:57 +03:00
parent 2411645ad7
commit 8c5d99ab21
3 changed files with 4 additions and 2 deletions

View File

@ -41,7 +41,7 @@ public override Bindable<float?> Current
{
// Intercept and extract the internal number bindable from DifficultyBindable.
// This will provide bounds and precision specifications for the slider bar.
difficultyBindable = ((DifficultyBindable)value).GetBoundCopy();
difficultyBindable = (DifficultyBindable)value.GetBoundCopy();
sliderDisplayCurrent.BindTo(difficultyBindable.CurrentNumber);
base.Current = difficultyBindable;

View File

@ -128,6 +128,6 @@ public override void UnbindFrom(IUnbindable them)
ExtendedLimits.UnbindFrom(otherDifficultyBindable.ExtendedLimits);
}
public new DifficultyBindable GetBoundCopy() => new DifficultyBindable { BindTarget = this };
protected override Bindable<float?> CreateInstance() => new DifficultyBindable();
}
}

View File

@ -41,6 +41,8 @@ public override int Value
protected override int DefaultMaxValue => VALID_DIVISORS.Last();
protected override int DefaultPrecision => 1;
protected override Bindable<int> CreateInstance() => new BindableBeatDivisor();
/// <summary>
/// Retrieves the appropriate colour for a beat divisor.
/// </summary>