diff options
-rw-r--r-- | docs/release-notes.md | 1 | ||||
-rw-r--r-- | src/SMAPI/Framework/Input/SInputState.cs | 7 | ||||
-rw-r--r-- | src/SMAPI/Framework/ModHelpers/InputHelper.cs | 7 | ||||
-rw-r--r-- | src/SMAPI/IInputHelper.cs | 4 | ||||
-rw-r--r-- | src/SMAPI/InputStatus.cs (renamed from src/SMAPI/Framework/Input/InputStatus.cs) | 4 |
5 files changed, 21 insertions, 2 deletions
diff --git a/docs/release-notes.md b/docs/release-notes.md index 78b0d132..4b7c359a 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -7,6 +7,7 @@ * For modders: * Added support for self-broadcasts through the multiplayer API. (Mods can now send messages to the current machine. That enables simple integrations between mods without needing an API, and lets mods notify a host mod without needing different code depending on whether the current player is the host or a farmhand.) + * Added `helper.Input.GetStatus` method to get the low-level status of a button. * Eliminated unneeded network messages when broadcasting to a peer who can't handle the message (e.g. because they don't have SMAPI or don't have the target mod). * For the web UI: diff --git a/src/SMAPI/Framework/Input/SInputState.cs b/src/SMAPI/Framework/Input/SInputState.cs index 84cea36c..f54d3124 100644 --- a/src/SMAPI/Framework/Input/SInputState.cs +++ b/src/SMAPI/Framework/Input/SInputState.cs @@ -169,6 +169,13 @@ namespace StardewModdingAPI.Framework.Input return buttons.Any(button => this.IsDown(button.ToSButton())); } + /// <summary>Get the status of a button.</summary> + /// <param name="button">The button to check.</param> + public InputStatus GetStatus(SButton button) + { + return this.GetStatus(this.ActiveButtons, button); + } + /********* ** Private methods diff --git a/src/SMAPI/Framework/ModHelpers/InputHelper.cs b/src/SMAPI/Framework/ModHelpers/InputHelper.cs index f4cd12b6..5858cddd 100644 --- a/src/SMAPI/Framework/ModHelpers/InputHelper.cs +++ b/src/SMAPI/Framework/ModHelpers/InputHelper.cs @@ -50,5 +50,12 @@ namespace StardewModdingAPI.Framework.ModHelpers { this.InputState.SuppressButtons.Add(button); } + + /// <summary>Get the status of a button.</summary> + /// <param name="button">The button to check.</param> + public InputStatus GetStatus(SButton button) + { + return this.InputState.GetStatus(button); + } } } diff --git a/src/SMAPI/IInputHelper.cs b/src/SMAPI/IInputHelper.cs index 328f504b..ba26773d 100644 --- a/src/SMAPI/IInputHelper.cs +++ b/src/SMAPI/IInputHelper.cs @@ -17,5 +17,9 @@ namespace StardewModdingAPI /// <summary>Prevent the game from handling a button press. This doesn't prevent other mods from receiving the event.</summary> /// <param name="button">The button to suppress.</param> void Suppress(SButton button); + + /// <summary>Get the status of a button.</summary> + /// <param name="button">The button to check.</param> + InputStatus GetStatus(SButton button); } } diff --git a/src/SMAPI/Framework/Input/InputStatus.cs b/src/SMAPI/InputStatus.cs index 99b0006c..d9cdd6b2 100644 --- a/src/SMAPI/Framework/Input/InputStatus.cs +++ b/src/SMAPI/InputStatus.cs @@ -1,7 +1,7 @@ -namespace StardewModdingAPI.Framework.Input +namespace StardewModdingAPI { /// <summary>The input status for a button during an update frame.</summary> - internal enum InputStatus + public enum InputStatus { /// <summary>The button was neither pressed, held, nor released.</summary> None, |