using System; using System.Collections.Generic; namespace StardewModdingAPI.Events { /// Event arguments when a button is pressed. public class InputButtonPressedArgsInput : EventArgs { /********* ** Properties *********/ /// The buttons to suppress. private readonly HashSet SuppressButtons; /********* ** Accessors *********/ /// The button on the controller, keyboard, or mouse. public SButton Button { get; } /// The current cursor position. public ICursorPosition Cursor { get; } /// Whether a mod has indicated the key was already handled. public bool IsSuppressed => this.SuppressButtons.Contains(this.Button); /********* ** Public methods *********/ /// Construct an instance. /// The button on the controller, keyboard, or mouse. /// The cursor position. /// The buttons to suppress. public InputButtonPressedArgsInput(SButton button, ICursorPosition cursor, HashSet suppressButtons) { this.Button = button; this.Cursor = cursor; this.SuppressButtons = suppressButtons; } /// Prevent the game from handling the current button press. This doesn't prevent other mods from receiving the event. public void SuppressButton() { this.SuppressButton(this.Button); } /// Prevent the game from handling a button press. This doesn't prevent other mods from receiving the event. /// The button to suppress. public void SuppressButton(SButton button) { this.SuppressButtons.Add(button); } } }