From af4aeeab095d5cf53843d8757cd568768fc11d8f Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Wed, 4 Jan 2017 01:14:25 -0500 Subject: [PATCH] Update following framework changes --- osu.Game/Overlays/Options/DropdownOption.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/Options/DropdownOption.cs b/osu.Game/Overlays/Options/DropdownOption.cs index ec2bad5bdc..5d6fc0d835 100644 --- a/osu.Game/Overlays/Options/DropdownOption.cs +++ b/osu.Game/Overlays/Options/DropdownOption.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Reflection; @@ -69,9 +70,6 @@ public DropdownOption() Direction = FlowDirection.VerticalOnly; RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - var items = typeof(T).GetFields().Where(f => !f.IsSpecialName).Zip( - (T[])Enum.GetValues(typeof(T)), (a, b) => new Tuple( - a.GetCustomAttribute()?.Description ?? a.Name, b)); Children = new Drawable[] { text = new SpriteText { Alpha = 0 }, @@ -79,7 +77,7 @@ public DropdownOption() { Margin = new MarginPadding { Top = 5 }, RelativeSizeAxes = Axes.X, - Items = items.Select(item => new StyledDropDownMenuItem(item.Item1, item.Item2)) + Items = (T[])Enum.GetValues(typeof(T)), } }; dropdown.ValueChanged += Dropdown_ValueChanged; @@ -93,6 +91,17 @@ protected override DropDownComboBox CreateComboBox() { return new StyledDropDownComboBox(); } + + protected override IEnumerable> GetDropDownItems(IEnumerable values) + { + return values.Select(v => + { + var field = typeof(U).GetField(Enum.GetName(typeof(U), v)); + return new StyledDropDownMenuItem( + field.GetCustomAttribute()?.Description ?? field.Name, v); + }); + + } public StyledDropDownMenu() {