diff options
| author | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-10-14 11:44:02 -0400 |
|---|---|---|
| committer | Jesse Plamondon-Willard <github@jplamondonw.com> | 2017-10-14 11:44:02 -0400 |
| commit | 79118316065a01322d8ea12a14589ec016794c32 (patch) | |
| tree | 7a26668a66ea0630a2b9367ac820fe7a6d99ac77 /src/StardewModdingAPI/Events | |
| parent | af1a2bde8219c5d4b8660b13702725626a4a5647 (diff) | |
| parent | 8aec1eff99858716afe7b8604b512181f78c214f (diff) | |
| download | SMAPI-79118316065a01322d8ea12a14589ec016794c32.tar.gz SMAPI-79118316065a01322d8ea12a14589ec016794c32.tar.bz2 SMAPI-79118316065a01322d8ea12a14589ec016794c32.zip | |
Merge branch 'develop' into stable
Diffstat (limited to 'src/StardewModdingAPI/Events')
36 files changed, 0 insertions, 1854 deletions
diff --git a/src/StardewModdingAPI/Events/ChangeType.cs b/src/StardewModdingAPI/Events/ChangeType.cs deleted file mode 100644 index 4b207f08..00000000 --- a/src/StardewModdingAPI/Events/ChangeType.cs +++ /dev/null @@ -1,15 +0,0 @@ -namespace StardewModdingAPI.Events -{ - /// <summary>Indicates how an inventory item changed.</summary> - public enum ChangeType - { - /// <summary>The entire stack was removed.</summary> - Removed, - - /// <summary>The entire stack was added.</summary> - Added, - - /// <summary>The stack size changed.</summary> - StackChange - } -}
\ No newline at end of file diff --git a/src/StardewModdingAPI/Events/ContentEvents.cs b/src/StardewModdingAPI/Events/ContentEvents.cs deleted file mode 100644 index 4b4e2ad0..00000000 --- a/src/StardewModdingAPI/Events/ContentEvents.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; -using StardewModdingAPI.Framework; - -namespace StardewModdingAPI.Events -{ - /// <summary>Events raised when the game loads content.</summary> - public static class ContentEvents - { - - /********* - ** Events - *********/ - /// <summary>Raised after the content language changes.</summary> - public static event EventHandler<EventArgsValueChanged<string>> AfterLocaleChanged; - - - /********* - ** Internal methods - *********/ - /// <summary>Raise an <see cref="AfterLocaleChanged"/> event.</summary> - /// <param name="monitor">Encapsulates monitoring and logging.</param> - /// <param name="oldLocale">The previous locale.</param> - /// <param name="newLocale">The current locale.</param> - internal static void InvokeAfterLocaleChanged(IMonitor monitor, string oldLocale, string newLocale) - { - monitor.SafelyRaiseGenericEvent($"{nameof(ContentEvents)}.{nameof(ContentEvents.AfterLocaleChanged)}", ContentEvents.AfterLocaleChanged?.GetInvocationList(), null, new EventArgsValueChanged<string>(oldLocale, newLocale)); - } - } -} diff --git a/src/StardewModdingAPI/Events/ControlEvents.cs b/src/StardewModdingAPI/Events/ControlEvents.cs deleted file mode 100644 index 80d0f547..00000000 --- a/src/StardewModdingAPI/Events/ControlEvents.cs +++ /dev/null @@ -1,112 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Input; -using StardewModdingAPI.Framework; - -namespace StardewModdingAPI.Events -{ - /// <summary>Events raised when the player uses a controller, keyboard, or mouse.</summary> - public static class ControlEvents - { - /********* - ** Events - *********/ - /// <summary>Raised when the <see cref="KeyboardState"/> changes. That happens when the player presses or releases a key.</summary> - public static event EventHandler<EventArgsKeyboardStateChanged> KeyboardChanged; - - /// <summary>Raised when the player presses a keyboard key.</summary> - public static event EventHandler<EventArgsKeyPressed> KeyPressed; - - /// <summary>Raised when the player releases a keyboard key.</summary> - public static event EventHandler<EventArgsKeyPressed> KeyReleased; - - /// <summary>Raised when the <see cref="MouseState"/> changes. That happens when the player moves the mouse, scrolls the mouse wheel, or presses/releases a button.</summary> - public static event EventHandler<EventArgsMouseStateChanged> MouseChanged; - - /// <summary>The player pressed a controller button. This event isn't raised for trigger buttons.</summary> - public static event EventHandler<EventArgsControllerButtonPressed> ControllerButtonPressed; - - /// <summary>The player released a controller button. This event isn't raised for trigger buttons.</summary> - public static event EventHandler<EventArgsControllerButtonReleased> ControllerButtonReleased; - - /// <summary>The player pressed a controller trigger button.</summary> - public static event EventHandler<EventArgsControllerTriggerPressed> ControllerTriggerPressed; - - /// <summary>The player released a controller trigger button.</summary> - public static event EventHandler<EventArgsControllerTriggerReleased> ControllerTriggerReleased; - - - /********* - ** Internal methods - *********/ - /// <summary>Raise a <see cref="KeyboardChanged"/> event.</summary> - /// <param name="monitor">Encapsulates monitoring and logging.</param> - /// <param name="priorState">The previous keyboard state.</param> - /// <param name="newState">The current keyboard state.</param> - internal static void InvokeKeyboardChanged(IMonitor monitor, KeyboardState priorState, KeyboardState newState) - { - monitor.SafelyRaiseGenericEvent($"{nameof(ControlEvents)}.{nameof(ControlEvents.KeyboardChanged)}", ControlEvents.KeyboardChanged?.GetInvocationList(), null, new EventArgsKeyboardStateChanged(priorState, newState)); - } - - /// <summary>Raise a <see cref="MouseChanged"/> event.</summary> - /// <param name="monitor">Encapsulates monitoring and logging.</param> - /// <param name="priorState">The previous mouse state.</param> - /// <param name="newState">The current mouse state.</param> - /// <param name="priorPosition">The previous mouse position on the screen adjusted for the zoom level.</param> - /// <param name="newPosition">The current mouse position on the screen adjusted for the zoom level.</param> - internal static void InvokeMouseChanged(IMonitor monitor, MouseState priorState, MouseState newState, Point priorPosition, Point newPosition) - { - monitor.SafelyRaiseGenericEvent($"{nameof(ControlEvents)}.{nameof(ControlEvents.MouseChanged)}", ControlEvents.MouseChanged?.GetInvocationList(), null, new EventArgsMouseStateChanged(priorState, newState, priorPosition, newPosition)); - } - - /// <summary>Raise a <see cref="KeyPressed"/> event.</summary> - /// <param name="monitor">Encapsulates monitoring and logging.</param> - /// <param name="key">The keyboard button that was pressed.</param> - internal static void InvokeKeyPressed(IMonitor monitor, Keys key) - { - monitor.SafelyRaiseGenericEvent($"{nameof(ControlEvents)}.{nameof(ControlEvents.KeyPressed)}", ControlEvents.KeyPressed?.GetInvocationList(), null, new EventArgsKeyPressed(key)); - } - - /// <summary>Raise a <see cref="KeyReleased"/> event.</summary> - /// <param name="monitor">Encapsulates monitoring and logging.</param> - /// <param name="key">The keyboard button that was released.</param> - internal static void InvokeKeyReleased(IMonitor monitor, Keys key) - { - monitor.SafelyRaiseGenericEvent($"{nameof(ControlEvents)}.{nameof(ControlEvents.KeyReleased)}", ControlEvents.KeyReleased?.GetInvocationList(), null, new EventArgsKeyPressed(key)); - } - - /// <summary>Raise a <see cref="ControllerButtonPressed"/> event.</summary> - /// <param name="monitor">Encapsulates monitoring and logging.</param> - /// <param name="button">The controller button that was pressed.</param> - internal static void InvokeButtonPressed(IMonitor monitor, Buttons button) - { - monitor.SafelyRaiseGenericEvent($"{nameof(ControlEvents)}.{nameof(ControlEvents.ControllerButtonPressed)}", ControlEvents.ControllerButtonPressed?.GetInvocationList(), null, new EventArgsControllerButtonPressed(PlayerIndex.One, button)); - } - - /// <summary>Raise a <see cref="ControllerButtonReleased"/> event.</summary> - /// <param name="monitor">Encapsulates monitoring and logging.</param> - /// <param name="button">The controller button that was released.</param> - internal static void InvokeButtonReleased(IMonitor monitor, Buttons button) - { - monitor.SafelyRaiseGenericEvent($"{nameof(ControlEvents)}.{nameof(ControlEvents.ControllerButtonReleased)}", ControlEvents.ControllerButtonReleased?.GetInvocationList(), null, new EventArgsControllerButtonReleased(PlayerIndex.One, button)); - } - - /// <summary>Raise a <see cref="ControllerTriggerPressed"/> event.</summary> - /// <param name="monitor">Encapsulates monitoring and logging.</param> - /// <param name="button">The trigger button that was pressed.</param> - /// <param name="value">The current trigger value.</param> - internal static void InvokeTriggerPressed(IMonitor monitor, Buttons button, float value) - { - monitor.SafelyRaiseGenericEvent($"{nameof(ControlEvents)}.{nameof(ControlEvents.ControllerTriggerPressed)}", ControlEvents.ControllerTriggerPressed?.GetInvocationList(), null, new EventArgsControllerTriggerPressed(PlayerIndex.One, button, value)); - } - - /// <summary>Raise a <see cref="ControllerTriggerReleased"/> event.</summary> - /// <param name="monitor">Encapsulates monitoring and logging.</param> - /// <param name="button">The trigger button that was pressed.</param> - /// <param name="value">The current trigger value.</param> - internal static void InvokeTriggerReleased(IMonitor monitor, Buttons button, float value) - { - monitor.SafelyRaiseGenericEvent($"{nameof(ControlEvents)}.{nameof(ControlEvents.ControllerTriggerReleased)}", ControlEvents.ControllerTriggerReleased?.GetInvocationList(), null, new EventArgsControllerTriggerReleased(PlayerIndex.One, button, value)); - } - } -} diff --git a/src/StardewModdingAPI/Events/EventArgsClickableMenuChanged.cs b/src/StardewModdingAPI/Events/EventArgsClickableMenuChanged.cs deleted file mode 100644 index 2a2aa163..00000000 --- a/src/StardewModdingAPI/Events/EventArgsClickableMenuChanged.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using StardewValley.Menus; - -namespace StardewModdingAPI.Events -{ - /// <summary>Event arguments for a <see cref="MenuEvents.MenuChanged"/> event.</summary> - public class EventArgsClickableMenuChanged : EventArgs - { - /********* - ** Accessors - *********/ - /// <summary>The previous menu.</summary> - public IClickableMenu NewMenu { get; } - - /// <summary>The current menu.</summary> - public IClickableMenu PriorMenu { get; } - - - /********* - ** Public methods - *********/ - /// <summary>Construct an instance.</summary> - /// <param name="priorMenu">The previous menu.</param> - /// <param name="newMenu">The current menu.</param> - public EventArgsClickableMenuChanged(IClickableMenu priorMenu, IClickableMenu newMenu) - { - this.NewMenu = newMenu; - this.PriorMenu = priorMenu; - } - } -} diff --git a/src/StardewModdingAPI/Events/EventArgsClickableMenuClosed.cs b/src/StardewModdingAPI/Events/EventArgsClickableMenuClosed.cs deleted file mode 100644 index 5e6585f0..00000000 --- a/src/StardewModdingAPI/Events/EventArgsClickableMenuClosed.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using StardewValley.Menus; - -namespace StardewModdingAPI.Events -{ - /// <summary>Event arguments for a <see cref="MenuEvents.MenuClosed"/> event.</summary> - public class EventArgsClickableMenuClosed : EventArgs - { - /********* - ** Accessors - *********/ - /// <summary>The menu that was closed.</summary> - public IClickableMenu PriorMenu { get; } - - - /********* - ** Accessors - *********/ - /// <summary>Construct an instance.</summary> - /// <param name="priorMenu">The menu that was closed.</param> - public EventArgsClickableMenuClosed(IClickableMenu priorMenu) - { - this.PriorMenu = priorMenu; - } - } -} diff --git a/src/StardewModdingAPI/Events/EventArgsCommand.cs b/src/StardewModdingAPI/Events/EventArgsCommand.cs deleted file mode 100644 index 35370139..00000000 --- a/src/StardewModdingAPI/Events/EventArgsCommand.cs +++ /dev/null @@ -1,28 +0,0 @@ -#if SMAPI_1_x -using System; - -namespace StardewModdingAPI.Events -{ - /// <summary>Event arguments for a <see cref="StardewModdingAPI.Command.CommandFired"/> event.</summary> - [Obsolete("Use " + nameof(IModHelper) + "." + nameof(IModHelper.ConsoleCommands))] - public class EventArgsCommand : EventArgs - { - /********* - ** Accessors - *********/ - /// <summary>The triggered command.</summary> - public Command Command { get; } - - - /********* - ** Public methods - *********/ - /// <summary>Construct an instance.</summary> - /// <param name="command">The triggered command.</param> - public EventArgsCommand(Command command) - { - this.Command = command; - } - } -} -#endif
\ No newline at end of file diff --git a/src/StardewModdingAPI/Events/EventArgsControllerButtonPressed.cs b/src/StardewModdingAPI/Events/EventArgsControllerButtonPressed.cs deleted file mode 100644 index 3243b80b..00000000 --- a/src/StardewModdingAPI/Events/EventArgsControllerButtonPressed.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Input; - -namespace StardewModdingAPI.Events -{ - /// <summary>Event arguments for a <see cref="ControlEvents.ControllerButtonPressed"/> event.</summary> - public class EventArgsControllerButtonPressed : EventArgs - { - /********* - ** Accessors - *********/ - /// <summary>The player who pressed the button.</summary> - public PlayerIndex PlayerIndex { get; } - - /// <summary>The controller button that was pressed.</summary> - public Buttons ButtonPressed { get; } - - - /********* - ** Public methods - *********/ - /// <summary>Construct an instance.</summary> - /// <param name="playerIndex">The player who pressed the button.</param> - /// <param name="button">The controller button that was pressed.</param> - public EventArgsControllerButtonPressed(PlayerIndex playerIndex, Buttons button) - { - this.PlayerIndex = playerIndex; - this.ButtonPressed = button; - } - } -} diff --git a/src/StardewModdingAPI/Events/EventArgsControllerButtonReleased.cs b/src/StardewModdingAPI/Events/EventArgsControllerButtonReleased.cs deleted file mode 100644 index e05a080b..00000000 --- a/src/StardewModdingAPI/Events/EventArgsControllerButtonReleased.cs +++ /dev/null @@ -1,32 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Input; - -namespace StardewModdingAPI.Events -{ - /// <summary>Event arguments for a <see cref="ControlEvents.ControllerButtonReleased"/> event.</summary> - public class EventArgsControllerButtonReleased : EventArgs - { - /********* - ** Accessors - *********/ - /// <summary>The player who pressed the button.</summary> - public PlayerIndex PlayerIndex { get; } - - /// <summary>The controller button that was pressed.</summary> - public Buttons ButtonReleased { get; } - - - /********* - ** Public methods - *********/ - /// <summary>Construct an instance.</summary> - /// <param name="playerIndex">The player who pressed the button.</param> - /// <param name="button">The controller button that was released.</param> - public EventArgsControllerButtonReleased(PlayerIndex playerIndex, Buttons button) - { - this.PlayerIndex = playerIndex; - this.ButtonReleased = button; - } - } -} diff --git a/src/StardewModdingAPI/Events/EventArgsControllerTriggerPressed.cs b/src/StardewModdingAPI/Events/EventArgsControllerTriggerPressed.cs deleted file mode 100644 index a2087733..00000000 --- a/src/StardewModdingAPI/Events/EventArgsControllerTriggerPressed.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Input; - -namespace StardewModdingAPI.Events -{ - /// <summary>Event arguments for a <see cref="ControlEvents.ControllerTriggerPressed"/> event.</summary> - public class EventArgsControllerTriggerPressed : EventArgs - { - /********* - ** Accessors - *********/ - /// <summary>The player who pressed the button.</summary> - public PlayerIndex PlayerIndex { get; } - - /// <summary>The controller button that was pressed.</summary> - public Buttons ButtonPressed { get; } - - /// <summary>The current trigger value.</summary> - public float Value { get; } - - - /********* - ** Public methods - *********/ - /// <summary>Construct an instance.</summary> - /// <param name="playerIndex">The player who pressed the trigger button.</param> - /// <param name="button">The trigger button that was pressed.</param> - /// <param name="value">The current trigger value.</param> - public EventArgsControllerTriggerPressed(PlayerIndex playerIndex, Buttons button, float value) - { - this.PlayerIndex = playerIndex; - this.ButtonPressed = button; - this.Value = value; - } - } -} diff --git a/src/StardewModdingAPI/Events/EventArgsControllerTriggerReleased.cs b/src/StardewModdingAPI/Events/EventArgsControllerTriggerReleased.cs deleted file mode 100644 index d2eecbec..00000000 --- a/src/StardewModdingAPI/Events/EventArgsControllerTriggerReleased.cs +++ /dev/null @@ -1,37 +0,0 @@ -using System; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Input; - -namespace StardewModdingAPI.Events -{ - /// <summary>Event arguments for a <see cref="ControlEvents.ControllerTriggerReleased"/> event.</summary> - public class EventArgsControllerTriggerReleased : EventArgs - { - /********* - ** Accessors - *********/ - /// <summary>The player who pressed the button.</summary> - public PlayerIndex PlayerIndex { get; } - - /// <summary>The controller button that was released.</summary> - public Buttons ButtonReleased { get; } - - /// <summary>The current trigger value.</summary> - public float Value { get; } - - - /********* - ** Public methods - *********/ - /// <summary>Construct an instance.</summary> - /// <param name="playerIndex">The player who pressed the trigger button.</param> - /// <param name="button">The trigger button that was released.</param> - /// <param name="value">The current trigger value.</param> - public EventArgsControllerTriggerReleased(PlayerIndex playerIndex, Buttons button, float value) - { - this.PlayerIndex = playerIndex; - this.ButtonReleased = button; - this.Value = value; - } - } -} diff --git a/src/StardewModdingAPI/Events/EventArgsCurrentLocationChanged.cs b/src/StardewModdingAPI/Events/EventArgsCurrentLocationChanged.cs deleted file mode 100644 index 25d3ebf3..00000000 --- a/src/StardewModdingAPI/Events/EventArgsCurrentLocationChanged.cs +++ /dev/null @@ -1,31 +0,0 @@ -using System; -using StardewValley; - -namespace StardewModdingAPI.Events -{ - /// <summary>Event arguments for a <see cref="LocationEvents.CurrentLocationChanged"/> event.</summary> - public class EventArgsCurrentLocationChanged : EventArgs - { - /********* - ** Accessors - *********/ - /// <summary>The player's current location.</summary> - public GameLocation NewLocation { get; } - - /// <summary>The player's previous location.</summary> - public GameLocation PriorLocation { get; } - - - /********* - ** Public methods - *********/ - /// <summary>Construct an instance.</summary> - /// <param name="priorLocation">The player's previous location.</param> - /// <param name="newLocation">The player's current location.</param> - public EventArgsCurrentLocationChanged(GameLocation priorLocation, GameLocation newLocation) - { - this.NewLocation = newLocation; - this.PriorLocation = priorLocation; - } - } -} diff --git a/src/StardewModdingAPI/Events/EventArgsFarmerChanged.cs b/src/StardewModdingAPI/Events/EventArgsFarmerChanged.cs deleted file mode 100644 index 4c359939..00000000 --- a/src/StardewModdingAPI/Events/EventArgsFarmerChanged.cs +++ /dev/null @@ -1,33 +0,0 @@ -#if SMAPI_1_x -using System; -using SFarmer = StardewValley.Farmer; - -namespace StardewModdingAPI.Events -{ - /// <summary>Event arguments for a <see cref="PlayerEvents.FarmerChanged"/> event.</summary> - public class EventArgsFarmerChanged : EventArgs - { - /********* - ** Accessors - *********/ - /// <summary>The previous player character.</summary> - public SFarmer NewFarmer { get; } - - /// <summary>The new player character.</summary> - public SFarmer PriorFarmer { get; } - - - /********* - ** Public methods - *********/ - /// <summary>Construct an instance.</summary> - /// <param name="priorFarmer">The previous player character.</param> - /// <param name="newFarmer">The new player character.</param> - public EventArgsFarmerChanged(SFarmer priorFarmer, SFarmer newFarmer) - { - this.PriorFarmer = priorFarmer; - this.NewFarmer = newFarmer; - } - } -} -#endif
\ No newline at end of file diff --git a/src/StardewModdingAPI/Events/EventArgsGameLocationsChanged.cs b/src/StardewModdingAPI/Events/EventArgsGameLocationsChanged.cs deleted file mode 100644 index fb8c821e..00000000 --- a/src/StardewModdingAPI/Events/EventArgsGameLocationsChanged.cs +++ /dev/null @@ -1,27 +0,0 @@ -using System; -using System.Collections.Generic; -using StardewValley; - -namespace StardewModdingAPI.Events -{ - /// <summary>Event arguments for a <see cref="LocationEvents.LocationsChanged"/> event.</summary> - public class EventArgsGameLocationsChanged : EventArgs - { - /********* - ** Accessors - *********/ - /// <summary>The current list of game locations.</summary> - public List<GameLocation> NewLocations { get; } - - - /********* - ** Public methods - *********/ - /// <summary>Construct an instance.</summary> - /// <param name="newLocations">The current list of game locations.</param> - public EventArgsGameLocationsChanged(List<GameLocation> newLocations) - { - this.NewLocations = newLocations; - } - } -} diff --git a/src/StardewModdingAPI/Events/EventArgsInput.cs b/src/StardewModdingAPI/Events/EventArgsInput.cs deleted file mode 100644 index 31368555..00000000 --- a/src/StardewModdingAPI/Events/EventArgsInput.cs +++ /dev/null @@ -1,126 +0,0 @@ -#if !SMAPI_1_x -using System; -using System.Linq; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Input; -using StardewModdingAPI.Utilities; -using StardewValley; - -namespace StardewModdingAPI.Events -{ - /// <summary>Event arguments when a button is pressed or released.</summary> - public class EventArgsInput : EventArgs - { - /********* - ** 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; set; } - - /// <summary>Whether the input is considered a 'click' by the game for enabling action.</summary> - public bool IsClick { 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="isClick">Whether the input is considered a 'click' by the game for enabling action.</param> - public EventArgsInput(SButton button, ICursorPosition cursor, bool isClick) - { - this.Button = button; - this.Cursor = cursor; - this.IsClick = isClick; - } - - /// <summary>Prevent the game from handling the vurrent 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) - { - // keyboard - if (this.Button.TryGetKeyboard(out Keys key)) - Game1.oldKBState = new KeyboardState(Game1.oldKBState.GetPressedKeys().Except(new[] { key }).ToArray()); - - // controller - else if (this.Bu |
