1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-22 21:00:33 +08:00

Avoid multiple synchronous overheads in SettingsItem

This commit is contained in:
Dean Herbert 2021-08-16 19:16:48 +09:00
parent 237d3e656b
commit 8d051d9fa0

View File

@ -93,15 +93,13 @@ namespace osu.Game.Overlays.Settings
public bool MatchingFilter
{
set => this.FadeTo(value ? 1 : 0);
set => Alpha = value ? 1 : 0;
}
public bool FilteringActive { get; set; }
public event Action SettingChanged;
private readonly RestoreDefaultValueButton<T> restoreDefaultButton;
protected SettingsItem()
{
RelativeSizeAxes = Axes.X;
@ -110,7 +108,6 @@ namespace osu.Game.Overlays.Settings
InternalChildren = new Drawable[]
{
restoreDefaultButton = new RestoreDefaultValueButton<T>(),
FlowContent = new FillFlowContainer
{
RelativeSizeAxes = Axes.X,
@ -122,7 +119,11 @@ namespace osu.Game.Overlays.Settings
},
},
};
}
[BackgroundDependencyLoader]
private void load()
{
// all bindable logic is in constructor intentionally to support "CreateSettingsControls" being used in a context it is
// never loaded, but requires bindable storage.
if (controlWithCurrent == null)
@ -130,14 +131,15 @@ namespace osu.Game.Overlays.Settings
controlWithCurrent.Current.ValueChanged += _ => SettingChanged?.Invoke();
controlWithCurrent.Current.DisabledChanged += _ => updateDisabled();
}
protected override void LoadComplete()
{
base.LoadComplete();
// intentionally done before LoadComplete to avoid overhead.
if (ShowsDefaultIndicator)
restoreDefaultButton.Current = controlWithCurrent.Current;
{
AddInternal(new RestoreDefaultValueButton<T>
{
Current = controlWithCurrent.Current,
});
}
}
private void updateDisabled()