mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Fix SettingsItem bindable logic (#7080)
Fix SettingsItem bindable logic
This commit is contained in:
@ -53,27 +53,10 @@ namespace osu.Game.Overlays.Settings
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// hold a reference to the provided bindable so we don't have to in every settings section.
|
|
||||||
private Bindable<T> bindable;
|
|
||||||
|
|
||||||
public virtual Bindable<T> Bindable
|
public virtual Bindable<T> Bindable
|
||||||
{
|
{
|
||||||
get => bindable;
|
get => controlWithCurrent.Current;
|
||||||
|
set => controlWithCurrent.Current = value;
|
||||||
set
|
|
||||||
{
|
|
||||||
if (bindable != null)
|
|
||||||
controlWithCurrent?.Current.UnbindFrom(bindable);
|
|
||||||
|
|
||||||
bindable = value;
|
|
||||||
controlWithCurrent?.Current.BindTo(bindable);
|
|
||||||
|
|
||||||
if (ShowsDefaultIndicator)
|
|
||||||
{
|
|
||||||
restoreDefaultButton.Bindable = bindable.GetBoundCopy();
|
|
||||||
restoreDefaultButton.Bindable.TriggerChange();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual IEnumerable<string> FilterTerms => Keywords == null ? new[] { LabelText } : new List<string>(Keywords) { LabelText }.ToArray();
|
public virtual IEnumerable<string> FilterTerms => Keywords == null ? new[] { LabelText } : new List<string>(Keywords) { LabelText }.ToArray();
|
||||||
@ -110,7 +93,12 @@ namespace osu.Game.Overlays.Settings
|
|||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
if (controlWithCurrent != null)
|
if (controlWithCurrent != null)
|
||||||
|
{
|
||||||
controlWithCurrent.Current.DisabledChanged += disabled => { Colour = disabled ? Color4.Gray : Color4.White; };
|
controlWithCurrent.Current.DisabledChanged += disabled => { Colour = disabled ? Color4.Gray : Color4.White; };
|
||||||
|
|
||||||
|
if (ShowsDefaultIndicator)
|
||||||
|
restoreDefaultButton.Bindable = controlWithCurrent.Current;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class RestoreDefaultValueButton : Container, IHasTooltip
|
private class RestoreDefaultValueButton : Container, IHasTooltip
|
||||||
@ -125,6 +113,7 @@ namespace osu.Game.Overlays.Settings
|
|||||||
bindable = value;
|
bindable = value;
|
||||||
bindable.ValueChanged += _ => UpdateState();
|
bindable.ValueChanged += _ => UpdateState();
|
||||||
bindable.DisabledChanged += _ => UpdateState();
|
bindable.DisabledChanged += _ => UpdateState();
|
||||||
|
UpdateState();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user