From 873abef23563f5273e9b66d7b7e3cc2f5e4e0e92 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 23 Sep 2017 19:15:07 -0400 Subject: add mod update checks based on manifest fields (#336) --- src/StardewModdingAPI/Events/GameEvents.cs | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'src/StardewModdingAPI/Events') diff --git a/src/StardewModdingAPI/Events/GameEvents.cs b/src/StardewModdingAPI/Events/GameEvents.cs index 5610e67a..deb71a86 100644 --- a/src/StardewModdingAPI/Events/GameEvents.cs +++ b/src/StardewModdingAPI/Events/GameEvents.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Diagnostics.CodeAnalysis; using StardewModdingAPI.Framework; @@ -39,9 +39,6 @@ namespace StardewModdingAPI.Events /// Raised during launch after configuring XNA or MonoGame. The game window hasn't been opened by this point. Called after . internal static event EventHandler InitializeInternal; - /// Raised during launch after configuring Stardew Valley, loading it into memory, and opening the game window. The window is still blank by this point. - internal static event EventHandler GameLoadedInternal; - #if SMAPI_1_x /// Raised during launch after configuring XNA or MonoGame. The game window hasn't been opened by this point. Called after . [Obsolete("The " + nameof(Mod) + "." + nameof(Mod.Entry) + " method is now called after the " + nameof(GameEvents.Initialize) + " event, so any contained logic can be done directly in " + nameof(Mod.Entry) + ".")] @@ -143,19 +140,14 @@ namespace StardewModdingAPI.Events { monitor.SafelyRaisePlainEvent($"{nameof(GameEvents)}.{nameof(GameEvents.LoadContent)}", GameEvents._LoadContent?.GetInvocationList()); } -#endif /// Raise a event. /// Encapsulates monitoring and logging. internal static void InvokeGameLoaded(IMonitor monitor) { - monitor.SafelyRaisePlainEvent($"{nameof(GameEvents)}.{nameof(GameEvents.GameLoadedInternal)}", GameEvents.GameLoadedInternal?.GetInvocationList()); -#if SMAPI_1_x monitor.SafelyRaisePlainEvent($"{nameof(GameEvents)}.{nameof(GameEvents.GameLoaded)}", GameEvents._GameLoaded?.GetInvocationList()); -#endif } -#if SMAPI_1_x /// Raise a event. /// Encapsulates monitoring and logging. internal static void InvokeFirstUpdateTick(IMonitor monitor) -- cgit From 2d36105c33ffba77eb979ef6ef0d2e7d906b09bc Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 23 Sep 2017 20:53:12 -0400 Subject: drop support for SMAPI 1.x (#360) --- src/StardewModdingAPI/Events/EventArgsCommand.cs | 28 ----- .../Events/EventArgsFarmerChanged.cs | 33 ------ src/StardewModdingAPI/Events/EventArgsInput.cs | 2 - .../Events/EventArgsLoadedGameChanged.cs | 27 ----- src/StardewModdingAPI/Events/EventArgsNewDay.cs | 37 ------ .../Events/EventArgsStringChanged.cs | 31 ----- src/StardewModdingAPI/Events/GameEvents.cs | 112 ------------------ src/StardewModdingAPI/Events/InputEvents.cs | 2 - src/StardewModdingAPI/Events/PlayerEvents.cs | 74 +----------- src/StardewModdingAPI/Events/TimeEvents.cs | 128 +-------------------- 10 files changed, 2 insertions(+), 472 deletions(-) delete mode 100644 src/StardewModdingAPI/Events/EventArgsCommand.cs delete mode 100644 src/StardewModdingAPI/Events/EventArgsFarmerChanged.cs delete mode 100644 src/StardewModdingAPI/Events/EventArgsLoadedGameChanged.cs delete mode 100644 src/StardewModdingAPI/Events/EventArgsNewDay.cs delete mode 100644 src/StardewModdingAPI/Events/EventArgsStringChanged.cs (limited to 'src/StardewModdingAPI/Events') 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 -{ - /// Event arguments for a event. - [Obsolete("Use " + nameof(IModHelper) + "." + nameof(IModHelper.ConsoleCommands))] - public class EventArgsCommand : EventArgs - { - /********* - ** Accessors - *********/ - /// The triggered command. - public Command Command { get; } - - - /********* - ** Public methods - *********/ - /// Construct an instance. - /// The triggered command. - public EventArgsCommand(Command command) - { - this.Command = command; - } - } -} -#endif \ No newline at end of file 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 -{ - /// Event arguments for a event. - public class EventArgsFarmerChanged : EventArgs - { - /********* - ** Accessors - *********/ - /// The previous player character. - public SFarmer NewFarmer { get; } - - /// The new player character. - public SFarmer PriorFarmer { get; } - - - /********* - ** Public methods - *********/ - /// Construct an instance. - /// The previous player character. - /// The new player character. - 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/EventArgsInput.cs b/src/StardewModdingAPI/Events/EventArgsInput.cs index 31368555..66cb19f2 100644 --- a/src/StardewModdingAPI/Events/EventArgsInput.cs +++ b/src/StardewModdingAPI/Events/EventArgsInput.cs @@ -1,4 +1,3 @@ -#if !SMAPI_1_x using System; using System.Linq; using Microsoft.Xna.Framework; @@ -123,4 +122,3 @@ namespace StardewModdingAPI.Events } } } -#endif diff --git a/src/StardewModdingAPI/Events/EventArgsLoadedGameChanged.cs b/src/StardewModdingAPI/Events/EventArgsLoadedGameChanged.cs deleted file mode 100644 index 688b4b3d..00000000 --- a/src/StardewModdingAPI/Events/EventArgsLoadedGameChanged.cs +++ /dev/null @@ -1,27 +0,0 @@ -#if SMAPI_1_x -using System; - -namespace StardewModdingAPI.Events -{ - /// Event arguments for a event. - public class EventArgsLoadedGameChanged : EventArgs - { - /********* - ** Accessors - *********/ - /// Whether the save has been loaded. This is always true. - public bool LoadedGame { get; } - - - /********* - ** Public methods - *********/ - /// Construct an instance. - /// Whether the save has been loaded. This is always true. - public EventArgsLoadedGameChanged(bool loaded) - { - this.LoadedGame = loaded; - } - } -} -#endif \ No newline at end of file diff --git a/src/StardewModdingAPI/Events/EventArgsNewDay.cs b/src/StardewModdingAPI/Events/EventArgsNewDay.cs deleted file mode 100644 index b8cbe9e3..00000000 --- a/src/StardewModdingAPI/Events/EventArgsNewDay.cs +++ /dev/null @@ -1,37 +0,0 @@ -#if SMAPI_1_x -using System; - -namespace StardewModdingAPI.Events -{ - /// Event arguments for a event. - public class EventArgsNewDay : EventArgs - { - /********* - ** Accessors - *********/ - /// The previous day value. - public int PreviousDay { get; } - - /// The current day value. - public int CurrentDay { get; } - - /// Whether the game just started the transition (true) or finished it (false). - public bool IsNewDay { get; } - - - /********* - ** Public methods - *********/ - /// Construct an instance. - /// The previous day value. - /// The current day value. - /// Whether the game just started the transition (true) or finished it (false). - public EventArgsNewDay(int priorDay, int newDay, bool isTransitioning) - { - this.PreviousDay = priorDay; - this.CurrentDay = newDay; - this.IsNewDay = isTransitioning; - } - } -} -#endif \ No newline at end of file diff --git a/src/StardewModdingAPI/Events/EventArgsStringChanged.cs b/src/StardewModdingAPI/Events/EventArgsStringChanged.cs deleted file mode 100644 index f580a2ce..00000000 --- a/src/StardewModdingAPI/Events/EventArgsStringChanged.cs +++ /dev/null @@ -1,31 +0,0 @@ -#if SMAPI_1_x -using System; - -namespace StardewModdingAPI.Events -{ - /// Event arguments for a string field that changed value. - public class EventArgsStringChanged : EventArgs - { - /********* - ** Accessors - *********/ - /// The previous value. - public string NewString { get; } - - /// The current value. - public string PriorString { get; } - - /********* - ** Public methods - *********/ - /// Construct an instance. - /// The previous value. - /// The current value. - public EventArgsStringChanged(string priorString, string newString) - { - this.NewString = newString; - this.PriorString = priorString; - } - } -} -#endif \ No newline at end of file diff --git a/src/StardewModdingAPI/Events/GameEvents.cs b/src/StardewModdingAPI/Events/GameEvents.cs index deb71a86..b477376e 100644 --- a/src/StardewModdingAPI/Events/GameEvents.cs +++ b/src/StardewModdingAPI/Events/GameEvents.cs @@ -1,94 +1,17 @@ using System; -using System.Diagnostics.CodeAnalysis; using StardewModdingAPI.Framework; -#pragma warning disable 618 // Suppress obsolete-symbol errors in this file. Since several events are marked obsolete, this produces unnecessary warnings. namespace StardewModdingAPI.Events { /// Events raised when the game changes state. public static class GameEvents { - /********* - ** Properties - *********/ -#if SMAPI_1_x - /// Manages deprecation warnings. - private static DeprecationManager DeprecationManager; - - /// The backing field for . - [SuppressMessage("ReSharper", "InconsistentNaming")] - private static event EventHandler _Initialize; - - /// The backing field for . - [SuppressMessage("ReSharper", "InconsistentNaming")] - private static event EventHandler _LoadContent; - - /// The backing field for . - [SuppressMessage("ReSharper", "InconsistentNaming")] - private static event EventHandler _GameLoaded; - - /// The backing field for . - [SuppressMessage("ReSharper", "InconsistentNaming")] - private static event EventHandler _FirstUpdateTick; -#endif - - /********* ** Events *********/ /// Raised during launch after configuring XNA or MonoGame. The game window hasn't been opened by this point. Called after . internal static event EventHandler InitializeInternal; -#if SMAPI_1_x - /// Raised during launch after configuring XNA or MonoGame. The game window hasn't been opened by this point. Called after . - [Obsolete("The " + nameof(Mod) + "." + nameof(Mod.Entry) + " method is now called after the " + nameof(GameEvents.Initialize) + " event, so any contained logic can be done directly in " + nameof(Mod.Entry) + ".")] - public static event EventHandler Initialize - { - add - { - GameEvents.DeprecationManager.Warn($"{nameof(GameEvents)}.{nameof(GameEvents.Initialize)}", "1.10", DeprecationLevel.PendingRemoval); - GameEvents._Initialize += value; - } - remove => GameEvents._Initialize -= value; - } - - /// Raised before XNA loads or reloads graphics resources. Called during . - [Obsolete("The " + nameof(Mod) + "." + nameof(Mod.Entry) + " method is now called after the " + nameof(GameEvents.LoadContent) + " event, so any contained logic can be done directly in " + nameof(Mod.Entry) + ".")] - public static event EventHandler LoadContent - { - add - { - GameEvents.DeprecationManager.Warn($"{nameof(GameEvents)}.{nameof(GameEvents.LoadContent)}", "1.10", DeprecationLevel.PendingRemoval); - GameEvents._LoadContent += value; - } - remove => GameEvents._LoadContent -= value; - } - - /// Raised during launch after configuring Stardew Valley, loading it into memory, and opening the game window. The window is still blank by this point. - [Obsolete("The " + nameof(Mod) + "." + nameof(Mod.Entry) + " method is now called after the game loads, so any contained logic can be done directly in " + nameof(Mod.Entry) + ".")] - public static event EventHandler GameLoaded - { - add - { - GameEvents.DeprecationManager.Warn($"{nameof(GameEvents)}.{nameof(GameEvents.GameLoaded)}", "1.12", DeprecationLevel.PendingRemoval); - GameEvents._GameLoaded += value; - } - remove => GameEvents._GameLoaded -= value; - } - - /// Raised during the first game update tick. - [Obsolete("The " + nameof(Mod) + "." + nameof(Mod.Entry) + " method is now called after the game loads, so any contained logic can be done directly in " + nameof(Mod.Entry) + ".")] - public static event EventHandler FirstUpdateTick - { - add - { - GameEvents.DeprecationManager.Warn($"{nameof(GameEvents)}.{nameof(GameEvents.FirstUpdateTick)}", "1.12", DeprecationLevel.PendingRemoval); - GameEvents._FirstUpdateTick += value; - } - remove => GameEvents._FirstUpdateTick -= value; - } -#endif - /// Raised when the game updates its state (≈60 times per second). public static event EventHandler UpdateTick; @@ -114,47 +37,12 @@ namespace StardewModdingAPI.Events /********* ** Internal methods *********/ -#if SMAPI_1_x - /// Injects types required for backwards compatibility. - /// Manages deprecation warnings. - internal static void Shim(DeprecationManager deprecationManager) - { - GameEvents.DeprecationManager = deprecationManager; - } -#endif - /// Raise an event. /// Encapsulates logging and monitoring. internal static void InvokeInitialize(IMonitor monitor) { monitor.SafelyRaisePlainEvent($"{nameof(GameEvents)}.{nameof(GameEvents.InitializeInternal)}", GameEvents.InitializeInternal?.GetInvocationList()); -#if SMAPI_1_x - monitor.SafelyRaisePlainEvent($"{nameof(GameEvents)}.{nameof(GameEvents.Initialize)}", GameEvents._Initialize?.GetInvocationList()); -#endif - } - -#if SMAPI_1_x - /// Raise a event. - /// Encapsulates logging and monitoring. - internal static void InvokeLoadContent(IMonitor monitor) - { - monitor.SafelyRaisePlainEvent($"{nameof(GameEvents)}.{nameof(GameEvents.LoadContent)}", GameEvents._LoadContent?.GetInvocationList()); - } - - /// Raise a event. - /// Encapsulates monitoring and logging. - internal static void InvokeGameLoaded(IMonitor monitor) - { - monitor.SafelyRaisePlainEvent($"{nameof(GameEvents)}.{nameof(GameEvents.GameLoaded)}", GameEvents._GameLoaded?.GetInvocationList()); - } - - /// Raise a event. - /// Encapsulates monitoring and logging. - internal static void InvokeFirstUpdateTick(IMonitor monitor) - { - monitor.SafelyRaisePlainEvent($"{nameof(GameEvents)}.{nameof(GameEvents.FirstUpdateTick)}", GameEvents._FirstUpdateTick?.GetInvocationList()); } -#endif /// Raise an event. /// Encapsulates logging and monitoring. diff --git a/src/StardewModdingAPI/Events/InputEvents.cs b/src/StardewModdingAPI/Events/InputEvents.cs index b99b49e0..c31eb698 100644 --- a/src/StardewModdingAPI/Events/InputEvents.cs +++ b/src/StardewModdingAPI/Events/InputEvents.cs @@ -1,4 +1,3 @@ -#if !SMAPI_1_x using System; using StardewModdingAPI.Framework; using StardewModdingAPI.Utilities; @@ -42,4 +41,3 @@ namespace StardewModdingAPI.Events } } } -#endif \ No newline at end of file diff --git a/src/StardewModdingAPI/Events/PlayerEvents.cs b/src/StardewModdingAPI/Events/PlayerEvents.cs index 72826330..5a9a9d5f 100644 --- a/src/StardewModdingAPI/Events/PlayerEvents.cs +++ b/src/StardewModdingAPI/Events/PlayerEvents.cs @@ -1,63 +1,17 @@ -using System; +using System; using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; using System.Linq; using StardewModdingAPI.Framework; using StardewValley; -using SFarmer = StardewValley.Farmer; -#pragma warning disable 618 // Suppress obsolete-symbol errors in this file. Since several events are marked obsolete, this produces unnecessary warnings. namespace StardewModdingAPI.Events { /// Events raised when the player data changes. public static class PlayerEvents { - /********* - ** Properties - *********/ -#if SMAPI_1_x - /// Manages deprecation warnings. - private static DeprecationManager DeprecationManager; - - /// The backing field for . - [SuppressMessage("ReSharper", "InconsistentNaming")] - private static event EventHandler _LoadedGame; - - /// The backing field for . - [SuppressMessage("ReSharper", "InconsistentNaming")] - private static event EventHandler _FarmerChanged; -#endif - - /********* ** Events *********/ -#if SMAPI_1_x - /// Raised after the player loads a saved game. - [Obsolete("Use " + nameof(SaveEvents) + "." + nameof(SaveEvents.AfterLoad) + " instead")] - public static event EventHandler LoadedGame - { - add - { - PlayerEvents.DeprecationManager.Warn($"{nameof(PlayerEvents)}.{nameof(PlayerEvents.LoadedGame)}", "1.6", DeprecationLevel.PendingRemoval); - PlayerEvents._LoadedGame += value; - } - remove => PlayerEvents._LoadedGame -= value; - } - - /// Raised after the game assigns a new player character. This happens just before ; it's unclear how this would happen any other time. - [Obsolete("should no longer be used")] - public static event EventHandler FarmerChanged - { - add - { - PlayerEvents.DeprecationManager.Warn($"{nameof(PlayerEvents)}.{nameof(PlayerEvents.FarmerChanged)}", "1.6", DeprecationLevel.PendingRemoval); - PlayerEvents._FarmerChanged += value; - } - remove => PlayerEvents._FarmerChanged -= value; - } -#endif - /// Raised after the player's inventory changes in any way (added or removed item, sorted, etc). public static event EventHandler InventoryChanged; @@ -68,32 +22,6 @@ namespace StardewModdingAPI.Events /********* ** Internal methods *********/ -#if SMAPI_1_x - /// Injects types required for backwards compatibility. - /// Manages deprecation warnings. - internal static void Shim(DeprecationManager deprecationManager) - { - PlayerEvents.DeprecationManager = deprecationManager; - } - - /// Raise a event. - /// Encapsulates monitoring and logging. - /// Whether the save has been loaded. This is always true. - internal static void InvokeLoadedGame(IMonitor monitor, EventArgsLoadedGameChanged loaded) - { - monitor.SafelyRaiseGenericEvent($"{nameof(PlayerEvents)}.{nameof(PlayerEvents.LoadedGame)}", PlayerEvents._LoadedGame?.GetInvocationList(), null, loaded); - } - - /// Raise a event. - /// Encapsulates monitoring and logging. - /// The previous player character. - /// The new player character. - internal static void InvokeFarmerChanged(IMonitor monitor, SFarmer priorFarmer, SFarmer newFarmer) - { - monitor.SafelyRaiseGenericEvent($"{nameof(PlayerEvents)}.{nameof(PlayerEvents.FarmerChanged)}", PlayerEvents._FarmerChanged?.GetInvocationList(), null, new EventArgsFarmerChanged(priorFarmer, newFarmer)); - } -#endif - /// Raise an event. /// Encapsulates monitoring and logging. /// The player's inventory. diff --git a/src/StardewModdingAPI/Events/TimeEvents.cs b/src/StardewModdingAPI/Events/TimeEvents.cs index d5ab9fb7..9aea5e04 100644 --- a/src/StardewModdingAPI/Events/TimeEvents.cs +++ b/src/StardewModdingAPI/Events/TimeEvents.cs @@ -1,38 +1,11 @@ -using System; -using System.Diagnostics.CodeAnalysis; +using System; using StardewModdingAPI.Framework; -#pragma warning disable 618 // Suppress obsolete-symbol errors in this file. Since several events are marked obsolete, this produces unnecessary warnings. namespace StardewModdingAPI.Events { /// Events raised when the in-game date or time changes. public static class TimeEvents { - /********* - ** Properties - *********/ -#if SMAPI_1_x - /// Manages deprecation warnings. - private static DeprecationManager DeprecationManager; - - /// The backing field for . - [SuppressMessage("ReSharper", "InconsistentNaming")] - private static event EventHandler _OnNewDay; - - /// The backing field for . - [SuppressMessage("ReSharper", "InconsistentNaming")] - private static event EventHandler _DayOfMonthChanged; - - /// The backing field for . - [SuppressMessage("ReSharper", "InconsistentNaming")] - private static event EventHandler _SeasonOfYearChanged; - - /// The backing field for . - [SuppressMessage("ReSharper", "InconsistentNaming")] - private static event EventHandler _YearOfGameChanged; -#endif - - /********* ** Events *********/ @@ -42,69 +15,9 @@ namespace StardewModdingAPI.Events /// Raised after the in-game clock changes. public static event EventHandler TimeOfDayChanged; -#if SMAPI_1_x - /// Raised after the day-of-month value changes, including when loading a save. This may happen before save; in most cases you should use instead. - [Obsolete("Use " + nameof(TimeEvents) + "." + nameof(TimeEvents.AfterDayStarted) + " or " + nameof(SaveEvents) + " instead")] - public static event EventHandler DayOfMonthChanged - { - add - { - TimeEvents.DeprecationManager.Warn($"{nameof(TimeEvents)}.{nameof(TimeEvents.DayOfMonthChanged)}", "1.14", DeprecationLevel.PendingRemoval); - TimeEvents._DayOfMonthChanged += value; - } - remove => TimeEvents._DayOfMonthChanged -= value; - } - - /// Raised after the year value changes. - [Obsolete("Use " + nameof(TimeEvents) + "." + nameof(TimeEvents.AfterDayStarted) + " or " + nameof(SaveEvents) + " instead")] - public static event EventHandler YearOfGameChanged - { - add - { - TimeEvents.DeprecationManager.Warn($"{nameof(TimeEvents)}.{nameof(TimeEvents.YearOfGameChanged)}", "1.14", DeprecationLevel.PendingRemoval); - TimeEvents._YearOfGameChanged += value; - } - remove => TimeEvents._YearOfGameChanged -= value; - } - - /// Raised after the season value changes. - [Obsolete("Use " + nameof(TimeEvents) + "." + nameof(TimeEvents.AfterDayStarted) + " or " + nameof(SaveEvents) + " instead")] - public static event EventHandler SeasonOfYearChanged - { - add - { - TimeEvents.DeprecationManager.Warn($"{nameof(TimeEvents)}.{nameof(TimeEvents.SeasonOfYearChanged)}", "1.14", DeprecationLevel.PendingRemoval); - TimeEvents._SeasonOfYearChanged += value; - } - remove => TimeEvents._SeasonOfYearChanged -= value; - } - - /// Raised when the player is transitioning to a new day and the game is performing its day update logic. This event is triggered twice: once after the game starts transitioning, and again after it finishes. - [Obsolete("Use " + nameof(TimeEvents) + "." + nameof(TimeEvents.AfterDayStarted) + " or " + nameof(SaveEvents) + " instead")] - public static event EventHandler OnNewDay - { - add - { - TimeEvents.DeprecationManager.Warn($"{nameof(TimeEvents)}.{nameof(TimeEvents.OnNewDay)}", "1.6", DeprecationLevel.PendingRemoval); - TimeEvents._OnNewDay += value; - } - remove => TimeEvents._OnNewDay -= value; - } -#endif - - /********* ** Internal methods *********/ -#if SMAPI_1_x - /// Injects types required for backwards compatibility. - /// Manages deprecation warnings. - internal static void Shim(DeprecationManager deprecationManager) - { - TimeEvents.DeprecationManager = deprecationManager; - } -#endif - /// Raise an event. /// Encapsulates monitoring and logging. internal static void InvokeAfterDayStarted(IMonitor monitor) @@ -120,44 +33,5 @@ namespace StardewModdingAPI.Events { monitor.SafelyRaiseGenericEvent($"{nameof(TimeEvents)}.{nameof(TimeEvents.TimeOfDayChanged)}", TimeEvents.TimeOfDayChanged?.GetInvocationList(), null, new EventArgsIntChanged(priorTime, newTime)); } - -#if SMAPI_1_x - /// Raise a event. - /// Encapsulates monitoring and logging. - /// The previous day value. - /// The current day value. - internal static void InvokeDayOfMonthChanged(IMonitor monitor, int priorDay, int newDay) - { - monitor.SafelyRaiseGenericEvent($"{nameof(TimeEvents)}.{nameof(TimeEvents.DayOfMonthChanged)}", TimeEvents._DayOfMonthChanged?.GetInvocationList(), null, new EventArgsIntChanged(priorDay, newDay)); - } - - /// Raise a event. - /// Encapsulates monitoring and logging. - /// The previous year value. - /// The current year value. - internal static void InvokeYearOfGameChanged(IMonitor monitor, int priorYear, int newYear) - { - monitor.SafelyRaiseGenericEvent($"{nameof(TimeEvents)}.{nameof(TimeEvents.YearOfGameChanged)}", TimeEvents._YearOfGameChanged?.GetInvocationList(), null, new EventArgsIntChanged(priorYear, newYear)); - } - - /// Raise a event. - /// Encapsulates monitoring and logging. - /// The previous season name. - /// The current season name. - internal static void InvokeSeasonOfYearChanged(IMonitor monitor, string priorSeason, string newSeason) - { - monitor.SafelyRaiseGenericEvent($"{nameof(TimeEvents)}.{nameof(TimeEvents.SeasonOfYearChanged)}", TimeEvents._SeasonOfYearChanged?.GetInvocationList(), null, new EventArgsStringChanged(priorSeason, newSeason)); - } - - /// Raise a event. - /// Encapsulates monitoring and logging. - /// The previous day value. - /// The current day value. - /// Whether the game just started the transition (true) or finished it (false). - internal static void InvokeOnNewDay(IMonitor monitor, int priorDay, int newDay, bool isTransitioning) - { - monitor.SafelyRaiseGenericEvent($"{nameof(TimeEvents)}.{nameof(TimeEvents.OnNewDay)}", TimeEvents._OnNewDay?.GetInvocationList(), null, new EventArgsNewDay(priorDay, newDay, isTransitioning)); - } -#endif } } -- cgit From 929dccb75a1405737975d76648e015a3e7c00177 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 7 Oct 2017 23:07:10 -0400 Subject: reorganise repo structure --- src/StardewModdingAPI/Events/ChangeType.cs | 15 --- src/StardewModdingAPI/Events/ContentEvents.cs | 29 ----- src/StardewModdingAPI/Events/ControlEvents.cs | 112 ------------------- .../Events/EventArgsClickableMenuChanged.cs | 31 ------ .../Events/EventArgsClickableMenuClosed.cs | 26 ----- .../Events/EventArgsControllerButtonPressed.cs | 32 ------ .../Events/EventArgsControllerButtonReleased.cs | 32 ------ .../Events/EventArgsControllerTriggerPressed.cs | 37 ------ .../Events/EventArgsControllerTriggerReleased.cs | 37 ------ .../Events/EventArgsCurrentLocationChanged.cs | 31 ------ .../Events/EventArgsGameLocationsChanged.cs | 27 ----- src/StardewModdingAPI/Events/EventArgsInput.cs | 124 --------------------- .../Events/EventArgsIntChanged.cs | 29 ----- .../Events/EventArgsInventoryChanged.cs | 41 ------- .../Events/EventArgsKeyPressed.cs | 26 ----- .../Events/EventArgsKeyboardStateChanged.cs | 31 ------ src/StardewModdingAPI/Events/EventArgsLevelUp.cs | 52 --------- .../Events/EventArgsLocationObjectsChanged.cs | 28 ----- .../Events/EventArgsMineLevelChanged.cs | 30 ----- .../Events/EventArgsMouseStateChanged.cs | 42 ------- .../Events/EventArgsValueChanged.cs | 31 ------ src/StardewModdingAPI/Events/GameEvents.cs | 96 ---------------- src/StardewModdingAPI/Events/GraphicsEvents.cs | 116 ------------------- src/StardewModdingAPI/Events/InputEvents.cs | 43 ------- src/StardewModdingAPI/Events/ItemStackChange.cs | 20 ---- src/StardewModdingAPI/Events/LocationEvents.cs | 54 --------- src/StardewModdingAPI/Events/MenuEvents.cs | 40 ------- src/StardewModdingAPI/Events/MineEvents.cs | 28 ----- src/StardewModdingAPI/Events/PlayerEvents.cs | 43 ------- src/StardewModdingAPI/Events/SaveEvents.cs | 56 ---------- src/StardewModdingAPI/Events/TimeEvents.cs | 37 ------ 31 files changed, 1376 deletions(-) delete mode 100644 src/StardewModdingAPI/Events/ChangeType.cs delete mode 100644 src/StardewModdingAPI/Events/ContentEvents.cs delete mode 100644 src/StardewModdingAPI/Events/ControlEvents.cs delete mode 100644 src/StardewModdingAPI/Events/EventArgsClickableMenuChanged.cs delete mode 100644 src/StardewModdingAPI/Events/EventArgsClickableMenuClosed.cs delete mode 100644 src/StardewModdingAPI/Events/EventArgsControllerButtonPressed.cs delete mode 100644 src/StardewModdingAPI/Events/EventArgsControllerButtonReleased.cs delete mode 100644 src/StardewModdingAPI/Events/EventArgsControllerTriggerPressed.cs delete mode 100644 src/StardewModdingAPI/Events/EventArgsControllerTriggerReleased.cs delete mode 100644 src/StardewModdingAPI/Events/EventArgsCurrentLocationChanged.cs delete mode 100644 src/StardewModdingAPI/Events/EventArgsGameLocationsChanged.cs delete mode 100644 src/StardewModdingAPI/Events/EventArgsInput.cs delete mode 100644 src/StardewModdingAPI/Events/EventArgsIntChanged.cs delete mode 100644 src/StardewModdingAPI/Events/EventArgsInventoryChanged.cs delete mode 100644 src/StardewModdingAPI/Events/EventArgsKeyPressed.cs delete mode 100644 src/StardewModdingAPI/Events/EventArgsKeyboardStateChanged.cs delete mode 100644 src/StardewModdingAPI/Events/EventArgsLevelUp.cs delete mode 100644 src/StardewModdingAPI/Events/EventArgsLocationObjectsChanged.cs delete mode 100644 src/StardewModdingAPI/Events/EventArgsMineLevelChanged.cs delete mode 100644 src/StardewModdingAPI/Events/EventArgsMouseStateChanged.cs delete mode 100644 src/StardewModdingAPI/Events/EventArgsValueChanged.cs delete mode 100644 src/StardewModdingAPI/Events/GameEvents.cs delete mode 100644 src/StardewModdingAPI/Events/GraphicsEvents.cs delete mode 100644 src/StardewModdingAPI/Events/InputEvents.cs delete mode 100644 src/StardewModdingAPI/Events/ItemStackChange.cs delete mode 100644 src/StardewModdingAPI/Events/LocationEvents.cs delete mode 100644 src/StardewModdingAPI/Events/MenuEvents.cs delete mode 100644 src/StardewModdingAPI/Events/MineEvents.cs delete mode 100644 src/StardewModdingAPI/Events/PlayerEvents.cs delete mode 100644 src/StardewModdingAPI/Events/SaveEvents.cs delete mode 100644 src/StardewModdingAPI/Events/TimeEvents.cs (limited to 'src/StardewModdingAPI/Events') 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 -{ - /// Indicates how an inventory item changed. - public enum ChangeType - { - /// The entire stack was removed. - Removed, - - /// The entire stack was added. - Added, - - /// The stack size changed. - 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 -{ - /// Events raised when the game loads content. - public static class ContentEvents - { - - /********* - ** Events - *********/ - /// Raised after the content language changes. - public static event EventHandler> AfterLocaleChanged; - - - /********* - ** Internal methods - *********/ - /// Raise an event. - /// Encapsulates monitoring and logging. - /// The previous locale. - /// The current locale. - internal static void InvokeAfterLocaleChanged(IMonitor monitor, string oldLocale, string newLocale) - { - monitor.SafelyRaiseGenericEvent($"{nameof(ContentEvents)}.{nameof(ContentEvents.AfterLocaleChanged)}", ContentEvents.AfterLocaleChanged?.GetInvocationList(), null, new EventArgsValueChanged(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 -{ - /// Events raised when the player uses a controller, keyboard, or mouse. - public static class ControlEvents - { - /********* - ** Events - *********/ - /// Raised when the changes. That happens when the player presses or releases a key. - public static event EventHandler KeyboardChanged; - - /// Raised when the player presses a keyboard key. - public static event EventHandler KeyPressed; - - /// Raised when the player releases a keyboard key. - public static event EventHandler KeyReleased; - - /// Raised when the changes. That happens when the player moves the mouse, scrolls the mouse wheel, or presses/releases a button. - public static event EventHandler MouseChanged; - - /// The player pressed a controller button. This event isn't raised for trigger buttons. - public static event EventHandler ControllerButtonPressed; - - /// The player released a controller button. This event isn't raised for trigger buttons. - public static event EventHandler ControllerButtonReleased; - - /// The player pressed a controller trigger button. - public static event EventHandler ControllerTriggerPressed; - - /// The player released a controller trigger button. - public static event EventHandler ControllerTriggerReleased; - - - /********* - ** Internal methods - *********/ - /// Raise a event. - /// Encapsulates monitoring and logging. - /// The previous keyboard state. - /// The current keyboard state. - 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)); - } - - /// Raise a event. - /// Encapsulates monitoring and logging. - /// The previous mouse state. - /// The current mouse state. - /// The previous mouse position on the screen adjusted for the zoom level. - /// The current mouse position on the screen adjusted for the zoom level. - 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)); - } - - /// Raise a event. - /// Encapsulates monitoring and logging. - /// The keyboard button that was pressed. - internal static void InvokeKeyPressed(IMonitor monitor, Keys key) - { - monitor.SafelyRaiseGenericEvent($"{nameof(ControlEvents)}.{nameof(ControlEvents.KeyPressed)}", ControlEvents.KeyPressed?.GetInvocationList(), null, new EventArgsKeyPressed(key)); - } - - /// Raise a event. - /// Encapsulates monitoring and logging. - /// The keyboard button that was released. - internal static void InvokeKeyReleased(IMonitor monitor, Keys key) - { - monitor.SafelyRaiseGenericEvent($"{nameof(ControlEvents)}.{nameof(ControlEvents.KeyReleased)}", ControlEvents.KeyReleased?.GetInvocationList(), null, new EventArgsKeyPressed(key)); - } - - /// Raise a event. - /// Encapsulates monitoring and logging. - /// The controller button that was pressed. - internal static void InvokeButtonPressed(IMonitor monitor, Buttons button) - { - monitor.SafelyRaiseGenericEvent($"{nameof(ControlEvents)}.{nameof(ControlEvents.ControllerButtonPressed)}", ControlEvents.ControllerButtonPressed?.GetInvocationList(), null, new EventArgsControllerButtonPressed(PlayerIndex.One, button)); - } - - /// Raise a event. - /// Encapsulates monitoring and logging. - /// The controller button that was released. - internal static void InvokeButtonReleased(IMonitor monitor, Buttons button) - { - monitor.SafelyRaiseGenericEvent($"{nameof(ControlEvents)}.{nameof(ControlEvents.ControllerButtonReleased)}", ControlEvents.ControllerButtonReleased?.GetInvocationList(), null, new EventArgsControllerButtonReleased(PlayerIndex.One, button)); - } - - /// Raise a event. - /// Encapsulates monitoring and logging. - /// The trigger button that was pressed. - /// The current trigger value. - 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)); - } - - /// Raise a event. - /// Encapsulates monitoring and logging. - /// The trigger button that was pressed. - /// The current trigger value. - 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 -{ - /// Event arguments for a event. - public class EventArgsClickableMenuChanged : EventArgs - { - /********* - ** Accessors - *********/ - /// The previous menu. - public IClickableMenu NewMenu { get; } - - /// The current menu. - public IClickableMenu PriorMenu { get; } - - - /********* - ** Public methods - *********/ - /// Construct an instance. - /// The previous menu. - /// The current menu. - 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 -{ - /// Event arguments for a event. - public class EventArgsClickableMenuClosed : EventArgs - { - /********* - ** Accessors - *********/ - /// The menu that was closed. - public IClickableMenu PriorMenu { get; } - - - /********* - ** Accessors - *********/ - /// Construct an instance. - /// The menu that was closed. - public EventArgsClickableMenuClosed(IClickableMenu priorMenu) - { - this.PriorMenu = priorMenu; - } - } -} 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 -{ - /// Event arguments for a event. - public class EventArgsControllerButtonPressed : EventArgs - { - /********* - ** Accessors - *********/ - /// The player who pressed the button. - public PlayerIndex PlayerIndex { get; } - - /// The controller button that was pressed. - public Buttons ButtonPressed { get; } - - - /********* - ** Public methods - *********/ - /// Construct an instance. - /// The player who pressed the button. - /// The controller button that was pressed. - 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 -{ - /// Event arguments for a event. - public class EventArgsControllerButtonReleased : EventArgs - { - /********* - ** Accessors - *********/ - /// The player who pressed the button. - public PlayerIndex PlayerIndex { get; } - - /// The controller button that was pressed. - public Buttons ButtonReleased { get; } - - - /********* - ** Public methods - *********/ - /// Construct an instance. - /// The player who pressed the button. - /// The controller button that was released. - 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 -{ - /// Event arguments for a event. - public class EventArgsControllerTriggerPressed : EventArgs - { - /********* - ** Accessors - *********/ - /// The player who pressed the button. - public PlayerIndex PlayerIndex { get; } - - /// The controller button that was pressed. - public Buttons ButtonPressed { get; } - - /// The current trigger value. - public float Value { get; } - - - /********* - ** Public methods - *********/ - /// Construct an instance. - /// The player who pressed the trigger button. - /// The trigger button that was pressed. - /// The current trigger value. - 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 -{ - /// Event arguments for a event. - public class EventArgsControllerTriggerReleased : EventArgs - { - /********* - ** Accessors - *********/ - /// The player who pressed the button. - public PlayerIndex PlayerIndex { get; } - - /// The controller button that was released. - public Buttons ButtonReleased { get; } - - /// The current trigger value. - public float Value { get; } - - - /********* - ** Public methods - *********/ - /// Construct an instance. - /// The player who pressed the trigger button. - /// The trigger button that was released. - /// The current trigger value. - 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 -{ - /// Event arguments for a event. - public class EventArgsCurrentLocationChanged : EventArgs - { - /********* - ** Accessors - *********/ - /// The player's current location. - public GameLocation NewLocation { get; } - - /// The player's previous location. - public GameLocation PriorLocation { get; } - - - /********* - ** Public methods - *********/ - /// Construct an instance. - /// The player's previous location. - /// The player's current location. - public EventArgsCurrentLocationChanged(GameLocation priorLocation, GameLocation newLocation) - { - this.NewLocation = newLocation; - this.PriorLocation = priorLocation; - } - } -} 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 -{ - /// Event arguments for a event. - public class EventArgsGameLocationsChanged : EventArgs - { - /********* - ** Accessors - *********/ - /// The current list of game locations. - public List NewLocations { get; } - - - /********* - ** Public methods - *********/ - /// Construct an instance. - /// The current list of game locations. - public EventArgsGameLocationsChanged(List newLocations) - { - this.NewLocations = newLocations; - } - } -} diff --git a/src/StardewModdingAPI/Events/EventArgsInput.cs b/src/StardewModdingAPI/Events/EventArgsInput.cs deleted file mode 100644 index 66cb19f2..00000000 --- a/src/StardewModdingAPI/Events/EventArgsInput.cs +++ /dev/null @@ -1,124 +0,0 @@ -using System; -using System.Linq; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Input; -using StardewModdingAPI.Utilities; -using StardewValley; - -namespace StardewModdingAPI.Events -{ - /// Event arguments when a button is pressed or released. - public class EventArgsInput : EventArgs - { - /********* - ** Accessors - *********/ - /// The button on the controller, keyboard, or mouse. - public SButton Button { get; } - - /// The current cursor position. - public ICursorPosition Cursor { get; set; } - - /// Whether the input is considered a 'click' by the game for enabling action. - public bool IsClick { get; } - - - /********* - ** Public methods - *********/ - /// Construct an instance. - /// The button on the controller, keyboard, or mouse. - /// The cursor position. - /// Whether the input is considered a 'click' by the game for enabling action. - public EventArgsInput(SButton button, ICursorPosition cursor, bool isClick) - { - this.Button = button; - this.Cursor = cursor; - this.IsClick = isClick; - } - - /// Prevent the game from handling the vurrent 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) - { - // keyboard - if (this.Button.TryGetKeyboard(out Keys key)) - Game1.oldKBState = new KeyboardState(Game1.oldKBState.GetPressedKeys().Except(new[] { key }).ToArray()); - - // controller - else if (this.Button.TryGetController(out Buttons controllerButton)) - { - var newState = GamePad.GetState(PlayerIndex.One); - var thumbsticks = Game1.oldPadState.ThumbSticks; - var triggers = Game1.oldPadState.Triggers; - var buttons = Game1.oldPadState.Buttons; - var dpad = Game1.oldPadState.DPad; - - switch (controllerButton) - { - // d-pad - case Buttons.DPadDown: - dpad = new GamePadDPad(dpad.Up, newState.DPad.Down, dpad.Left, dpad.Right); - break; - case Buttons.DPadLeft: - dpad = new GamePadDPad(dpad.Up, dpad.Down, newState.DPad.Left, dpad.Right); - break; - case Buttons.DPadRight: - dpad = new GamePadDPad(dpad.Up, dpad.Down, dpad.Left, newState.DPad.Right); - break; - case Buttons.DPadUp: - dpad = new GamePadDPad(newState.DPad.Up, dpad.Down, dpad.Left, dpad.Right); - break; - - // trigger - case Buttons.LeftTrigger: - triggers = new GamePadTriggers(newState.Triggers.Left, triggers.Right); - break; - case Buttons.RightTrigger: - triggers = new GamePadTriggers(triggers.Left, newState.Triggers.Right); - break; - - // thumbstick - case Buttons.LeftThumbstickDown: - case Buttons.LeftThumbstickLeft: - case Buttons.LeftThumbstickRight: - case Buttons.LeftThumbstickUp: - thumbsticks = new GamePadThumbSticks(newState.ThumbSticks.Left, thumbsticks.Right); - break; - case Buttons.RightThumbstickDown: - case Buttons.RightThumbstickLeft: - case Buttons.RightThumbstickRight: - case Buttons.RightThumbstickUp: - thumbsticks = new GamePadThumbSticks(newState.ThumbSticks.Right, thumbsticks.Left); - break; - - // buttons - default: - var mask = - (buttons.A == ButtonState.Pressed ? Buttons.A : 0) - | (buttons.B == ButtonState.Pressed ? Buttons.B : 0) - | (buttons.Back == ButtonState.Pressed ? Buttons.Back : 0) - | (buttons.BigButton == ButtonState.Pressed ? Buttons.BigButton : 0) - | (buttons.LeftShoulder == ButtonState.Pressed ? Buttons.LeftShoulder : 0) - | (buttons.LeftStick == ButtonState.Pressed ? Buttons.LeftStick : 0) - | (buttons.RightShoulder == ButtonState.Pressed ? Buttons.RightShoulder : 0) - | (buttons.RightStick == ButtonState.Pressed ? Buttons.RightStick : 0) - | (buttons.Start == ButtonState.Pressed ? Buttons.Start : 0) - | (buttons.X == ButtonState.Pressed ? Buttons.X : 0) - | (buttons.Y == ButtonState.Pressed ? Buttons.Y : 0); - mask = mask ^ controllerButton; - buttons = new GamePadButtons(mask); - break; - } - - Game1.oldPadState = new GamePadState(thumbsticks, triggers, buttons, dpad); - } - } - } -} diff --git a/src/StardewModdingAPI/Events/EventArgsIntChanged.cs b/src/StardewModdingAPI/Events/EventArgsIntChanged.cs deleted file mode 100644 index 0c742d12..00000000 --- a/src/StardewModdingAPI/Events/EventArgsIntChanged.cs +++ /dev/null @@ -1,29 +0,0 @@ -using System; - -namespace StardewModdingAPI.Events -{ - /// Event arguments for an integer field that changed value. - public class EventArgsIntChanged : EventArgs - { - /********* - ** Accessors - *********/ - /// The previous value. - public int PriorInt { get; } - - /// The current value. - public int NewInt { get; } - - /********* - ** Public methods - *********/ - /// Construct an instance. - /// The previous value. - /// The current value. - public EventArgsIntChanged(int priorInt, int newInt) - { - this.PriorInt = priorInt; - this.NewInt = newInt; - } - } -} diff --git a/src/StardewModdingAPI/Events/EventArgsInventoryChanged.cs b/src/StardewModdingAPI/Events/EventArgsInventoryChanged.cs deleted file mode 100644 index 1ee02842..00000000 --- a/src/StardewModdingAPI/Events/EventArgsInventoryChanged.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -u