diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-10-05 21:59:57 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2018-10-05 21:59:57 -0400 |
commit | 63fb4dbe8ae4d611c4854f863b9b29265e02fdee (patch) | |
tree | ceebeaa5739b04112f6efdc8fceabd17f8b6797c /src/SMAPI/Events/ButtonReleasedEventArgs.cs | |
parent | 0530824cc2c573cae0a80f7def2b46bf8aeb9af9 (diff) | |
download | SMAPI-63fb4dbe8ae4d611c4854f863b9b29265e02fdee.tar.gz SMAPI-63fb4dbe8ae4d611c4854f863b9b29265e02fdee.tar.bz2 SMAPI-63fb4dbe8ae4d611c4854f863b9b29265e02fdee.zip |
tweak new event naming convention (#310)
Diffstat (limited to 'src/SMAPI/Events/ButtonReleasedEventArgs.cs')
-rw-r--r-- | src/SMAPI/Events/ButtonReleasedEventArgs.cs | 60 |
1 files changed, 60 insertions, 0 deletions
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 +{ + /// <summary>Event arguments when a button is released.</summary> + public class ButtonReleasedEventArgs : EventArgs + { + /********* + ** Properties + *********/ + /// <summary>The game's current input state.</summary> + private readonly SInputState InputState; + + + /********* + ** Accessors + *********/ + /// <summary>The button on the controller, keyboard, or mouse.</summary> + public SButton Button { get; } + + /// <summary>The current cursor position.</summary> + public ICursorPosition Cursor { get; } + + + /********* + ** Public methods + *********/ + /// <summary>Construct an instance.</summary> + /// <param name="button">The button on the controller, keyboard, or mouse.</param> + /// <param name="cursor">The cursor position.</param> + /// <param name="inputState">The game's current input state.</param> + internal ButtonReleasedEventArgs(SButton button, ICursorPosition cursor, SInputState inputState) + { + this.Button = button; + this.Cursor = cursor; + this.InputState = inputState; + } + + /// <summary>Whether a mod has indicated the key was already handled, so the game should handle it.</summary> + public bool IsSuppressed() + { + return this.IsSuppressed(this.Button); + } + + /// <summary>Whether a mod has indicated the key was already handled, so the game should handle it.</summary> + /// <param name="button">The button to check.</param> + public bool IsSuppressed(SButton button) + { + return this.InputState.SuppressButtons.Contains(button); + } + + /// <summary>Get whether a given button was pressed or held.</summary> + /// <param name="button">The button to check.</param> + public bool IsDown(SButton button) + { + return this.InputState.IsDown(button); + } + } +} |