1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-05-04 17:07:07 +02:00

Added an Enum constructor to GenericInput

This commit is contained in:
Ell 2022-05-18 21:45:38 +02:00
parent 30bcdc1710
commit 161d44dbe0
2 changed files with 11 additions and 0 deletions

View file

@ -15,6 +15,7 @@ Additions
- Added SpriteBatchContext struct and extensions
- Added InputHandler.InvertPressBehavior
- Added ReverseInput, ReverseOutput and AndThen to Easings
- Added an Enum constructor to GenericInput
Improvements
- Allow comparing Keybind and Combination based on the amount of modifiers they have

View file

@ -60,6 +60,16 @@ namespace MLEM.Input {
/// <param name="button">The button to convert.</param>
public GenericInput(Buttons button) : this(InputType.Gamepad, (int) button) {}
/// <summary>
/// Creates a new generic input from the given <see cref="Enum"/> value.
/// If the value is a <see cref="MouseButton"/>, <see cref="Keys"/> or <see cref="Buttons"/>, the appropriate <see cref="Type"/> and value will be set. Otherwise, the <see cref="Type"/> will be set to <see cref="InputType.None"/>.
/// </summary>
/// <param name="value">The value to convert.</param>
public GenericInput(Enum value) {
this.Type = value is MouseButton ? InputType.Mouse : value is Keys ? InputType.Keyboard : value is Buttons ? InputType.Gamepad : InputType.None;
this.value = Convert.ToInt32(value);
}
private GenericInput(InputType type, int value) {
this.Type = type;
this.value = value;