using System; using System.Collections.Generic; namespace StardewModdingAPI.Events { /// Event arguments when a button is pressed or released. public class EventArgsInput : 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 the input should trigger actions on the affected tile. public bool IsActionButton => this.Button.IsActionButton(); /// Whether the input should use tools on the affected tile. public bool IsUseToolButton => this.Button.IsUseToolButton(); /// 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 EventArgsInput(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); } } }