mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 03:02:54 +08:00
Add DisplayName
This commit is contained in:
parent
9daf524120
commit
0378de8346
15
osu.Game/Configuration/DisplayNameAttribute.cs
Normal file
15
osu.Game/Configuration/DisplayNameAttribute.cs
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,11 +1,14 @@
|
|||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace osu.Game.Configuration
|
namespace osu.Game.Configuration
|
||||||
{
|
{
|
||||||
public enum ProgressBarType
|
public enum ProgressBarType
|
||||||
{
|
{
|
||||||
Off,
|
Off,
|
||||||
Pie,
|
Pie,
|
||||||
|
[DisplayName("Top Right")]
|
||||||
TopRight,
|
TopRight,
|
||||||
|
[DisplayName("Bottom Right")]
|
||||||
BottomRight,
|
BottomRight,
|
||||||
Bottom
|
Bottom
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using osu.Framework.Configuration;
|
using osu.Framework.Configuration;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -7,6 +8,7 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Graphics.Primitives;
|
using osu.Framework.Graphics.Primitives;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
using osu.Game.Configuration;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Options
|
namespace osu.Game.Overlays.Options
|
||||||
{
|
{
|
||||||
@ -52,8 +54,9 @@ namespace osu.Game.Overlays.Options
|
|||||||
Direction = FlowDirection.VerticalOnly;
|
Direction = FlowDirection.VerticalOnly;
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
AutoSizeAxes = Axes.Y;
|
AutoSizeAxes = Axes.Y;
|
||||||
var items = Enum.GetNames(typeof(T)).Zip(
|
var items = typeof(T).GetFields().Where(f => !f.IsSpecialName).Zip(
|
||||||
(T[])Enum.GetValues(typeof(T)), (a, b) => new Tuple<string, T>(a, b));
|
(T[])Enum.GetValues(typeof(T)), (a, b) => new Tuple<string, T>(
|
||||||
|
a.GetCustomAttribute<DisplayNameAttribute>()?.Name ?? a.Name, b));
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
text = new SpriteText { Alpha = 0 },
|
text = new SpriteText { Alpha = 0 },
|
||||||
|
@ -225,6 +225,7 @@
|
|||||||
<Compile Include="Overlays\Options\SliderOption.cs" />
|
<Compile Include="Overlays\Options\SliderOption.cs" />
|
||||||
<Compile Include="Configuration\ProgressBarType.cs" />
|
<Compile Include="Configuration\ProgressBarType.cs" />
|
||||||
<Compile Include="Overlays\Options\OptionsDropdown.cs" />
|
<Compile Include="Overlays\Options\OptionsDropdown.cs" />
|
||||||
|
<Compile Include="Configuration\DisplayNameAttribute.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="$(SolutionDir)\osu-framework\osu.Framework\osu.Framework.csproj">
|
<ProjectReference Include="$(SolutionDir)\osu-framework\osu.Framework\osu.Framework.csproj">
|
||||||
|
Loading…
Reference in New Issue
Block a user