mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 08:20:00 +09:00
Move input handler settings creation to OsuGameBase
This commit is contained in:
@ -5,10 +5,6 @@ using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Input.Handlers;
|
||||
using osu.Framework.Input.Handlers.Joystick;
|
||||
using osu.Framework.Input.Handlers.Midi;
|
||||
using osu.Framework.Input.Handlers.Mouse;
|
||||
using osu.Framework.Input.Handlers.Tablet;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Localisation;
|
||||
@ -22,9 +18,6 @@ namespace osu.Game.Overlays.Settings.Sections
|
||||
|
||||
public override LocalisableString Header => InputSettingsStrings.InputSectionHeader;
|
||||
|
||||
[Resolved]
|
||||
private GameHost host { get; set; }
|
||||
|
||||
public override Drawable CreateIcon() => new SpriteIcon
|
||||
{
|
||||
Icon = FontAwesome.Solid.Keyboard
|
||||
@ -36,7 +29,7 @@ namespace osu.Game.Overlays.Settings.Sections
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
private void load(GameHost host, OsuGameBase game)
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
@ -45,42 +38,14 @@ namespace osu.Game.Overlays.Settings.Sections
|
||||
|
||||
foreach (var handler in host.AvailableInputHandlers)
|
||||
{
|
||||
var handlerSection = createSectionFor(handler);
|
||||
var handlerSection = game.CreateSettingsSubsectionFor(handler);
|
||||
|
||||
if (handlerSection != null)
|
||||
Add(handlerSection);
|
||||
}
|
||||
}
|
||||
|
||||
private SettingsSubsection createSectionFor(InputHandler handler)
|
||||
{
|
||||
SettingsSubsection section;
|
||||
|
||||
switch (handler)
|
||||
{
|
||||
// ReSharper disable once SuspiciousTypeConversion.Global (net standard fuckery)
|
||||
case ITabletHandler th:
|
||||
section = new TabletSettings(th);
|
||||
break;
|
||||
|
||||
case MouseHandler mh:
|
||||
section = new MouseSettings(mh);
|
||||
break;
|
||||
|
||||
// whitelist the handlers which should be displayed to avoid any weird cases of users touching settings they shouldn't.
|
||||
case JoystickHandler _:
|
||||
case MidiHandler _:
|
||||
section = new HandlerSection(handler);
|
||||
break;
|
||||
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
return section;
|
||||
}
|
||||
|
||||
private class HandlerSection : SettingsSubsection
|
||||
public class HandlerSection : SettingsSubsection
|
||||
{
|
||||
private readonly InputHandler handler;
|
||||
|
||||
|
Reference in New Issue
Block a user