mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 14:32:55 +08:00
Store last opened settings subpanel rather than relying on LINQ
This commit is contained in:
parent
4620ba8787
commit
067ff0e0ad
@ -9,7 +9,6 @@ using osu.Game.Overlays.Settings.Sections;
|
||||
using osu.Game.Overlays.Settings.Sections.Input;
|
||||
using osuTK.Graphics;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Localisation;
|
||||
@ -38,6 +37,8 @@ namespace osu.Game.Overlays
|
||||
|
||||
private readonly List<SettingsSubPanel> subPanels = new List<SettingsSubPanel>();
|
||||
|
||||
private SettingsSubPanel lastOpenedSubPanel;
|
||||
|
||||
protected override Drawable CreateHeader() => new SettingsHeader(Title, Description);
|
||||
protected override Drawable CreateFooter() => new SettingsFooter();
|
||||
|
||||
@ -46,21 +47,21 @@ namespace osu.Game.Overlays
|
||||
{
|
||||
}
|
||||
|
||||
public override bool AcceptsFocus => subPanels.All(s => s.State.Value != Visibility.Visible);
|
||||
public override bool AcceptsFocus => lastOpenedSubPanel == null || lastOpenedSubPanel.State.Value == Visibility.Hidden;
|
||||
|
||||
private T createSubPanel<T>(T subPanel)
|
||||
where T : SettingsSubPanel
|
||||
{
|
||||
subPanel.Depth = 1;
|
||||
subPanel.Anchor = Anchor.TopRight;
|
||||
subPanel.State.ValueChanged += subPanelStateChanged;
|
||||
subPanel.State.ValueChanged += e => subPanelStateChanged(subPanel, e);
|
||||
|
||||
subPanels.Add(subPanel);
|
||||
|
||||
return subPanel;
|
||||
}
|
||||
|
||||
private void subPanelStateChanged(ValueChangedEvent<Visibility> state)
|
||||
private void subPanelStateChanged(SettingsSubPanel panel, ValueChangedEvent<Visibility> state)
|
||||
{
|
||||
switch (state.NewValue)
|
||||
{
|
||||
@ -69,6 +70,8 @@ namespace osu.Game.Overlays
|
||||
|
||||
SectionsContainer.FadeOut(300, Easing.OutQuint);
|
||||
ContentContainer.MoveToX(-WIDTH, 500, Easing.OutQuint);
|
||||
|
||||
lastOpenedSubPanel = panel;
|
||||
break;
|
||||
|
||||
case Visibility.Hidden:
|
||||
@ -80,7 +83,7 @@ namespace osu.Game.Overlays
|
||||
}
|
||||
}
|
||||
|
||||
protected override float ExpandedPosition => subPanels.Any(s => s.State.Value == Visibility.Visible) ? -WIDTH : base.ExpandedPosition;
|
||||
protected override float ExpandedPosition => lastOpenedSubPanel?.State.Value == Visibility.Visible ? -WIDTH : base.ExpandedPosition;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
|
Loading…
Reference in New Issue
Block a user