2019-01-24 16:43:03 +08:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Overlays.Settings;
|
2019-05-14 09:45:05 +08:00
|
|
|
|
using osu.Game.Overlays.Settings.Sections;
|
2021-07-21 12:18:24 +08:00
|
|
|
|
using osu.Game.Overlays.Settings.Sections.Input;
|
2019-05-14 09:45:05 +08:00
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
using System.Collections.Generic;
|
2019-06-11 13:28:52 +08:00
|
|
|
|
using osu.Framework.Bindables;
|
2021-04-21 13:37:11 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
|
|
|
|
using osu.Game.Localisation;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
|
{
|
2020-09-03 14:46:56 +08:00
|
|
|
|
public class SettingsOverlay : SettingsPanel, INamedOverlayComponent
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-09-03 14:46:56 +08:00
|
|
|
|
public string IconTexture => "Icons/Hexacons/settings";
|
2021-04-21 13:37:11 +08:00
|
|
|
|
public LocalisableString Title => SettingsStrings.HeaderTitle;
|
|
|
|
|
public LocalisableString Description => SettingsStrings.HeaderDescription;
|
2020-09-03 14:46:56 +08:00
|
|
|
|
|
2019-05-14 09:45:05 +08:00
|
|
|
|
protected override IEnumerable<SettingsSection> CreateSections() => new SettingsSection[]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-05-14 09:45:05 +08:00
|
|
|
|
new GeneralSection(),
|
2021-10-12 12:41:35 +08:00
|
|
|
|
new SkinSection(),
|
2019-05-27 00:45:37 +08:00
|
|
|
|
new InputSection(createSubPanel(new KeyBindingPanel())),
|
2020-11-30 05:00:15 +08:00
|
|
|
|
new UserInterfaceSection(),
|
2019-05-14 09:45:05 +08:00
|
|
|
|
new GameplaySection(),
|
2021-10-12 13:31:08 +08:00
|
|
|
|
new RulesetSection(),
|
2021-10-12 12:41:35 +08:00
|
|
|
|
new AudioSection(),
|
|
|
|
|
new GraphicsSection(),
|
2019-05-14 09:45:05 +08:00
|
|
|
|
new OnlineSection(),
|
|
|
|
|
new MaintenanceSection(),
|
|
|
|
|
new DebugSection(),
|
|
|
|
|
};
|
|
|
|
|
|
2019-05-27 00:45:37 +08:00
|
|
|
|
private readonly List<SettingsSubPanel> subPanels = new List<SettingsSubPanel>();
|
|
|
|
|
|
2021-08-06 23:38:14 +08:00
|
|
|
|
private SettingsSubPanel lastOpenedSubPanel;
|
|
|
|
|
|
2020-09-03 15:32:43 +08:00
|
|
|
|
protected override Drawable CreateHeader() => new SettingsHeader(Title, Description);
|
2019-05-14 09:45:05 +08:00
|
|
|
|
protected override Drawable CreateFooter() => new SettingsFooter();
|
|
|
|
|
|
|
|
|
|
public SettingsOverlay()
|
|
|
|
|
: base(true)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-06 23:38:14 +08:00
|
|
|
|
public override bool AcceptsFocus => lastOpenedSubPanel == null || lastOpenedSubPanel.State.Value == Visibility.Hidden;
|
2019-05-27 00:45:37 +08:00
|
|
|
|
|
|
|
|
|
private T createSubPanel<T>(T subPanel)
|
|
|
|
|
where T : SettingsSubPanel
|
|
|
|
|
{
|
|
|
|
|
subPanel.Depth = 1;
|
|
|
|
|
subPanel.Anchor = Anchor.TopRight;
|
2021-08-06 23:38:14 +08:00
|
|
|
|
subPanel.State.ValueChanged += e => subPanelStateChanged(subPanel, e);
|
2019-05-27 00:45:37 +08:00
|
|
|
|
|
|
|
|
|
subPanels.Add(subPanel);
|
|
|
|
|
|
|
|
|
|
return subPanel;
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2021-08-06 23:38:14 +08:00
|
|
|
|
private void subPanelStateChanged(SettingsSubPanel panel, ValueChangedEvent<Visibility> state)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-06-11 13:28:52 +08:00
|
|
|
|
switch (state.NewValue)
|
2019-05-14 09:45:05 +08:00
|
|
|
|
{
|
|
|
|
|
case Visibility.Visible:
|
|
|
|
|
Sidebar?.FadeColour(Color4.DarkGray, 300, Easing.OutQuint);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-05-14 09:45:05 +08:00
|
|
|
|
SectionsContainer.FadeOut(300, Easing.OutQuint);
|
2021-08-08 00:56:51 +08:00
|
|
|
|
ContentContainer.MoveToX(-PANEL_WIDTH, 500, Easing.OutQuint);
|
2021-08-06 23:38:14 +08:00
|
|
|
|
|
|
|
|
|
lastOpenedSubPanel = panel;
|
2019-05-14 09:45:05 +08:00
|
|
|
|
break;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-05-14 09:45:05 +08:00
|
|
|
|
case Visibility.Hidden:
|
|
|
|
|
Sidebar?.FadeColour(Color4.White, 300, Easing.OutQuint);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-05-14 09:45:05 +08:00
|
|
|
|
SectionsContainer.FadeIn(500, Easing.OutQuint);
|
|
|
|
|
ContentContainer.MoveToX(0, 500, Easing.OutQuint);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2021-08-08 00:56:51 +08:00
|
|
|
|
protected override float ExpandedPosition => lastOpenedSubPanel?.State.Value == Visibility.Visible ? -PANEL_WIDTH : base.ExpandedPosition;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-05-14 09:45:05 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-05-27 00:45:37 +08:00
|
|
|
|
foreach (var s in subPanels)
|
|
|
|
|
ContentContainer.Add(s);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|