diff options
author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-10-22 15:09:36 -0400 |
---|---|---|
committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-10-22 15:09:36 -0400 |
commit | ed56cb714d7fb76f3c1b9d2f2e7b7627f8accc70 (patch) | |
tree | fbdfa324a8734c3926597a146aa029b8bbd335a7 /src/SMAPI/Events | |
parent | 99c8dd79406f5099194d72e26085a49939705259 (diff) | |
download | SMAPI-ed56cb714d7fb76f3c1b9d2f2e7b7627f8accc70.tar.gz SMAPI-ed56cb714d7fb76f3c1b9d2f2e7b7627f8accc70.tar.bz2 SMAPI-ed56cb714d7fb76f3c1b9d2f2e7b7627f8accc70.zip |
replace input events' e.IsClick with better-designed e.IsActionButton and e.IsUseToolButton
Diffstat (limited to 'src/SMAPI/Events')
-rw-r--r-- | src/SMAPI/Events/EventArgsInput.cs | 18 | ||||
-rw-r--r-- | src/SMAPI/Events/InputEvents.cs | 15 |
2 files changed, 21 insertions, 12 deletions
diff --git a/src/SMAPI/Events/EventArgsInput.cs b/src/SMAPI/Events/EventArgsInput.cs index 617dac35..ff904675 100644 --- a/src/SMAPI/Events/EventArgsInput.cs +++ b/src/SMAPI/Events/EventArgsInput.cs @@ -2,7 +2,6 @@ using System; using System.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Input; -using StardewModdingAPI.Utilities; using StardewValley; namespace StardewModdingAPI.Events @@ -20,7 +19,14 @@ namespace StardewModdingAPI.Events public ICursorPosition Cursor { get; set; } /// <summary>Whether the input is considered a 'click' by the game for enabling action.</summary> - public bool IsClick { get; } + [Obsolete("Use " + nameof(EventArgsInput.IsActionButton) + " or " + nameof(EventArgsInput.IsUseToolButton) + " instead")] // deprecated in SMAPI 2.1 + public bool IsClick => this.IsActionButton; + + /// <summary>Whether the input should trigger actions on the affected tile.</summary> + public bool IsActionButton { get; } + + /// <summary>Whether the input should use tools on the affected tile.</summary> + public bool IsUseToolButton { get; } /********* @@ -29,12 +35,14 @@ namespace StardewModdingAPI.Events /// <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="isClick">Whether the input is considered a 'click' by the game for enabling action.</param> - public EventArgsInput(SButton button, ICursorPosition cursor, bool isClick) + /// <param name="isActionButton">Whether the input should trigger actions on the affected tile.</param> + /// <param name="isUseToolButton">Whether the input should use tools on the affected tile.</param> + public EventArgsInput(SButton button, ICursorPosition cursor, bool isActionButton, bool isUseToolButton) { this.Button = button; this.Cursor = cursor; - this.IsClick = isClick; + this.IsActionButton = isActionButton; + this.IsUseToolButton = isUseToolButton; } /// <summary>Prevent the game from handling the vurrent button press. This doesn't prevent other mods from receiving the event.</summary> diff --git a/src/SMAPI/Events/InputEvents.cs b/src/SMAPI/Events/InputEvents.cs index c31eb698..985aed99 100644 --- a/src/SMAPI/Events/InputEvents.cs +++ b/src/SMAPI/Events/InputEvents.cs @@ -1,6 +1,5 @@ using System; using StardewModdingAPI.Framework; -using StardewModdingAPI.Utilities; namespace StardewModdingAPI.Events { @@ -24,20 +23,22 @@ namespace StardewModdingAPI.Events /// <param name="monitor">Encapsulates monitoring and logging.</param> /// <param name="button">The button on the controller, keyboard, or mouse.</param> /// <param name="cursor">The cursor position.</param> - /// <param name="isClick">Whether the input is considered a 'click' by the game for enabling action.</param> - internal static void InvokeButtonPressed(IMonitor monitor, SButton button, ICursorPosition cursor, bool isClick) + /// <param name="isActionButton">Whether the input should trigger actions on the affected tile.</param> + /// <param name="isUseToolButton">Whether the input should use tools on the affected tile.</param> + internal static void InvokeButtonPressed(IMonitor monitor, SButton button, ICursorPosition cursor, bool isActionButton, bool isUseToolButton) { - monitor.SafelyRaiseGenericEvent($"{nameof(InputEvents)}.{nameof(InputEvents.ButtonPressed)}", InputEvents.ButtonPressed?.GetInvocationList(), null, new EventArgsInput(button, cursor, isClick)); + monitor.SafelyRaiseGenericEvent($"{nameof(InputEvents)}.{nameof(InputEvents.ButtonPressed)}", InputEvents.ButtonPressed?.GetInvocationList(), null, new EventArgsInput(button, cursor, isActionButton, isUseToolButton)); } /// <summary>Raise a <see cref="ButtonReleased"/> event.</summary> /// <param name="monitor">Encapsulates monitoring and logging.</param> /// <param name="button">The button on the controller, keyboard, or mouse.</param> /// <param name="cursor">The cursor position.</param> - /// <param name="isClick">Whether the input is considered a 'click' by the game for enabling action.</param> - internal static void InvokeButtonReleased(IMonitor monitor, SButton button, ICursorPosition cursor, bool isClick) + /// <param name="isActionButton">Whether the input should trigger actions on the affected tile.</param> + /// <param name="isUseToolButton">Whether the input should use tools on the affected tile.</param> + internal static void InvokeButtonReleased(IMonitor monitor, SButton button, ICursorPosition cursor, bool isActionButton, bool isUseToolButton) { - monitor.SafelyRaiseGenericEvent($"{nameof(InputEvents)}.{nameof(InputEvents.ButtonReleased)}", InputEvents.ButtonReleased?.GetInvocationList(), null, new EventArgsInput(button, cursor, isClick)); + monitor.SafelyRaiseGenericEvent($"{nameof(InputEvents)}.{nameof(InputEvents.ButtonReleased)}", InputEvents.ButtonReleased?.GetInvocationList(), null, new EventArgsInput(button, cursor, isActionButton, isUseToolButton)); } } } |