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
|
|
|
|
|
|
2021-03-12 17:38:16 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
2017-02-07 12:52:19 +08:00
|
|
|
|
using osu.Framework.Graphics;
|
2019-03-27 18:29:27 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2021-03-12 17:38:16 +08:00
|
|
|
|
using osu.Framework.Input.Handlers;
|
2021-07-15 11:50:34 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2021-03-12 17:38:16 +08:00
|
|
|
|
using osu.Framework.Platform;
|
2021-08-12 09:53:31 +08:00
|
|
|
|
using osu.Game.Localisation;
|
2017-05-15 09:55:29 +08:00
|
|
|
|
using osu.Game.Overlays.Settings.Sections.Input;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2017-05-15 09:55:29 +08:00
|
|
|
|
namespace osu.Game.Overlays.Settings.Sections
|
2017-02-07 12:52:19 +08:00
|
|
|
|
{
|
2017-05-15 09:55:29 +08:00
|
|
|
|
public partial class InputSection : SettingsSection
|
2017-02-07 12:52:19 +08:00
|
|
|
|
{
|
2021-03-12 17:38:16 +08:00
|
|
|
|
private readonly KeyBindingPanel keyConfig;
|
|
|
|
|
|
2021-08-12 09:53:31 +08:00
|
|
|
|
public override LocalisableString Header => InputSettingsStrings.InputSectionHeader;
|
2020-04-26 02:35:46 +08:00
|
|
|
|
|
|
|
|
|
public override Drawable CreateIcon() => new SpriteIcon
|
|
|
|
|
{
|
|
|
|
|
Icon = FontAwesome.Solid.Keyboard
|
|
|
|
|
};
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-05-14 09:45:05 +08:00
|
|
|
|
public InputSection(KeyBindingPanel keyConfig)
|
2021-03-12 17:38:16 +08:00
|
|
|
|
{
|
|
|
|
|
this.keyConfig = keyConfig;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2022-01-15 06:16:07 +08:00
|
|
|
|
private void load(GameHost host, OsuGameBase game)
|
2017-02-07 12:52:19 +08:00
|
|
|
|
{
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2021-03-12 17:38:16 +08:00
|
|
|
|
new BindingSettings(keyConfig),
|
2017-02-07 12:52:19 +08:00
|
|
|
|
};
|
2021-03-12 17:38:16 +08:00
|
|
|
|
|
|
|
|
|
foreach (var handler in host.AvailableInputHandlers)
|
|
|
|
|
{
|
2022-01-15 06:16:07 +08:00
|
|
|
|
var handlerSection = game.CreateSettingsSubsectionFor(handler);
|
2021-03-12 17:38:16 +08:00
|
|
|
|
|
|
|
|
|
if (handlerSection != null)
|
|
|
|
|
Add(handlerSection);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-15 06:16:07 +08:00
|
|
|
|
public partial class HandlerSection : SettingsSubsection
|
2021-03-12 17:38:16 +08:00
|
|
|
|
{
|
|
|
|
|
private readonly InputHandler handler;
|
|
|
|
|
|
|
|
|
|
public HandlerSection(InputHandler handler)
|
|
|
|
|
{
|
|
|
|
|
this.handler = handler;
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-18 20:17:04 +08:00
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new SettingsCheckbox
|
|
|
|
|
{
|
2021-08-12 09:53:31 +08:00
|
|
|
|
LabelText = CommonStrings.Enabled,
|
2021-03-18 20:17:04 +08:00
|
|
|
|
Current = handler.Enabled
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-15 11:50:34 +08:00
|
|
|
|
protected override LocalisableString Header => handler.Description;
|
2017-02-07 12:52:19 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|