mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 08:02:55 +08:00
Make settings more modular
This commit is contained in:
parent
384b8c0600
commit
66fa84a451
44
osu.Desktop.Tests/Visual/TestCaseKeyConfiguration.cs
Normal file
44
osu.Desktop.Tests/Visual/TestCaseKeyConfiguration.cs
Normal file
@ -0,0 +1,44 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// 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<SettingsSection> CreateSections() => new[]
|
||||
{
|
||||
new BindingsSection(),
|
||||
new BindingsSection()
|
||||
};
|
||||
}
|
||||
|
||||
public class BindingsSection : SettingsSection
|
||||
{
|
||||
public override FontAwesome Icon => FontAwesome.fa_osu_mod_nofail;
|
||||
public override string Header => "Header";
|
||||
}
|
||||
}
|
@ -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()
|
||||
|
@ -81,6 +81,7 @@
|
||||
<Compile Include="Visual\TestCaseGamefield.cs" />
|
||||
<Compile Include="Visual\TestCaseGraph.cs" />
|
||||
<Compile Include="Visual\TestCaseHitObjects.cs" />
|
||||
<Compile Include="Visual\TestCaseKeyConfiguration.cs" />
|
||||
<Compile Include="Visual\TestCaseKeyCounter.cs" />
|
||||
<Compile Include="Visual\TestCaseLeaderboard.cs" />
|
||||
<Compile Include="Visual\TestCaseManiaHitObjects.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
|
||||
{
|
||||
|
29
osu.Game/Overlays/MainSettings.cs
Normal file
29
osu.Game/Overlays/MainSettings.cs
Normal file
@ -0,0 +1,29 @@
|
||||
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// 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<SettingsSection> 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();
|
||||
}
|
||||
}
|
@ -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
|
||||
{
|
||||
|
@ -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<float> getToolbarHeight;
|
||||
|
||||
public SettingsOverlay()
|
||||
protected SettingsOverlay()
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y;
|
||||
AutoSizeAxes = Axes.X;
|
||||
}
|
||||
|
||||
protected abstract IEnumerable<SettingsSection> 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();
|
||||
|
@ -102,6 +102,7 @@
|
||||
<Compile Include="Online\API\Requests\PostMessageRequest.cs" />
|
||||
<Compile Include="Online\Chat\ErrorMessage.cs" />
|
||||
<Compile Include="Overlays\Chat\ChatTabControl.cs" />
|
||||
<Compile Include="Overlays\MainSettings.cs" />
|
||||
<Compile Include="Overlays\Music\CollectionsDropdown.cs" />
|
||||
<Compile Include="Overlays\Music\FilterControl.cs" />
|
||||
<Compile Include="Overlays\Music\PlaylistItem.cs" />
|
||||
|
Loading…
Reference in New Issue
Block a user