From 0378de83466810fce0c867514e7a7e02da949d38 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Thu, 1 Dec 2016 16:45:43 -0500 Subject: [PATCH] Add DisplayName --- osu.Game/Configuration/DisplayNameAttribute.cs | 15 +++++++++++++++ osu.Game/Configuration/ProgressBarType.cs | 5 ++++- osu.Game/Overlays/Options/OptionsDropdown.cs | 7 +++++-- osu.Game/osu.Game.csproj | 1 + 4 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 osu.Game/Configuration/DisplayNameAttribute.cs diff --git a/osu.Game/Configuration/DisplayNameAttribute.cs b/osu.Game/Configuration/DisplayNameAttribute.cs new file mode 100644 index 0000000000..1665dec2dd --- /dev/null +++ b/osu.Game/Configuration/DisplayNameAttribute.cs @@ -0,0 +1,15 @@ +using System; +namespace osu.Game.Configuration +{ + [AttributeUsage(AttributeTargets.Field | AttributeTargets.Property)] + public class DisplayNameAttribute : Attribute + { + public string Name { get; set; } + + public DisplayNameAttribute(string name) + { + Name = name; + } + } +} + diff --git a/osu.Game/Configuration/ProgressBarType.cs b/osu.Game/Configuration/ProgressBarType.cs index 15f1e35712..06db19d392 100644 --- a/osu.Game/Configuration/ProgressBarType.cs +++ b/osu.Game/Configuration/ProgressBarType.cs @@ -1,11 +1,14 @@ -using System; +using System; + namespace osu.Game.Configuration { public enum ProgressBarType { Off, Pie, + [DisplayName("Top Right")] TopRight, + [DisplayName("Bottom Right")] BottomRight, Bottom } diff --git a/osu.Game/Overlays/Options/OptionsDropdown.cs b/osu.Game/Overlays/Options/OptionsDropdown.cs index d1641cd8cf..8e5a14e32f 100644 --- a/osu.Game/Overlays/Options/OptionsDropdown.cs +++ b/osu.Game/Overlays/Options/OptionsDropdown.cs @@ -1,5 +1,6 @@ using System; using System.Linq; +using System.Reflection; using OpenTK.Graphics; using osu.Framework.Configuration; using osu.Framework.Graphics; @@ -7,6 +8,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; +using osu.Game.Configuration; namespace osu.Game.Overlays.Options { @@ -52,8 +54,9 @@ namespace osu.Game.Overlays.Options Direction = FlowDirection.VerticalOnly; RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; - var items = Enum.GetNames(typeof(T)).Zip( - (T[])Enum.GetValues(typeof(T)), (a, b) => new Tuple(a, b)); + var items = typeof(T).GetFields().Where(f => !f.IsSpecialName).Zip( + (T[])Enum.GetValues(typeof(T)), (a, b) => new Tuple( + a.GetCustomAttribute()?.Name ?? a.Name, b)); Children = new Drawable[] { text = new SpriteText { Alpha = 0 }, diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index eda53c848b..11dfe0eebe 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -225,6 +225,7 @@ +