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
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2016-11-12 18:44:16 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2016-10-13 22:57:05 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2016-10-16 17:14:17 +08:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-05-15 09:55:29 +08:00
|
|
|
|
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;
|
2023-11-24 12:16:04 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2021-04-21 13:37:11 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2023-11-24 12:16:04 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2021-04-21 13:37:11 +08:00
|
|
|
|
using osu.Game.Localisation;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2016-09-29 19:13:58 +08:00
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
|
{
|
2020-09-03 14:46:56 +08:00
|
|
|
|
public partial class SettingsOverlay : SettingsPanel, INamedOverlayComponent
|
2016-09-29 19:13:58 +08:00
|
|
|
|
{
|
2023-11-24 12:16:04 +08:00
|
|
|
|
public IconUsage Icon => HexaconsIcons.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[]
|
2017-01-13 12:49:05 +08:00
|
|
|
|
{
|
2022-04-27 15:02:39 +08:00
|
|
|
|
// This list should be kept in sync with ScreenBehaviour.
|
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)
|
2016-09-29 19:13:58 +08:00
|
|
|
|
{
|
2016-10-13 22:57:05 +08:00
|
|
|
|
}
|
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)
|
2016-10-13 22:57:05 +08:00
|
|
|
|
{
|
2019-06-11 13:28:52 +08:00
|
|
|
|
switch (state.NewValue)
|
2019-05-14 09:45:05 +08:00
|
|
|
|
{
|
|
|
|
|
case Visibility.Visible:
|
2023-12-27 01:33:17 +08:00
|
|
|
|
Sidebar.Expanded.Value = false;
|
|
|
|
|
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;
|
2023-12-27 01:33:17 +08:00
|
|
|
|
|
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:
|
2023-12-27 01:33:17 +08:00
|
|
|
|
Sidebar.Expanded.Value = true;
|
|
|
|
|
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;
|
|
|
|
|
}
|
2017-05-11 12:56:21 +08:00
|
|
|
|
}
|
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()
|
2017-05-21 03:50:04 +08:00
|
|
|
|
{
|
2019-05-27 00:45:37 +08:00
|
|
|
|
foreach (var s in subPanels)
|
|
|
|
|
ContentContainer.Add(s);
|
2017-05-21 03:50:04 +08:00
|
|
|
|
}
|
2016-09-29 19:13:58 +08:00
|
|
|
|
}
|
|
|
|
|
}
|