mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 22:56:36 +09:00
Avoid multiple synchronous overheads in SettingsItem
This commit is contained in:
@ -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()
|
||||
|
Reference in New Issue
Block a user