1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 12:02:55 +08:00

Allow SettingsSections to exit without a parent SettingsPanel

This commit is contained in:
Dean Herbert 2022-04-22 18:04:07 +09:00
parent ca6c292a08
commit 7258a09748

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
@ -44,7 +45,7 @@ namespace osu.Game.Overlays.Settings
public bool FilteringActive { get; set; }
[Resolved]
[Resolved(canBeNull: true)]
private SettingsPanel settingsPanel { get; set; }
protected SettingsSection()
@ -117,7 +118,7 @@ namespace osu.Game.Overlays.Settings
},
});
selectedSection = settingsPanel.CurrentSection.GetBoundCopy();
selectedSection = settingsPanel?.CurrentSection.GetBoundCopy() ?? new Bindable<SettingsSection>(this);
selectedSection.BindValueChanged(_ => updateContentFade(), true);
}
@ -138,7 +139,10 @@ namespace osu.Game.Overlays.Settings
protected override bool OnClick(ClickEvent e)
{
if (!isCurrentSection)
{
Debug.Assert(settingsPanel != null);
settingsPanel.SectionsContainer.ScrollTo(this);
}
return base.OnClick(e);
}