summaryrefslogtreecommitdiff
path: root/src/SMAPI/Events/InputButtonPressedEventArgs.cs
diff options
context:
space:
mode:
authorJesse Plamondon-Willard <github@jplamondonw.com>2018-06-02 01:48:35 -0400
committerJesse Plamondon-Willard <github@jplamondonw.com>2018-06-02 01:48:35 -0400
commit0df7a967a6980db7f4da8d393feae97c968e3375 (patch)
treeb8dcd1332fe3413fac26dc297a08d16f2300b804 /src/SMAPI/Events/InputButtonPressedEventArgs.cs
parent97a2bdfdd443b3d5b79f48eb1d718ebf255f5e0f (diff)
downloadSMAPI-0df7a967a6980db7f4da8d393feae97c968e3375.tar.gz
SMAPI-0df7a967a6980db7f4da8d393feae97c968e3375.tar.bz2
SMAPI-0df7a967a6980db7f4da8d393feae97c968e3375.zip
add new-style input events (#310)
Diffstat (limited to 'src/SMAPI/Events/InputButtonPressedEventArgs.cs')
-rw-r--r--src/SMAPI/Events/InputButtonPressedEventArgs.cs56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/SMAPI/Events/InputButtonPressedEventArgs.cs b/src/SMAPI/Events/InputButtonPressedEventArgs.cs
new file mode 100644
index 00000000..c8d55cd4
--- /dev/null
+++ b/src/SMAPI/Events/InputButtonPressedEventArgs.cs
@@ -0,0 +1,56 @@
+using System;
+using System.Collections.Generic;
+
+namespace StardewModdingAPI.Events
+{
+ /// <summary>Event arguments when a button is pressed.</summary>
+ public class InputButtonPressedArgsInput : EventArgs
+ {
+ /*********
+ ** Properties
+ *********/
+ /// <summary>The buttons to suppress.</summary>
+ private readonly HashSet<SButton> SuppressButtons;
+
+
+ /*********
+ ** 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; }
+
+ /// <summary>Whether a mod has indicated the key was already handled.</summary>
+ public bool IsSuppressed => this.SuppressButtons.Contains(this.Button);
+
+
+ /*********
+ ** 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="suppressButtons">The buttons to suppress.</param>
+ public InputButtonPressedArgsInput(SButton button, ICursorPosition cursor, HashSet<SButton> suppressButtons)
+ {
+ this.Button = button;
+ this.Cursor = cursor;
+ this.SuppressButtons = suppressButtons;
+ }
+
+ /// <summary>Prevent the game from handling the current button press. This doesn't prevent other mods from receiving the event.</summary>
+ public void SuppressButton()
+ {
+ this.SuppressButton(this.Button);
+ }
+
+ /// <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>
+ public void SuppressButton(SButton button)
+ {
+ this.SuppressButtons.Add(button);
+ }
+ }
+}