2019-01-24 08:43:03 +00: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 09:19:50 +00:00
|
|
|
|
|
2016-11-12 10:44:16 +00:00
|
|
|
|
using osu.Framework.Allocation;
|
2016-10-13 14:57:05 +00:00
|
|
|
|
using osu.Framework.Graphics;
|
2016-10-16 09:14:17 +00:00
|
|
|
|
using osu.Framework.Graphics.Containers;
|
2017-05-15 01:55:29 +00:00
|
|
|
|
using osu.Game.Overlays.Settings;
|
2019-05-14 01:45:05 +00:00
|
|
|
|
using osu.Game.Overlays.Settings.Sections;
|
2021-07-21 04:18:24 +00:00
|
|
|
|
using osu.Game.Overlays.Settings.Sections.Input;
|
2019-05-14 01:45:05 +00:00
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
using System.Collections.Generic;
|
2019-06-11 05:28:52 +00:00
|
|
|
|
using osu.Framework.Bindables;
|
2021-04-21 05:37:11 +00:00
|
|
|
|
using osu.Framework.Localisation;
|
|
|
|
|
using osu.Game.Localisation;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2016-09-29 11:13:58 +00:00
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
|
{
|
2020-09-03 06:46:56 +00:00
|
|
|
|
public class SettingsOverlay : SettingsPanel, INamedOverlayComponent
|
2016-09-29 11:13:58 +00:00
|
|
|
|
{
|
2020-09-03 06:46:56 +00:00
|
|
|
|
public string IconTexture => "Icons/Hexacons/settings";
|
2021-04-21 05:37:11 +00:00
|
|
|
|
public LocalisableString Title => SettingsStrings.HeaderTitle;
|
|
|
|
|
public LocalisableString Description => SettingsStrings.HeaderDescription;
|
2020-09-03 06:46:56 +00:00
|
|
|
|
|
2019-05-14 01:45:05 +00:00
|
|
|
|
protected override IEnumerable<SettingsSection> CreateSections() => new SettingsSection[]
|
2017-01-13 04:49:05 +00:00
|
|
|
|
{
|
2022-04-27 07:02:39 +00:00
|
|
|
|
// This list should be kept in sync with ScreenBehaviour.
|
2019-05-14 01:45:05 +00:00
|
|
|
|
new GeneralSection(),
|
2021-10-12 04:41:35 +00:00
|
|
|
|
new SkinSection(),
|
2019-05-26 16:45:37 +00:00
|
|
|
|
new InputSection(createSubPanel(new KeyBindingPanel())),
|
2020-11-29 21:00:15 +00:00
|
|
|
|
new UserInterfaceSection(),
|
2019-05-14 01:45:05 +00:00
|
|
|
|
new GameplaySection(),
|
2021-10-12 05:31:08 +00:00
|
|
|
|
new RulesetSection(),
|
2021-10-12 04:41:35 +00:00
|
|
|
|
new AudioSection(),
|
|
|
|
|
new GraphicsSection(),
|
2019-05-14 01:45:05 +00:00
|
|
|
|
new OnlineSection(),
|
|
|
|
|
new MaintenanceSection(),
|
|
|
|
|
new DebugSection(),
|
|
|
|
|
};
|
|
|
|
|
|
2019-05-26 16:45:37 +00:00
|
|
|
|
private readonly List<SettingsSubPanel> subPanels = new List<SettingsSubPanel>();
|
|
|
|
|
|
2021-08-06 15:38:14 +00:00
|
|
|
|
private SettingsSubPanel lastOpenedSubPanel;
|
|
|
|
|
|
2020-09-03 07:32:43 +00:00
|
|
|
|
protected override Drawable CreateHeader() => new SettingsHeader(Title, Description);
|
2019-05-14 01:45:05 +00:00
|
|
|
|
protected override Drawable CreateFooter() => new SettingsFooter();
|
|
|
|
|
|
|
|
|
|
public SettingsOverlay()
|
|
|
|
|
: base(true)
|
2016-09-29 11:13:58 +00:00
|
|
|
|
{
|
2016-10-13 14:57:05 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2021-08-06 15:38:14 +00:00
|
|
|
|
public override bool AcceptsFocus => lastOpenedSubPanel == null || lastOpenedSubPanel.State.Value == Visibility.Hidden;
|
2019-05-26 16:45:37 +00:00
|
|
|
|
|
|
|
|
|
private T createSubPanel<T>(T subPanel)
|
|
|
|
|
where T : SettingsSubPanel
|
|
|
|
|
{
|
|
|
|
|
subPanel.Depth = 1;
|
|
|
|
|
subPanel.Anchor = Anchor.TopRight;
|
2021-08-06 15:38:14 +00:00
|
|
|
|
subPanel.State.ValueChanged += e => subPanelStateChanged(subPanel, e);
|
2019-05-26 16:45:37 +00:00
|
|
|
|
|
|
|
|
|
subPanels.Add(subPanel);
|
|
|
|
|
|
|
|
|
|
return subPanel;
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2021-08-06 15:38:14 +00:00
|
|
|
|
private void subPanelStateChanged(SettingsSubPanel panel, ValueChangedEvent<Visibility> state)
|
2016-10-13 14:57:05 +00:00
|
|
|
|
{
|
2019-06-11 05:28:52 +00:00
|
|
|
|
switch (state.NewValue)
|
2019-05-14 01:45:05 +00:00
|
|
|
|
{
|
|
|
|
|
case Visibility.Visible:
|
|
|
|
|
Sidebar?.FadeColour(Color4.DarkGray, 300, Easing.OutQuint);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-05-14 01:45:05 +00:00
|
|
|
|
SectionsContainer.FadeOut(300, Easing.OutQuint);
|
2021-08-07 16:56:51 +00:00
|
|
|
|
ContentContainer.MoveToX(-PANEL_WIDTH, 500, Easing.OutQuint);
|
2021-08-06 15:38:14 +00:00
|
|
|
|
|
|
|
|
|
lastOpenedSubPanel = panel;
|
2019-05-14 01:45:05 +00:00
|
|
|
|
break;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-05-14 01:45:05 +00:00
|
|
|
|
case Visibility.Hidden:
|
|
|
|
|
Sidebar?.FadeColour(Color4.White, 300, Easing.OutQuint);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-05-14 01:45:05 +00:00
|
|
|
|
SectionsContainer.FadeIn(500, Easing.OutQuint);
|
|
|
|
|
ContentContainer.MoveToX(0, 500, Easing.OutQuint);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2017-05-11 04:56:21 +00:00
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2021-08-07 16:56:51 +00:00
|
|
|
|
protected override float ExpandedPosition => lastOpenedSubPanel?.State.Value == Visibility.Visible ? -PANEL_WIDTH : base.ExpandedPosition;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-05-14 01:45:05 +00:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
2017-05-20 19:50:04 +00:00
|
|
|
|
{
|
2019-05-26 16:45:37 +00:00
|
|
|
|
foreach (var s in subPanels)
|
|
|
|
|
ContentContainer.Add(s);
|
2017-05-20 19:50:04 +00:00
|
|
|
|
}
|
2016-09-29 11:13:58 +00:00
|
|
|
|
}
|
|
|
|
|
}
|