diff --git a/CHANGELOG.md b/CHANGELOG.md index d80b22b..68abe64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,6 +34,7 @@ Fixes - Fixed TokenizedString handling trailing spaces incorrectly in the last line of non-left aligned text - Fixed some TokenizedString tokens starting with a line break not being split correctly - Fixed InputHandler maintaining old input states when input types are toggled off +- Fixed Combination.IsModifierDown querying one of its modifiers instead of all of them Removals - Marked EnumHelper as obsolete due to its reimplementation in [DynamicEnums](https://www.nuget.org/packages/DynamicEnums) diff --git a/MLEM/Input/Keybind.cs b/MLEM/Input/Keybind.cs index 4b5f91e..7ee8ef6 100644 --- a/MLEM/Input/Keybind.cs +++ b/MLEM/Input/Keybind.cs @@ -406,35 +406,31 @@ namespace MLEM.Input { } /// - /// Returns whether this combination's modifier keys are currently down + /// Returns whether all of this combination's modifier keys are currently down. /// /// The input handler to query the keys with /// The index of the gamepad to query, or -1 to query all gamepads /// Whether this combination's modifiers are down public bool IsModifierDown(InputHandler handler, int gamepadIndex = -1) { - if (this.Modifiers.Length <= 0) - return true; foreach (var modifier in this.Modifiers) { - if (handler.IsDown(modifier, gamepadIndex)) - return true; + if (!handler.IsDown(modifier, gamepadIndex)) + return false; } - return false; + return true; } /// - /// Returns whether this combination's modifier keys were down in the last update call. + /// Returns whether all of this combination's modifier keys were down in the last update call. /// /// The input handler to query the keys with /// The index of the gamepad to query, or -1 to query all gamepads /// Whether this combination's modifiers were down public bool WasModifierDown(InputHandler handler, int gamepadIndex = -1) { - if (this.Modifiers.Length <= 0) - return true; foreach (var modifier in this.Modifiers) { - if (handler.WasDown(modifier, gamepadIndex)) - return true; + if (!handler.WasDown(modifier, gamepadIndex)) + return false; } - return false; + return true; } ///