From 63fb4dbe8ae4d611c4854f863b9b29265e02fdee Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 5 Oct 2018 21:59:57 -0400 Subject: tweak new event naming convention (#310) --- src/SMAPI/Events/ButtonReleasedEventArgs.cs | 60 +++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 src/SMAPI/Events/ButtonReleasedEventArgs.cs (limited to 'src/SMAPI/Events/ButtonReleasedEventArgs.cs') diff --git a/src/SMAPI/Events/ButtonReleasedEventArgs.cs b/src/SMAPI/Events/ButtonReleasedEventArgs.cs new file mode 100644 index 00000000..2a289bc7 --- /dev/null +++ b/src/SMAPI/Events/ButtonReleasedEventArgs.cs @@ -0,0 +1,60 @@ +using System; +using StardewModdingAPI.Framework.Input; + +namespace StardewModdingAPI.Events +{ + /// Event arguments when a button is released. + public class ButtonReleasedEventArgs : EventArgs + { + /********* + ** Properties + *********/ + /// The game's current input state. + private readonly SInputState InputState; + + + /********* + ** Accessors + *********/ + /// The button on the controller, keyboard, or mouse. + public SButton Button { get; } + + /// The current cursor position. + public ICursorPosition Cursor { get; } + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The button on the controller, keyboard, or mouse. + /// The cursor position. + /// The game's current input state. + internal ButtonReleasedEventArgs(SButton button, ICursorPosition cursor, SInputState inputState) + { + this.Button = button; + this.Cursor = cursor; + this.InputState = inputState; + } + + /// Whether a mod has indicated the key was already handled, so the game should handle it. + public bool IsSuppressed() + { + return this.IsSuppressed(this.Button); + } + + /// Whether a mod has indicated the key was already handled, so the game should handle it. + /// The button to check. + public bool IsSuppressed(SButton button) + { + return this.InputState.SuppressButtons.Contains(button); + } + + /// Get whether a given button was pressed or held. + /// The button to check. + public bool IsDown(SButton button) + { + return this.InputState.IsDown(button); + } + } +} -- cgit