feat: add VirtualKey.GetFancyName()

This commit is contained in:
goat 2021-12-14 21:23:21 +01:00
parent 29da317b2c
commit 7329465573
No known key found for this signature in database
GPG key ID: 7773BB5B43BA52E5
3 changed files with 252 additions and 4 deletions

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,25 @@
using System;
namespace Dalamud.Game.ClientState.Keys
{
/// <summary>
/// Attribute describing a VirtualKey.
/// </summary>
[AttributeUsage(AttributeTargets.Field)]
internal sealed class VirtualKeyAttribute : Attribute
{
/// <summary>
/// Initializes a new instance of the <see cref="VirtualKeyAttribute"/> class.
/// </summary>
/// <param name="fancyName">Fancy name of this key.</param>
public VirtualKeyAttribute(string fancyName)
{
this.FancyName = fancyName;
}
/// <summary>
/// Gets the fancy name of this virtual key.
/// </summary>
public string FancyName { get; init; }
}
}

View file

@ -0,0 +1,20 @@
using Dalamud.Utility;
namespace Dalamud.Game.ClientState.Keys
{
/// <summary>
/// Extension methods for <see cref="VirtualKey"/>.
/// </summary>
public static class VirtualKeyExtensions
{
/// <summary>
/// Get the fancy name associated with this key.
/// </summary>
/// <param name="key">The they key to act on.</param>
/// <returns>The key's fancy name.</returns>
public static string GetFancyName(this VirtualKey key)
{
return key.GetAttribute<VirtualKeyAttribute>().FancyName;
}
}
}