diff --git a/osu.Game/Graphics/UserInterface/OsuEnumDropdown.cs b/osu.Game/Graphics/UserInterface/OsuEnumDropdown.cs index fe828ca65b..5de6507bb3 100644 --- a/osu.Game/Graphics/UserInterface/OsuEnumDropdown.cs +++ b/osu.Game/Graphics/UserInterface/OsuEnumDropdown.cs @@ -13,12 +13,12 @@ namespace osu.Game.Graphics.UserInterface public OsuEnumDropdown() { if (!typeof(T).IsEnum) - throw new InvalidOperationException("SettingsDropdown only supports enums as the generic type argument"); - + throw new InvalidOperationException("OsuEnumDropdown only supports enums as the generic type argument"); + List> items = new List>(); foreach(var val in (T[])Enum.GetValues(typeof(T))) { - var field = typeof(T).GetField(Enum.GetName(typeof(T), val)); + var field = typeof(T).GetField(Enum.GetName(typeof(T), val)); items.Add( new KeyValuePair( field.GetCustomAttribute()?.Description ?? Enum.GetName(typeof(T), val), diff --git a/osu.Game/Overlays/Settings/SettingsEnumDropdown.cs b/osu.Game/Overlays/Settings/SettingsEnumDropdown.cs index a9f0848403..ffd8c04c50 100644 --- a/osu.Game/Overlays/Settings/SettingsEnumDropdown.cs +++ b/osu.Game/Overlays/Settings/SettingsEnumDropdown.cs @@ -1,32 +1,17 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using System; -using System.Reflection; -using System.ComponentModel; -using System.Collections.Generic; +using osu.Framework.Graphics; +using osu.Game.Graphics.UserInterface; namespace osu.Game.Overlays.Settings { public class SettingsEnumDropdown : SettingsDropdown { - public SettingsEnumDropdown() - { - if (!typeof(T).IsEnum) - throw new InvalidOperationException("SettingsDropdown only supports enums as the generic type argument"); - - List> items = new List>(); - foreach(var val in (T[])Enum.GetValues(typeof(T))) - { - var field = typeof(T).GetField(Enum.GetName(typeof(T), val)); - items.Add( - new KeyValuePair( - field.GetCustomAttribute()?.Description ?? Enum.GetName(typeof(T), val), - val - ) - ); - } - Items = items; - } + protected override Drawable CreateControl() => new OsuEnumDropdown + { + Margin = new MarginPadding { Top = 5 }, + RelativeSizeAxes = Axes.X, + }; } }