summaryrefslogtreecommitdiff
path: root/src/SMAPI/Events/InputButtonReleasedEventArgs.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2018-08-01 11:07:29 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2018-08-01 11:07:29 -0400
commit60b41195778af33fd609eab66d9ae3f1d1165e8f (patch)
tree7128b906d40e94c56c34ed6058f27bc31c31a08b /src/SMAPI/Events/InputButtonReleasedEventArgs.cs
parentb9bc1a6d17cafa0a97b46ffecda432cfc2f23b51 (diff)
parent52cf953f685c65b2b6814e375ec9a5ffa03c440a (diff)
downloadSMAPI-60b41195778af33fd609eab66d9ae3f1d1165e8f.tar.gz
SMAPI-60b41195778af33fd609eab66d9ae3f1d1165e8f.tar.bz2
SMAPI-60b41195778af33fd609eab66d9ae3f1d1165e8f.zip
Merge branch 'develop' into stable
Diffstat (limited to 'src/SMAPI/Events/InputButtonReleasedEventArgs.cs')
-rw-r--r--src/SMAPI/Events/InputButtonReleasedEventArgs.cs60
1 files changed, 60 insertions, 0 deletions
diff --git a/src/SMAPI/Events/InputButtonReleasedEventArgs.cs b/src/SMAPI/Events/InputButtonReleasedEventArgs.cs
new file mode 100644
index 00000000..4b0bc326
--- /dev/null
+++ b/src/SMAPI/Events/InputButtonReleasedEventArgs.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 InputButtonReleasedEventArgs : 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 InputButtonReleasedEventArgs(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);
+ }
+ }
+}