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