1
0
Fork 0
mirror of https://github.com/Ellpeck/MLEM.git synced 2024-12-24 17:29:23 +01:00

added generic input equality checking

This commit is contained in:
Ell 2021-06-20 23:17:39 +02:00
parent 60c9236cbd
commit 2118837062
2 changed files with 37 additions and 1 deletions

View file

@ -39,6 +39,36 @@ namespace MLEM.Input {
}
}
/// <inheritdoc />
public override bool Equals(object obj) {
return obj is GenericInput o && this.Type == o.Type && this.value == o.value;
}
/// <inheritdoc />
public override int GetHashCode() {
return ((int) this.Type * 397) ^ this.value;
}
/// <summary>
/// Compares the two generic input instances for equality using <see cref="Equals"/>
/// </summary>
/// <param name="left">The left input</param>
/// <param name="right">The right input</param>
/// <returns>Whether the two generic inputs are equal</returns>
public static bool operator ==(GenericInput left, GenericInput right) {
return left.Equals(right);
}
/// <summary>
/// Compares the two generic input instances for inequality using <see cref="Equals"/>
/// </summary>
/// <param name="left">The left input</param>
/// <param name="right">The right input</param>
/// <returns>Whether the two generic inputs are not equal</returns>
public static bool operator !=(GenericInput left, GenericInput right) {
return !left.Equals(right);
}
/// <summary>
/// Converts a <see cref="Keys"/> to a generic input.
/// </summary>

View file

@ -101,7 +101,13 @@ namespace MLEM.Input {
[DataMember]
public readonly GenericInput Key;
internal Combination(GenericInput key, GenericInput[] modifiers) {
/// <summary>
/// Creates a new combination with the given settings.
/// To add a combination to a <see cref="Keybind"/>, use <see cref="Keybind.Add(MLEM.Input.GenericInput,MLEM.Input.GenericInput[])"/> instead.
/// </summary>
/// <param name="key">The key</param>
/// <param name="modifiers">The modifiers</param>
public Combination(GenericInput key, GenericInput[] modifiers) {
this.Modifiers = modifiers;
this.Key = key;
}