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
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Game.Overlays.Settings;
|
2019-05-14 01:45:05 +00:00
|
|
|
|
using osu.Game.Overlays.Settings.Sections;
|
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
using System.Collections.Generic;
|
2019-05-26 16:45:37 +00:00
|
|
|
|
using System.Linq;
|
2019-06-11 05:28:52 +00:00
|
|
|
|
using osu.Framework.Bindables;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays
|
|
|
|
|
{
|
2020-09-03 06:46:56 +00:00
|
|
|
|
public class SettingsOverlay : SettingsPanel, INamedOverlayComponent
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2020-09-03 06:46:56 +00:00
|
|
|
|
public string IconTexture => "Icons/Hexacons/settings";
|
2020-09-03 07:32:43 +00:00
|
|
|
|
public string Title => "settings";
|
2020-09-06 17:13:06 +00:00
|
|
|
|
public string Description => "change the way osu! behaves";
|
2020-09-03 06:46:56 +00:00
|
|
|
|
|
2019-05-14 01:45:05 +00:00
|
|
|
|
protected override IEnumerable<SettingsSection> CreateSections() => new SettingsSection[]
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-05-14 01:45:05 +00:00
|
|
|
|
new GeneralSection(),
|
|
|
|
|
new GraphicsSection(),
|
|
|
|
|
new GameplaySection(),
|
|
|
|
|
new AudioSection(),
|
|
|
|
|
new SkinSection(),
|
2019-05-26 16:45:37 +00:00
|
|
|
|
new InputSection(createSubPanel(new KeyBindingPanel())),
|
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>();
|
|
|
|
|
|
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)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2019-06-11 05:28:52 +00:00
|
|
|
|
public override bool AcceptsFocus => subPanels.All(s => s.State.Value != Visibility.Visible);
|
2019-05-26 16:45:37 +00:00
|
|
|
|
|
|
|
|
|
private T createSubPanel<T>(T subPanel)
|
|
|
|
|
where T : SettingsSubPanel
|
|
|
|
|
{
|
|
|
|
|
subPanel.Depth = 1;
|
|
|
|
|
subPanel.Anchor = Anchor.TopRight;
|
2019-06-11 05:28:52 +00:00
|
|
|
|
subPanel.State.ValueChanged += subPanelStateChanged;
|
2019-05-26 16:45:37 +00:00
|
|
|
|
|
|
|
|
|
subPanels.Add(subPanel);
|
|
|
|
|
|
|
|
|
|
return subPanel;
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-06-11 05:28:52 +00:00
|
|
|
|
private void subPanelStateChanged(ValueChangedEvent<Visibility> state)
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-06-11 05:28:52 +00:00
|
|
|
|
switch (state.NewValue)
|
2019-05-14 01:45:05 +00:00
|
|
|
|
{
|
|
|
|
|
case Visibility.Visible:
|
|
|
|
|
Background.FadeTo(0.9f, 300, Easing.OutQuint);
|
|
|
|
|
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);
|
|
|
|
|
ContentContainer.MoveToX(-WIDTH, 500, Easing.OutQuint);
|
|
|
|
|
break;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-05-14 01:45:05 +00:00
|
|
|
|
case Visibility.Hidden:
|
|
|
|
|
Background.FadeTo(0.6f, 500, Easing.OutQuint);
|
|
|
|
|
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;
|
|
|
|
|
}
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-06-11 05:28:52 +00:00
|
|
|
|
protected override float ExpandedPosition => subPanels.Any(s => s.State.Value == Visibility.Visible) ? -WIDTH : base.ExpandedPosition;
|
2018-04-13 09:19:50 +00:00
|
|
|
|
|
2019-05-14 01:45:05 +00:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
2018-04-13 09:19:50 +00:00
|
|
|
|
{
|
2019-05-26 16:45:37 +00:00
|
|
|
|
foreach (var s in subPanels)
|
|
|
|
|
ContentContainer.Add(s);
|
2018-04-13 09:19:50 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|