1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 17:43:05 +08:00

Use whitelist to avoid exposing settings to user that shouldn't be

This commit is contained in:
Dean Herbert 2021-03-12 18:40:38 +09:00
parent 03230edcb1
commit 3458dcc33a

View File

@ -5,6 +5,8 @@ using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Handlers; 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.Mouse;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Game.Configuration; using osu.Game.Configuration;
@ -50,11 +52,6 @@ namespace osu.Game.Overlays.Settings.Sections
private SettingsSubsection createSectionFor(InputHandler handler) private SettingsSubsection createSectionFor(InputHandler handler)
{ {
var settingsControls = handler.CreateSettingsControlsFromAllBindables(false);
if (settingsControls.Count == 0)
return null;
SettingsSubsection section; SettingsSubsection section;
switch (handler) switch (handler)
@ -63,11 +60,21 @@ namespace osu.Game.Overlays.Settings.Sections
section = new MouseSettings(mh); section = new MouseSettings(mh);
break; break;
default: // 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); section = new HandlerSection(handler);
break; break;
default:
return null;
} }
var settingsControls = handler.CreateSettingsControlsFromAllBindables(false);
if (settingsControls.Count == 0)
return null;
section.AddRange(settingsControls); section.AddRange(settingsControls);
return section; return section;