2019-08-09 22:04:26 +02:00
|
|
|
using System;
|
2019-09-09 20:56:10 +02:00
|
|
|
using Microsoft.Xna.Framework.Input;
|
2019-08-09 22:04:26 +02:00
|
|
|
|
|
|
|
namespace MLEM.Misc {
|
2020-05-21 17:21:34 +02:00
|
|
|
/// <summary>
|
|
|
|
/// A helper class that allows easier usage of <see cref="Enum"/> values.
|
|
|
|
/// </summary>
|
2019-08-09 22:04:26 +02:00
|
|
|
public static class EnumHelper {
|
|
|
|
|
2020-05-21 17:21:34 +02:00
|
|
|
/// <summary>
|
|
|
|
/// All values of the <see cref="Buttons"/> enum.
|
|
|
|
/// </summary>
|
2022-07-29 19:52:01 +02:00
|
|
|
public static readonly Buttons[] Buttons = EnumHelper.GetValues<Buttons>();
|
2020-05-21 17:21:34 +02:00
|
|
|
/// <summary>
|
|
|
|
/// All values of the <see cref="Keys"/> enum.
|
|
|
|
/// </summary>
|
2022-07-29 19:52:01 +02:00
|
|
|
public static readonly Keys[] Keys = EnumHelper.GetValues<Keys>();
|
2019-09-09 20:56:10 +02:00
|
|
|
|
2020-05-21 17:21:34 +02:00
|
|
|
/// <summary>
|
2022-07-29 19:52:01 +02:00
|
|
|
/// Returns an array containing all of the values of the given enum type.
|
|
|
|
/// Note that this method is a version-independent equivalent of .NET 5's <c>Enum.GetValues<TEnum></c>.
|
2020-05-21 17:21:34 +02:00
|
|
|
/// </summary>
|
|
|
|
/// <typeparam name="T">The type whose enum to get</typeparam>
|
|
|
|
/// <returns>An enumerable of the values of the enum, in declaration order.</returns>
|
2022-07-29 19:52:01 +02:00
|
|
|
public static T[] GetValues<T>() {
|
|
|
|
return (T[]) Enum.GetValues(typeof(T));
|
2019-08-09 22:04:26 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2022-06-17 18:23:47 +02:00
|
|
|
}
|