diff --git a/osu.Desktop.Tests/Visual/TestCaseKeyConfiguration.cs b/osu.Desktop.Tests/Visual/TestCaseKeyConfiguration.cs new file mode 100644 index 0000000000..10a15d0a96 --- /dev/null +++ b/osu.Desktop.Tests/Visual/TestCaseKeyConfiguration.cs @@ -0,0 +1,44 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Game.Overlays; +using osu.Game.Overlays.Settings; +using System.Collections.Generic; +using osu.Game.Graphics; + +namespace osu.Desktop.Tests.Visual +{ + public class TestCaseKeyConfiguration : OsuTestCase + { + private readonly KeyConfiguration configuration; + + public override string Description => @"Key configuration"; + + public TestCaseKeyConfiguration() + { + Child = configuration = new KeyConfiguration(); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + configuration.Show(); + } + } + + public class KeyConfiguration : SettingsOverlay + { + protected override IEnumerable CreateSections() => new[] + { + new BindingsSection(), + new BindingsSection() + }; + } + + public class BindingsSection : SettingsSection + { + public override FontAwesome Icon => FontAwesome.fa_osu_mod_nofail; + public override string Header => "Header"; + } +} diff --git a/osu.Desktop.Tests/Visual/TestCaseSettings.cs b/osu.Desktop.Tests/Visual/TestCaseSettings.cs index 7b35009aef..1f4b88e9e3 100644 --- a/osu.Desktop.Tests/Visual/TestCaseSettings.cs +++ b/osu.Desktop.Tests/Visual/TestCaseSettings.cs @@ -13,7 +13,7 @@ namespace osu.Desktop.Tests.Visual public TestCaseSettings() { - Children = new[] { settings = new SettingsOverlay() }; + Children = new[] { settings = new MainSettings() }; } protected override void LoadComplete() diff --git a/osu.Desktop.Tests/osu.Desktop.Tests.csproj b/osu.Desktop.Tests/osu.Desktop.Tests.csproj index 3111088ff6..24d112a45c 100644 --- a/osu.Desktop.Tests/osu.Desktop.Tests.csproj +++ b/osu.Desktop.Tests/osu.Desktop.Tests.csproj @@ -81,6 +81,7 @@ + diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index f54fba4a0b..0d1e8396e4 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -182,7 +182,7 @@ namespace osu.Game LoadComponentAsync(direct = new DirectOverlay { Depth = -1 }, mainContent.Add); LoadComponentAsync(social = new SocialOverlay { Depth = -1 }, mainContent.Add); LoadComponentAsync(chat = new ChatOverlay { Depth = -1 }, mainContent.Add); - LoadComponentAsync(settings = new SettingsOverlay { Depth = -1 }, overlayContent.Add); + LoadComponentAsync(settings = new MainSettings { Depth = -1 }, overlayContent.Add); LoadComponentAsync(userProfile = new UserProfileOverlay { Depth = -2 }, mainContent.Add); LoadComponentAsync(musicController = new MusicController { diff --git a/osu.Game/Overlays/MainSettings.cs b/osu.Game/Overlays/MainSettings.cs new file mode 100644 index 0000000000..86a1262a11 --- /dev/null +++ b/osu.Game/Overlays/MainSettings.cs @@ -0,0 +1,29 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using System.Collections.Generic; +using osu.Framework.Graphics; +using osu.Game.Overlays.Settings; +using osu.Game.Overlays.Settings.Sections; + +namespace osu.Game.Overlays +{ + public class MainSettings : SettingsOverlay + { + protected override IEnumerable CreateSections() => new SettingsSection[] + { + new GeneralSection(), + new GraphicsSection(), + new GameplaySection(), + new AudioSection(), + new SkinSection(), + new InputSection(), + new OnlineSection(), + new MaintenanceSection(), + new DebugSection(), + }; + + protected override Drawable CreateHeader() => new SettingsHeader("settings", "Change the way osu! behaves"); + protected override Drawable CreateFooter() => new SettingsFooter(); + } +} \ No newline at end of file diff --git a/osu.Game/Overlays/Settings/SettingsHeader.cs b/osu.Game/Overlays/Settings/SettingsHeader.cs index c554b54a87..80d60b6e5d 100644 --- a/osu.Game/Overlays/Settings/SettingsHeader.cs +++ b/osu.Game/Overlays/Settings/SettingsHeader.cs @@ -11,6 +11,15 @@ namespace osu.Game.Overlays.Settings { public class SettingsHeader : Container { + private readonly string heading; + private readonly string subheading; + + public SettingsHeader(string heading, string subheading) + { + this.heading = heading; + this.subheading = subheading; + } + [BackgroundDependencyLoader] private void load(OsuColour colours) { @@ -28,7 +37,7 @@ namespace osu.Game.Overlays.Settings { new OsuSpriteText { - Text = "settings", + Text = heading, TextSize = 40, Margin = new MarginPadding { @@ -39,7 +48,7 @@ namespace osu.Game.Overlays.Settings new OsuSpriteText { Colour = colours.Pink, - Text = "Change the way osu! behaves", + Text = subheading, TextSize = 18, Margin = new MarginPadding { diff --git a/osu.Game/Overlays/SettingsOverlay.cs b/osu.Game/Overlays/SettingsOverlay.cs index 1dcabbfa15..c4971fd4ac 100644 --- a/osu.Game/Overlays/SettingsOverlay.cs +++ b/osu.Game/Overlays/SettingsOverlay.cs @@ -2,6 +2,7 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Collections.Generic; using System.Linq; using OpenTK.Graphics; using osu.Framework.Allocation; @@ -12,11 +13,10 @@ using osu.Framework.Input; using osu.Game.Graphics.Containers; using osu.Game.Graphics.UserInterface; using osu.Game.Overlays.Settings; -using osu.Game.Overlays.Settings.Sections; namespace osu.Game.Overlays { - public class SettingsOverlay : OsuFocusedOverlayContainer + public abstract class SettingsOverlay : OsuFocusedOverlayContainer { internal const float CONTENT_MARGINS = 10; @@ -38,27 +38,19 @@ namespace osu.Game.Overlays private Func getToolbarHeight; - public SettingsOverlay() + protected SettingsOverlay() { RelativeSizeAxes = Axes.Y; AutoSizeAxes = Axes.X; } + protected abstract IEnumerable CreateSections(); + [BackgroundDependencyLoader(permitNulls: true)] private void load(OsuGame game) { - var sections = new SettingsSection[] - { - new GeneralSection(), - new GraphicsSection(), - new GameplaySection(), - new AudioSection(), - new SkinSection(), - new InputSection(), - new OnlineSection(), - new MaintenanceSection(), - new DebugSection(), - }; + var sections = CreateSections().ToList(); + Children = new Drawable[] { new Box @@ -72,7 +64,7 @@ namespace osu.Game.Overlays RelativeSizeAxes = Axes.Y, Width = width, Margin = new MarginPadding { Left = SIDEBAR_WIDTH }, - ExpandableHeader = new SettingsHeader(), + ExpandableHeader = CreateHeader(), FixedHeader = searchTextBox = new SearchTextBox { RelativeSizeAxes = Axes.X, @@ -87,7 +79,7 @@ namespace osu.Game.Overlays Exit = Hide, }, Children = sections, - Footer = new SettingsFooter() + Footer = CreateFooter() }, sidebar = new Sidebar { @@ -121,6 +113,10 @@ namespace osu.Game.Overlays getToolbarHeight = () => game?.ToolbarOffset ?? 0; } + protected virtual Drawable CreateHeader() => new Container(); + + protected virtual Drawable CreateFooter() => new Container(); + protected override void PopIn() { base.PopIn(); diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 7690a56378..13c4938850 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -102,6 +102,7 @@ +