From 4da9e954df3846d01aa0536f4e8143466a1d62f3 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 11 Feb 2022 00:49:49 -0500 Subject: use Array.Empty to avoid unneeded array allocations --- src/SMAPI/Events/ButtonsChangedEventArgs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/SMAPI/Events') diff --git a/src/SMAPI/Events/ButtonsChangedEventArgs.cs b/src/SMAPI/Events/ButtonsChangedEventArgs.cs index dda41692..a5e87735 100644 --- a/src/SMAPI/Events/ButtonsChangedEventArgs.cs +++ b/src/SMAPI/Events/ButtonsChangedEventArgs.cs @@ -58,7 +58,7 @@ namespace StardewModdingAPI.Events foreach (var state in new[] { SButtonState.Pressed, SButtonState.Held, SButtonState.Released }) { if (!lookup.ContainsKey(state)) - lookup[state] = new SButton[0]; + lookup[state] = Array.Empty(); } return lookup; -- cgit From 584725bb8e554e314843315facca1fd15868bee4 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 23 Mar 2022 01:06:11 -0400 Subject: add initial AssetRequested content event (#766) --- src/SMAPI/Events/AssetRequestedEventArgs.cs | 94 +++++++++++++++++++++++++++++ src/SMAPI/Events/IContentEvents.cs | 17 ++++++ src/SMAPI/Events/IModEvents.cs | 3 + 3 files changed, 114 insertions(+) create mode 100644 src/SMAPI/Events/AssetRequestedEventArgs.cs create mode 100644 src/SMAPI/Events/IContentEvents.cs (limited to 'src/SMAPI/Events') diff --git a/src/SMAPI/Events/AssetRequestedEventArgs.cs b/src/SMAPI/Events/AssetRequestedEventArgs.cs new file mode 100644 index 00000000..b17250b0 --- /dev/null +++ b/src/SMAPI/Events/AssetRequestedEventArgs.cs @@ -0,0 +1,94 @@ +using System; +using System.Collections.Generic; +using Microsoft.Xna.Framework.Graphics; +using StardewModdingAPI.Framework; +using StardewModdingAPI.Framework.Content; +using xTile; + +namespace StardewModdingAPI.Events +{ + /// Event arguments for an event. + public class AssetRequestedEventArgs : EventArgs + { + /********* + ** Fields + *********/ + /// The mod handling the event. + private readonly IModMetadata Mod; + + + /********* + ** Accessors + *********/ + /// The name of the asset being requested. + public IAssetName Name { get; } + + /// The load operations requested by the event handler. + internal IList LoadOperations { get; } = new List(); + + /// The edit operations requested by the event handler. + internal IList EditOperations { get; } = new List(); + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The mod handling the event. + /// The name of the asset being requested. + internal AssetRequestedEventArgs(IModMetadata mod, IAssetName name) + { + this.Mod = mod; + this.Name = name; + } + + /// Provide the initial instance for the asset, instead of trying to load it from the game's Content folder. + /// Get the initial instance of an asset. + /// + /// Usage notes: + /// + /// The asset doesn't need to exist in the game's Content folder. If any mod loads the asset, the game will see it as an existing asset as if it was in that folder. + /// Each asset can logically only have one initial instance. If multiple loads apply at the same time, SMAPI will raise an error and ignore all of them. If you're making changes to the existing asset instead of replacing it, you should use instead to avoid those limitations and improve mod compatibility. + /// + /// + public void LoadFrom(Func load) + { + this.LoadOperations.Add( + new AssetLoadOperation(this.Mod, _ => load()) + ); + } + + /// Provide the initial instance for the asset from a file in your mod folder, instead of trying to load it from the game's Content folder. + /// The expected data type. The main supported types are , , dictionaries, and lists; other types may be supported by the game's content pipeline. + /// The relative path to the file in your mod folder. + /// + /// Usage notes: + /// + /// The asset doesn't need to exist in the game's Content folder. If any mod loads the asset, the game will see it as an existing asset as if it was in that folder. + /// Each asset can logically only have one initial instance. If multiple loads apply at the same time, SMAPI will raise an error and ignore all of them. If you're making changes to the existing asset instead of replacing it, you should use instead to avoid those limitations and improve mod compatibility. + /// + /// + public void LoadFromModFile(string relativePath) + { + this.LoadOperations.Add( + new AssetLoadOperation(this.Mod, _ => this.Mod.Mod.Helper.Content.Load(relativePath)) + ); + } + + /// Edit the asset after it's loaded. + /// Apply changes to the asset. + /// + /// Usage notes: + /// + /// Editing an asset which doesn't exist has no effect. This is applied after the asset is loaded from the game's Content folder, or from any mod's or . + /// You can apply any number of edits to the asset. Each edit will be applied on top of the previous one (i.e. it'll see the merged asset from all previous edits as its input). + /// + /// + public void Edit(Action apply) + { + this.EditOperations.Add( + new AssetEditOperation(this.Mod, apply) + ); + } + } +} diff --git a/src/SMAPI/Events/IContentEvents.cs b/src/SMAPI/Events/IContentEvents.cs new file mode 100644 index 00000000..feaf9c0a --- /dev/null +++ b/src/SMAPI/Events/IContentEvents.cs @@ -0,0 +1,17 @@ +using System; +using StardewValley; + +namespace StardewModdingAPI.Events +{ + /// Events related to assets loaded from the content pipeline (including data, maps, and textures). + public interface IContentEvents + { + /// Raised when an asset is being requested from the content pipeline. + /// + /// The asset isn't necessarily being loaded yet (e.g. the game may be checking if it exists). Mods can register the changes they want to apply using methods on the parameter. These will be applied when the asset is actually loaded. + /// + /// If the asset is requested multiple times in the same tick (e.g. once to check if it exists and once to load it), SMAPI might only raise the event once and reuse the cached result. + /// + event EventHandler AssetRequested; + } +} diff --git a/src/SMAPI/Events/IModEvents.cs b/src/SMAPI/Events/IModEvents.cs index 1f892b31..2603961b 100644 --- a/src/SMAPI/Events/IModEvents.cs +++ b/src/SMAPI/Events/IModEvents.cs @@ -3,6 +3,9 @@ namespace StardewModdingAPI.Events /// Manages access to events raised by SMAPI. public interface IModEvents { + /// Events related to assets loaded from the content pipeline (including data, maps, and textures). + IContentEvents Content { get; } + /// Events related to UI and drawing to the screen. IDisplayEvents Display { get; } -- cgit From 2b0ce2bb4d6690b7d00da0a243855db9bffffbf0 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Thu, 24 Mar 2022 22:55:55 -0400 Subject: add AssetInvalidated content event (#766) --- src/SMAPI/Events/AssetsInvalidatedEventArgs.cs | 27 ++++++++++++++++++++++++++ src/SMAPI/Events/IContentEvents.cs | 3 +++ 2 files changed, 30 insertions(+) create mode 100644 src/SMAPI/Events/AssetsInvalidatedEventArgs.cs (limited to 'src/SMAPI/Events') diff --git a/src/SMAPI/Events/AssetsInvalidatedEventArgs.cs b/src/SMAPI/Events/AssetsInvalidatedEventArgs.cs new file mode 100644 index 00000000..0127f83a --- /dev/null +++ b/src/SMAPI/Events/AssetsInvalidatedEventArgs.cs @@ -0,0 +1,27 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +namespace StardewModdingAPI.Events +{ + /// Event arguments for an event. + public class AssetsInvalidatedEventArgs : EventArgs + { + /********* + ** Accessors + *********/ + /// The asset names that were invalidated. + public IEnumerable Names { get; } + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The asset names that were invalidated. + internal AssetsInvalidatedEventArgs(IEnumerable names) + { + this.Names = names.ToArray(); + } + } +} diff --git a/src/SMAPI/Events/IContentEvents.cs b/src/SMAPI/Events/IContentEvents.cs index feaf9c0a..ede9ea23 100644 --- a/src/SMAPI/Events/IContentEvents.cs +++ b/src/SMAPI/Events/IContentEvents.cs @@ -13,5 +13,8 @@ namespace StardewModdingAPI.Events /// If the asset is requested multiple times in the same tick (e.g. once to check if it exists and once to load it), SMAPI might only raise the event once and reuse the cached result. /// event EventHandler AssetRequested; + + /// Raised after one or more assets were invalidated from the content cache by a mod, so they'll be reloaded next time they're requested. If the assets will be reloaded or propagated automatically, this event is raised before that happens. + event EventHandler AssetsInvalidated; } } -- cgit From b77eab6e0a09099998aa806302694e82216e79f8 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 25 Mar 2022 00:35:31 -0400 Subject: add AssetReady content event (#766) --- src/SMAPI/Events/AssetReadyEventArgs.cs | 25 +++++++++++++++++++++++++ src/SMAPI/Events/IContentEvents.cs | 7 +++++-- 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 src/SMAPI/Events/AssetReadyEventArgs.cs (limited to 'src/SMAPI/Events') diff --git a/src/SMAPI/Events/AssetReadyEventArgs.cs b/src/SMAPI/Events/AssetReadyEventArgs.cs new file mode 100644 index 00000000..946c9173 --- /dev/null +++ b/src/SMAPI/Events/AssetReadyEventArgs.cs @@ -0,0 +1,25 @@ +using System; + +namespace StardewModdingAPI.Events +{ + /// Event arguments for an event. + public class AssetReadyEventArgs : EventArgs + { + /********* + ** Accessors + *********/ + /// The name of the asset being requested. + public IAssetName Name { get; } + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The name of the asset being requested. + internal AssetReadyEventArgs(IAssetName name) + { + this.Name = name; + } + } +} diff --git a/src/SMAPI/Events/IContentEvents.cs b/src/SMAPI/Events/IContentEvents.cs index ede9ea23..abbaaf33 100644 --- a/src/SMAPI/Events/IContentEvents.cs +++ b/src/SMAPI/Events/IContentEvents.cs @@ -1,5 +1,4 @@ using System; -using StardewValley; namespace StardewModdingAPI.Events { @@ -8,7 +7,7 @@ namespace StardewModdingAPI.Events { /// Raised when an asset is being requested from the content pipeline. /// - /// The asset isn't necessarily being loaded yet (e.g. the game may be checking if it exists). Mods can register the changes they want to apply using methods on the parameter. These will be applied when the asset is actually loaded. + /// The asset isn't necessarily being loaded yet (e.g. the game may be checking if it exists). Mods can register the changes they want to apply using methods on the event arguments. These will be applied when the asset is actually loaded. /// /// If the asset is requested multiple times in the same tick (e.g. once to check if it exists and once to load it), SMAPI might only raise the event once and reuse the cached result. /// @@ -16,5 +15,9 @@ namespace StardewModdingAPI.Events /// Raised after one or more assets were invalidated from the content cache by a mod, so they'll be reloaded next time they're requested. If the assets will be reloaded or propagated automatically, this event is raised before that happens. event EventHandler AssetsInvalidated; + + /// Raised after an asset is loaded by the content pipeline, after all mod edits specified via have been applied. + /// This event is only raised if something requested the asset from the content pipeline. Invalidating an asset from the content cache won't necessarily reload it automatically. + event EventHandler AssetReady; } } -- cgit From b0011bf65c6ea7ba8d66a219501ac181cbd64c90 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 25 Mar 2022 01:02:26 -0400 Subject: use immutable set for invalidated asset names (#766) --- src/SMAPI/Events/AssetsInvalidatedEventArgs.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/SMAPI/Events') diff --git a/src/SMAPI/Events/AssetsInvalidatedEventArgs.cs b/src/SMAPI/Events/AssetsInvalidatedEventArgs.cs index 0127f83a..f3d83dd6 100644 --- a/src/SMAPI/Events/AssetsInvalidatedEventArgs.cs +++ b/src/SMAPI/Events/AssetsInvalidatedEventArgs.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Collections.Immutable; using System.Linq; namespace StardewModdingAPI.Events @@ -11,7 +12,7 @@ namespace StardewModdingAPI.Events ** Accessors *********/ /// The asset names that were invalidated. - public IEnumerable Names { get; } + public IReadOnlySet Names { get; } /********* @@ -21,7 +22,7 @@ namespace StardewModdingAPI.Events /// The asset names that were invalidated. internal AssetsInvalidatedEventArgs(IEnumerable names) { - this.Names = names.ToArray(); + this.Names = names.ToImmutableHashSet(); } } } -- cgit From e1fc566e0afeb6eb92418bb039365611abd33829 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 25 Mar 2022 21:46:37 -0400 Subject: add content pack labels (#766) --- src/SMAPI/Events/AssetRequestedEventArgs.cs | 30 +++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'src/SMAPI/Events') diff --git a/src/SMAPI/Events/AssetRequestedEventArgs.cs b/src/SMAPI/Events/AssetRequestedEventArgs.cs index b17250b0..774ab808 100644 --- a/src/SMAPI/Events/AssetRequestedEventArgs.cs +++ b/src/SMAPI/Events/AssetRequestedEventArgs.cs @@ -16,6 +16,9 @@ namespace StardewModdingAPI.Events /// The mod handling the event. private readonly IModMetadata Mod; + /// Get the mod metadata for a content pack, if it's a valid content pack for the mod. + private readonly Func GetOnBehalfOf; + /********* ** Accessors @@ -36,14 +39,17 @@ namespace StardewModdingAPI.Events /// Construct an instance. /// The mod handling the event. /// The name of the asset being requested. - internal AssetRequestedEventArgs(IModMetadata mod, IAssetName name) + /// Get the mod metadata for a content pack, if it's a valid content pack for the mod. + internal AssetRequestedEventArgs(IModMetadata mod, IAssetName name, Func getOnBehalfOf) { this.Mod = mod; this.Name = name; + this.GetOnBehalfOf = getOnBehalfOf; } /// Provide the initial instance for the asset, instead of trying to load it from the game's Content folder. /// Get the initial instance of an asset. + /// The content pack ID on whose behalf you're applying the change. This is only valid for content packs for your mod. /// /// Usage notes: /// @@ -51,10 +57,14 @@ namespace StardewModdingAPI.Events /// Each asset can logically only have one initial instance. If multiple loads apply at the same time, SMAPI will raise an error and ignore all of them. If you're making changes to the existing asset instead of replacing it, you should use instead to avoid those limitations and improve mod compatibility. /// /// - public void LoadFrom(Func load) + public void LoadFrom(Func load, string onBehalfOf = null) { this.LoadOperations.Add( - new AssetLoadOperation(this.Mod, _ => load()) + new AssetLoadOperation( + mod: this.Mod, + onBehalfOf: this.GetOnBehalfOf(this.Mod, onBehalfOf, "load assets"), + getData: _ => load() + ) ); } @@ -71,12 +81,16 @@ namespace StardewModdingAPI.Events public void LoadFromModFile(string relativePath) { this.LoadOperations.Add( - new AssetLoadOperation(this.Mod, _ => this.Mod.Mod.Helper.Content.Load(relativePath)) + new AssetLoadOperation( + mod: this.Mod, + onBehalfOf: null, + _ => this.Mod.Mod.Helper.Content.Load(relativePath)) ); } /// Edit the asset after it's loaded. /// Apply changes to the asset. + /// The content pack ID on whose behalf you're applying the change. This is only valid for content packs for your mod. /// /// Usage notes: /// @@ -84,10 +98,14 @@ namespace StardewModdingAPI.Events /// You can apply any number of edits to the asset. Each edit will be applied on top of the previous one (i.e. it'll see the merged asset from all previous edits as its input). /// /// - public void Edit(Action apply) + public void Edit(Action apply, string onBehalfOf = null) { this.EditOperations.Add( - new AssetEditOperation(this.Mod, apply) + new AssetEditOperation( + mod: this.Mod, + onBehalfOf: this.GetOnBehalfOf(this.Mod, onBehalfOf, "edit assets"), + apply + ) ); } } -- cgit From 021891ff0ceb6b327bc196c336aa56ddfaf99b0e Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 25 Mar 2022 22:49:14 -0400 Subject: add load conflict resolution option (#766) --- src/SMAPI/Events/AssetRequestedEventArgs.cs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/SMAPI/Events') diff --git a/src/SMAPI/Events/AssetRequestedEventArgs.cs b/src/SMAPI/Events/AssetRequestedEventArgs.cs index 774ab808..9942079b 100644 --- a/src/SMAPI/Events/AssetRequestedEventArgs.cs +++ b/src/SMAPI/Events/AssetRequestedEventArgs.cs @@ -50,18 +50,20 @@ namespace StardewModdingAPI.Events /// Provide the initial instance for the asset, instead of trying to load it from the game's Content folder. /// Get the initial instance of an asset. /// The content pack ID on whose behalf you're applying the change. This is only valid for content packs for your mod. + /// When there are multiple loads that apply to the same asset, this indicates whether this one can be skipped to resolve the conflict. If all loads allow skipping, the first one that was registered will be applied. If this is false, SMAPI will raise an error and apply none of them. /// /// Usage notes: /// /// The asset doesn't need to exist in the game's Content folder. If any mod loads the asset, the game will see it as an existing asset as if it was in that folder. - /// Each asset can logically only have one initial instance. If multiple loads apply at the same time, SMAPI will raise an error and ignore all of them. If you're making changes to the existing asset instead of replacing it, you should use instead to avoid those limitations and improve mod compatibility. + /// Each asset can logically only have one initial instance. If multiple loads apply at the same time, SMAPI will use the parameter to decide what happens. If you're making changes to the existing asset instead of replacing it, you should use instead to avoid those limitations and improve mod compatibility. /// /// - public void LoadFrom(Func load, string onBehalfOf = null) + public void LoadFrom(Func load, string onBehalfOf = null, bool allowSkipOnConflict = false) { this.LoadOperations.Add( new AssetLoadOperation( mod: this.Mod, + allowSkipOnConflict: allowSkipOnConflict, onBehalfOf: this.GetOnBehalfOf(this.Mod, onBehalfOf, "load assets"), getData: _ => load() ) @@ -71,6 +73,7 @@ namespace StardewModdingAPI.Events /// Provide the initial instance for the asset from a file in your mod folder, instead of trying to load it from the game's Content folder. /// The expected data type. The main supported types are , , dictionaries, and lists; other types may be supported by the game's content pipeline. /// The relative path to the file in your mod folder. + /// When there are multiple loads that apply to the same asset, this indicates whether this one can be skipped to resolve the conflict. If all loads allow skipping, the first one that was registered will be applied. If this is false, SMAPI will raise an error and apply none of them. /// /// Usage notes: /// @@ -78,11 +81,12 @@ namespace StardewModdingAPI.Events /// Each asset can logically only have one initial instance. If multiple loads apply at the same time, SMAPI will raise an error and ignore all of them. If you're making changes to the existing asset instead of replacing it, you should use instead to avoid those limitations and improve mod compatibility. /// /// - public void LoadFromModFile(string relativePath) + public void LoadFromModFile(string relativePath, bool allowSkipOnConflict = false) { this.LoadOperations.Add( new AssetLoadOperation( mod: this.Mod, + allowSkipOnConflict: allowSkipOnConflict, onBehalfOf: null, _ => this.Mod.Mod.Helper.Content.Load(relativePath)) ); -- cgit From 3707f481a567df5149aea00ffb14cddb7b14fccb Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Fri, 25 Mar 2022 23:53:30 -0400 Subject: extend load conflict resolution into load priority (#766) --- src/SMAPI/Events/AssetLoadPriority.cs | 19 +++++++++++++++++++ src/SMAPI/Events/AssetRequestedEventArgs.cs | 14 +++++++------- 2 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 src/SMAPI/Events/AssetLoadPriority.cs (limited to 'src/SMAPI/Events') diff --git a/src/SMAPI/Events/AssetLoadPriority.cs b/src/SMAPI/Events/AssetLoadPriority.cs new file mode 100644 index 00000000..e07b5a40 --- /dev/null +++ b/src/SMAPI/Events/AssetLoadPriority.cs @@ -0,0 +1,19 @@ +namespace StardewModdingAPI.Events +{ + /// The priority for an asset load when multiple apply for the same asset. + /// If multiple non- loads have the same priority, the one registered first will be selected. You can also specify arbitrary intermediate values, like AssetLoadPriority.Low + 5. + public enum AssetLoadPriority + { + /// This load is optional and can safely be skipped if there are higher-priority loads. + Low = -1000, + + /// The load is optional and can safely be skipped if there are higher-priority loads, but it should still be preferred over any -priority loads. + Medium = 0, + + /// The load is optional and can safely be skipped if there are higher-priority loads, but it should still be preferred over any - or -priority loads. + High = 1000, + + /// The load is not optional. If more than one loader has priority, SMAPI will log an error and ignore all of them. + Exclusive = int.MaxValue + } +} diff --git a/src/SMAPI/Events/AssetRequestedEventArgs.cs b/src/SMAPI/Events/AssetRequestedEventArgs.cs index 9942079b..d022a4de 100644 --- a/src/SMAPI/Events/AssetRequestedEventArgs.cs +++ b/src/SMAPI/Events/AssetRequestedEventArgs.cs @@ -49,21 +49,21 @@ namespace StardewModdingAPI.Events /// Provide the initial instance for the asset, instead of trying to load it from the game's Content folder. /// Get the initial instance of an asset. + /// If there are multiple loads that apply to the same asset, the priority with which this one should be applied. /// The content pack ID on whose behalf you're applying the change. This is only valid for content packs for your mod. - /// When there are multiple loads that apply to the same asset, this indicates whether this one can be skipped to resolve the conflict. If all loads allow skipping, the first one that was registered will be applied. If this is false, SMAPI will raise an error and apply none of them. /// /// Usage notes: /// /// The asset doesn't need to exist in the game's Content folder. If any mod loads the asset, the game will see it as an existing asset as if it was in that folder. - /// Each asset can logically only have one initial instance. If multiple loads apply at the same time, SMAPI will use the parameter to decide what happens. If you're making changes to the existing asset instead of replacing it, you should use instead to avoid those limitations and improve mod compatibility. + /// Each asset can logically only have one initial instance. If multiple loads apply at the same time, SMAPI will use the parameter to decide what happens. If you're making changes to the existing asset instead of replacing it, you should use instead to avoid those limitations and improve mod compatibility. /// /// - public void LoadFrom(Func load, string onBehalfOf = null, bool allowSkipOnConflict = false) + public void LoadFrom(Func load, AssetLoadPriority priority, string onBehalfOf = null) { this.LoadOperations.Add( new AssetLoadOperation( mod: this.Mod, - allowSkipOnConflict: allowSkipOnConflict, + priority: priority, onBehalfOf: this.GetOnBehalfOf(this.Mod, onBehalfOf, "load assets"), getData: _ => load() ) @@ -73,7 +73,7 @@ namespace StardewModdingAPI.Events /// Provide the initial instance for the asset from a file in your mod folder, instead of trying to load it from the game's Content folder. /// The expected data type. The main supported types are , , dictionaries, and lists; other types may be supported by the game's content pipeline. /// The relative path to the file in your mod folder. - /// When there are multiple loads that apply to the same asset, this indicates whether this one can be skipped to resolve the conflict. If all loads allow skipping, the first one that was registered will be applied. If this is false, SMAPI will raise an error and apply none of them. + /// If there are multiple loads that apply to the same asset, the priority with which this one should be applied. /// /// Usage notes: /// @@ -81,12 +81,12 @@ namespace StardewModdingAPI.Events /// Each asset can logically only have one initial instance. If multiple loads apply at the same time, SMAPI will raise an error and ignore all of them. If you're making changes to the existing asset instead of replacing it, you should use instead to avoid those limitations and improve mod compatibility. /// /// - public void LoadFromModFile(string relativePath, bool allowSkipOnConflict = false) + public void LoadFromModFile(string relativePath, AssetLoadPriority priority) { this.LoadOperations.Add( new AssetLoadOperation( mod: this.Mod, - allowSkipOnConflict: allowSkipOnConflict, + priority: priority, onBehalfOf: null, _ => this.Mod.Mod.Helper.Content.Load(relativePath)) ); -- cgit From e40907ab8b97bd8a557adf683a406413646b1fc5 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 26 Mar 2022 01:19:44 -0400 Subject: add NameWithoutLocale fields (#766) --- src/SMAPI/Events/AssetReadyEventArgs.cs | 8 +++++++- src/SMAPI/Events/AssetRequestedEventArgs.cs | 8 +++++++- src/SMAPI/Events/AssetsInvalidatedEventArgs.cs | 9 +++++++-- 3 files changed, 21 insertions(+), 4 deletions(-) (limited to 'src/SMAPI/Events') diff --git a/src/SMAPI/Events/AssetReadyEventArgs.cs b/src/SMAPI/Events/AssetReadyEventArgs.cs index 946c9173..2c308f18 100644 --- a/src/SMAPI/Events/AssetReadyEventArgs.cs +++ b/src/SMAPI/Events/AssetReadyEventArgs.cs @@ -11,15 +11,21 @@ namespace StardewModdingAPI.Events /// The name of the asset being requested. public IAssetName Name { get; } + /// The with any locale codes stripped. + /// For example, if contains a locale like Data/Bundles.fr-FR, this will be the name without locale like Data/Bundles. If the name has no locale, this field is equivalent. + public IAssetName NameWithoutLocale { get; } + /********* ** Public methods *********/ /// Construct an instance. /// The name of the asset being requested. - internal AssetReadyEventArgs(IAssetName name) + /// The with any locale codes stripped. + internal AssetReadyEventArgs(IAssetName name, IAssetName nameWithoutLocale) { this.Name = name; + this.NameWithoutLocale = nameWithoutLocale; } } } diff --git a/src/SMAPI/Events/AssetRequestedEventArgs.cs b/src/SMAPI/Events/AssetRequestedEventArgs.cs index d022a4de..9e2cde7f 100644 --- a/src/SMAPI/Events/AssetRequestedEventArgs.cs +++ b/src/SMAPI/Events/AssetRequestedEventArgs.cs @@ -26,6 +26,10 @@ namespace StardewModdingAPI.Events /// The name of the asset being requested. public IAssetName Name { get; } + /// The with any locale codes stripped. + /// For example, if contains a locale like Data/Bundles.fr-FR, this will be the name without locale like Data/Bundles. If the name has no locale, this field is equivalent. + public IAssetName NameWithoutLocale { get; } + /// The load operations requested by the event handler. internal IList LoadOperations { get; } = new List(); @@ -39,11 +43,13 @@ namespace StardewModdingAPI.Events /// Construct an instance. /// The mod handling the event. /// The name of the asset being requested. + /// The with any locale codes stripped. /// Get the mod metadata for a content pack, if it's a valid content pack for the mod. - internal AssetRequestedEventArgs(IModMetadata mod, IAssetName name, Func getOnBehalfOf) + internal AssetRequestedEventArgs(IModMetadata mod, IAssetName name, IAssetName nameWithoutLocale, Func getOnBehalfOf) { this.Mod = mod; this.Name = name; + this.NameWithoutLocale = nameWithoutLocale; this.GetOnBehalfOf = getOnBehalfOf; } diff --git a/src/SMAPI/Events/AssetsInvalidatedEventArgs.cs b/src/SMAPI/Events/AssetsInvalidatedEventArgs.cs index f3d83dd6..614cdf49 100644 --- a/src/SMAPI/Events/AssetsInvalidatedEventArgs.cs +++ b/src/SMAPI/Events/AssetsInvalidatedEventArgs.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Collections.Immutable; -using System.Linq; namespace StardewModdingAPI.Events { @@ -14,15 +13,21 @@ namespace StardewModdingAPI.Events /// The asset names that were invalidated. public IReadOnlySet Names { get; } + /// The with any locale codes stripped. + /// For example, if contains a locale like Data/Bundles.fr-FR, this will have the name without locale like Data/Bundles. If the name has no locale, this field is equivalent. + public IReadOnlySet NamesWithoutLocale { get; } + /********* ** Public methods *********/ /// Construct an instance. /// The asset names that were invalidated. - internal AssetsInvalidatedEventArgs(IEnumerable names) + /// The with any locale codes stripped. + internal AssetsInvalidatedEventArgs(IEnumerable names, IEnumerable namesWithoutLocale) { this.Names = names.ToImmutableHashSet(); + this.NamesWithoutLocale = namesWithoutLocale.ToImmutableHashSet(); } } } -- cgit From ad8912047beaf84ce34f4918703d55841be13ff0 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 26 Mar 2022 01:43:40 -0400 Subject: add asset edit priority (#766) --- src/SMAPI/Events/AssetEditPriority.cs | 16 ++++++++++++++++ src/SMAPI/Events/AssetRequestedEventArgs.cs | 4 +++- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 src/SMAPI/Events/AssetEditPriority.cs (limited to 'src/SMAPI/Events') diff --git a/src/SMAPI/Events/AssetEditPriority.cs b/src/SMAPI/Events/AssetEditPriority.cs new file mode 100644 index 00000000..d41dfd7d --- /dev/null +++ b/src/SMAPI/Events/AssetEditPriority.cs @@ -0,0 +1,16 @@ +namespace StardewModdingAPI.Events +{ + /// The priority for an asset edit when multiple apply for the same asset. + /// You can also specify arbitrary intermediate values, like AssetLoadPriority.Low + 5. + public enum AssetEditPriority + { + /// This edit should be applied before (i.e. 'under') edits. + Early = -1000, + + /// The default priority. + Default = 0, + + /// This edit should be applied after (i.e. 'on top of') edits. + Late = 1000 + } +} diff --git a/src/SMAPI/Events/AssetRequestedEventArgs.cs b/src/SMAPI/Events/AssetRequestedEventArgs.cs index 9e2cde7f..4d9ee236 100644 --- a/src/SMAPI/Events/AssetRequestedEventArgs.cs +++ b/src/SMAPI/Events/AssetRequestedEventArgs.cs @@ -100,6 +100,7 @@ namespace StardewModdingAPI.Events /// Edit the asset after it's loaded. /// Apply changes to the asset. + /// If there are multiple edits that apply to the same asset, the priority with which this one should be applied. /// The content pack ID on whose behalf you're applying the change. This is only valid for content packs for your mod. /// /// Usage notes: @@ -108,11 +109,12 @@ namespace StardewModdingAPI.Events /// You can apply any number of edits to the asset. Each edit will be applied on top of the previous one (i.e. it'll see the merged asset from all previous edits as its input). /// /// - public void Edit(Action apply, string onBehalfOf = null) + public void Edit(Action apply, AssetEditPriority priority = AssetEditPriority.Default, string onBehalfOf = null) { this.EditOperations.Add( new AssetEditOperation( mod: this.Mod, + priority: priority, onBehalfOf: this.GetOnBehalfOf(this.Mod, onBehalfOf, "edit assets"), apply ) -- cgit From 03efea26676464933513383eb1c841f1ca5db34d Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sat, 26 Mar 2022 19:08:25 -0400 Subject: add LocaleChanged content event (#766) --- src/SMAPI/Events/IContentEvents.cs | 4 +++ src/SMAPI/Events/LocaleChangedEventArgs.cs | 45 ++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 src/SMAPI/Events/LocaleChangedEventArgs.cs (limited to 'src/SMAPI/Events') diff --git a/src/SMAPI/Events/IContentEvents.cs b/src/SMAPI/Events/IContentEvents.cs index abbaaf33..d537db70 100644 --- a/src/SMAPI/Events/IContentEvents.cs +++ b/src/SMAPI/Events/IContentEvents.cs @@ -19,5 +19,9 @@ namespace StardewModdingAPI.Events /// Raised after an asset is loaded by the content pipeline, after all mod edits specified via have been applied. /// This event is only raised if something requested the asset from the content pipeline. Invalidating an asset from the content cache won't necessarily reload it automatically. event EventHandler AssetReady; + + /// Raised after the game language changes. + /// For non-English players, this may be raised during startup when the game switches to the previously selected language. + event EventHandler LocaleChanged; } } diff --git a/src/SMAPI/Events/LocaleChangedEventArgs.cs b/src/SMAPI/Events/LocaleChangedEventArgs.cs new file mode 100644 index 00000000..09d3f6e5 --- /dev/null +++ b/src/SMAPI/Events/LocaleChangedEventArgs.cs @@ -0,0 +1,45 @@ +using System; +using LanguageCode = StardewValley.LocalizedContentManager.LanguageCode; + +namespace StardewModdingAPI.Events +{ + /// Event arguments for an event. + public class LocaleChangedEventArgs : EventArgs + { + /********* + ** Accessors + *********/ + /// The previous language enum value. + /// For a custom language, this is always . + public LanguageCode OldLanguage { get; } + + /// The previous locale code. + /// This is the locale code as it appears in asset names, like fr-FR in Maps/springobjects.fr-FR. The locale code for English is an empty string. + public string OldLocale { get; } + + /// The new language enum value. + /// + public LanguageCode NewLanguage { get; } + + /// The new locale code. + /// + public string NewLocale { get; } + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The previous language enum value. + /// The previous locale code. + /// The new language enum value. + /// The new locale code. + internal LocaleChangedEventArgs(LanguageCode oldLanguage, string oldLocale, LanguageCode newLanguage, string newLocale) + { + this.OldLanguage = oldLanguage; + this.OldLocale = oldLocale; + this.NewLanguage = newLanguage; + this.NewLocale = newLocale; + } + } +} -- cgit From d864f2ed775dfd5843b9e1cdd1da96ade5dd1068 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 27 Mar 2022 12:16:28 -0400 Subject: add asset type to AssetRequested event (#766) --- src/SMAPI/Events/AssetRequestedEventArgs.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/SMAPI/Events') diff --git a/src/SMAPI/Events/AssetRequestedEventArgs.cs b/src/SMAPI/Events/AssetRequestedEventArgs.cs index 4d9ee236..c0cbd8fb 100644 --- a/src/SMAPI/Events/AssetRequestedEventArgs.cs +++ b/src/SMAPI/Events/AssetRequestedEventArgs.cs @@ -30,6 +30,9 @@ namespace StardewModdingAPI.Events /// For example, if contains a locale like Data/Bundles.fr-FR, this will be the name without locale like Data/Bundles. If the name has no locale, this field is equivalent. public IAssetName NameWithoutLocale { get; } + /// The requested data type. + public Type DataType { get; } + /// The load operations requested by the event handler. internal IList LoadOperations { get; } = new List(); @@ -43,13 +46,15 @@ namespace StardewModdingAPI.Events /// Construct an instance. /// The mod handling the event. /// The name of the asset being requested. + /// The requested data type. /// The with any locale codes stripped. /// Get the mod metadata for a content pack, if it's a valid content pack for the mod. - internal AssetRequestedEventArgs(IModMetadata mod, IAssetName name, IAssetName nameWithoutLocale, Func getOnBehalfOf) + internal AssetRequestedEventArgs(IModMetadata mod, IAssetName name, IAssetName nameWithoutLocale, Type dataType, Func getOnBehalfOf) { this.Mod = mod; this.Name = name; this.NameWithoutLocale = nameWithoutLocale; + this.DataType = dataType; this.GetOnBehalfOf = getOnBehalfOf; } -- cgit From 2e7c233f6c9bf6430672b39f970a3324deba79dd Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 6 Apr 2022 21:48:55 -0400 Subject: enable nullable annotations by default (#837) This adds `#nullable disable` to all existing code (except where null is impossible like enum files), so it can be migrated incrementally. --- src/SMAPI/Events/AssetReadyEventArgs.cs | 2 ++ src/SMAPI/Events/AssetRequestedEventArgs.cs | 2 ++ src/SMAPI/Events/AssetsInvalidatedEventArgs.cs | 2 ++ src/SMAPI/Events/BuildingListChangedEventArgs.cs | 2 ++ src/SMAPI/Events/ButtonPressedEventArgs.cs | 2 ++ src/SMAPI/Events/ButtonReleasedEventArgs.cs | 2 ++ src/SMAPI/Events/ButtonsChangedEventArgs.cs | 2 ++ src/SMAPI/Events/ChestInventoryChangedEventArgs.cs | 2 ++ src/SMAPI/Events/CursorMovedEventArgs.cs | 2 ++ src/SMAPI/Events/DebrisListChangedEventArgs.cs | 2 ++ src/SMAPI/Events/FurnitureListChangedEventArgs.cs | 2 ++ src/SMAPI/Events/IContentEvents.cs | 2 ++ src/SMAPI/Events/IDisplayEvents.cs | 2 ++ src/SMAPI/Events/IGameLoopEvents.cs | 2 ++ src/SMAPI/Events/IInputEvents.cs | 2 ++ src/SMAPI/Events/IModEvents.cs | 2 ++ src/SMAPI/Events/IMultiplayerEvents.cs | 2 ++ src/SMAPI/Events/IPlayerEvents.cs | 2 ++ src/SMAPI/Events/ISpecialisedEvents.cs | 2 ++ src/SMAPI/Events/IWorldEvents.cs | 2 ++ src/SMAPI/Events/InventoryChangedEventArgs.cs | 2 ++ src/SMAPI/Events/ItemStackSizeChange.cs | 2 ++ src/SMAPI/Events/LargeTerrainFeatureListChangedEventArgs.cs | 2 ++ src/SMAPI/Events/LevelChangedEventArgs.cs | 2 ++ src/SMAPI/Events/LocaleChangedEventArgs.cs | 2 ++ src/SMAPI/Events/LocationListChangedEventArgs.cs | 2 ++ src/SMAPI/Events/MenuChangedEventArgs.cs | 2 ++ src/SMAPI/Events/ModMessageReceivedEventArgs.cs | 2 ++ src/SMAPI/Events/NpcListChangedEventArgs.cs | 2 ++ src/SMAPI/Events/ObjectListChangedEventArgs.cs | 2 ++ src/SMAPI/Events/PeerConnectedEventArgs.cs | 2 ++ src/SMAPI/Events/PeerContextReceivedEventArgs.cs | 2 ++ src/SMAPI/Events/PeerDisconnectedEventArgs.cs | 2 ++ src/SMAPI/Events/RenderedActiveMenuEventArgs.cs | 2 ++ src/SMAPI/Events/RenderedEventArgs.cs | 2 ++ src/SMAPI/Events/RenderedHudEventArgs.cs | 2 ++ src/SMAPI/Events/RenderedWorldEventArgs.cs | 2 ++ src/SMAPI/Events/RenderingActiveMenuEventArgs.cs | 2 ++ src/SMAPI/Events/RenderingEventArgs.cs | 2 ++ src/SMAPI/Events/RenderingHudEventArgs.cs | 2 ++ src/SMAPI/Events/RenderingWorldEventArgs.cs | 2 ++ src/SMAPI/Events/TerrainFeatureListChangedEventArgs.cs | 2 ++ src/SMAPI/Events/WarpedEventArgs.cs | 2 ++ 43 files changed, 86 insertions(+) (limited to 'src/SMAPI/Events') diff --git a/src/SMAPI/Events/AssetReadyEventArgs.cs b/src/SMAPI/Events/AssetReadyEventArgs.cs index 2c308f18..19e5a9df 100644 --- a/src/SMAPI/Events/AssetReadyEventArgs.cs +++ b/src/SMAPI/Events/AssetReadyEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; namespace StardewModdingAPI.Events diff --git a/src/SMAPI/Events/AssetRequestedEventArgs.cs b/src/SMAPI/Events/AssetRequestedEventArgs.cs index c0cbd8fb..82b59290 100644 --- a/src/SMAPI/Events/AssetRequestedEventArgs.cs +++ b/src/SMAPI/Events/AssetRequestedEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using System.Collections.Generic; using Microsoft.Xna.Framework.Graphics; diff --git a/src/SMAPI/Events/AssetsInvalidatedEventArgs.cs b/src/SMAPI/Events/AssetsInvalidatedEventArgs.cs index 614cdf49..bd0df598 100644 --- a/src/SMAPI/Events/AssetsInvalidatedEventArgs.cs +++ b/src/SMAPI/Events/AssetsInvalidatedEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using System.Collections.Generic; using System.Collections.Immutable; diff --git a/src/SMAPI/Events/BuildingListChangedEventArgs.cs b/src/SMAPI/Events/BuildingListChangedEventArgs.cs index 74f37710..ba9574cc 100644 --- a/src/SMAPI/Events/BuildingListChangedEventArgs.cs +++ b/src/SMAPI/Events/BuildingListChangedEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/SMAPI/Events/ButtonPressedEventArgs.cs b/src/SMAPI/Events/ButtonPressedEventArgs.cs index 1b30fd23..94684513 100644 --- a/src/SMAPI/Events/ButtonPressedEventArgs.cs +++ b/src/SMAPI/Events/ButtonPressedEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using StardewModdingAPI.Framework.Input; diff --git a/src/SMAPI/Events/ButtonReleasedEventArgs.cs b/src/SMAPI/Events/ButtonReleasedEventArgs.cs index 40ec1cc1..6ff3727d 100644 --- a/src/SMAPI/Events/ButtonReleasedEventArgs.cs +++ b/src/SMAPI/Events/ButtonReleasedEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using StardewModdingAPI.Framework.Input; diff --git a/src/SMAPI/Events/ButtonsChangedEventArgs.cs b/src/SMAPI/Events/ButtonsChangedEventArgs.cs index a5e87735..c63d34e6 100644 --- a/src/SMAPI/Events/ButtonsChangedEventArgs.cs +++ b/src/SMAPI/Events/ButtonsChangedEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/SMAPI/Events/ChestInventoryChangedEventArgs.cs b/src/SMAPI/Events/ChestInventoryChangedEventArgs.cs index 4b4c4210..bc8ac0c0 100644 --- a/src/SMAPI/Events/ChestInventoryChangedEventArgs.cs +++ b/src/SMAPI/Events/ChestInventoryChangedEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using System.Collections.Generic; using StardewValley; diff --git a/src/SMAPI/Events/CursorMovedEventArgs.cs b/src/SMAPI/Events/CursorMovedEventArgs.cs index 43ff90ce..f3e7513b 100644 --- a/src/SMAPI/Events/CursorMovedEventArgs.cs +++ b/src/SMAPI/Events/CursorMovedEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; namespace StardewModdingAPI.Events diff --git a/src/SMAPI/Events/DebrisListChangedEventArgs.cs b/src/SMAPI/Events/DebrisListChangedEventArgs.cs index 61b7590a..56b1f30a 100644 --- a/src/SMAPI/Events/DebrisListChangedEventArgs.cs +++ b/src/SMAPI/Events/DebrisListChangedEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/SMAPI/Events/FurnitureListChangedEventArgs.cs b/src/SMAPI/Events/FurnitureListChangedEventArgs.cs index 683f4620..cda1b6cc 100644 --- a/src/SMAPI/Events/FurnitureListChangedEventArgs.cs +++ b/src/SMAPI/Events/FurnitureListChangedEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/SMAPI/Events/IContentEvents.cs b/src/SMAPI/Events/IContentEvents.cs index d537db70..109f9753 100644 --- a/src/SMAPI/Events/IContentEvents.cs +++ b/src/SMAPI/Events/IContentEvents.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; namespace StardewModdingAPI.Events diff --git a/src/SMAPI/Events/IDisplayEvents.cs b/src/SMAPI/Events/IDisplayEvents.cs index dbf8d90f..b8b89120 100644 --- a/src/SMAPI/Events/IDisplayEvents.cs +++ b/src/SMAPI/Events/IDisplayEvents.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using StardewValley; diff --git a/src/SMAPI/Events/IGameLoopEvents.cs b/src/SMAPI/Events/IGameLoopEvents.cs index 6855737b..52bac3f8 100644 --- a/src/SMAPI/Events/IGameLoopEvents.cs +++ b/src/SMAPI/Events/IGameLoopEvents.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; namespace StardewModdingAPI.Events diff --git a/src/SMAPI/Events/IInputEvents.cs b/src/SMAPI/Events/IInputEvents.cs index 081c40c0..01ceb224 100644 --- a/src/SMAPI/Events/IInputEvents.cs +++ b/src/SMAPI/Events/IInputEvents.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; namespace StardewModdingAPI.Events diff --git a/src/SMAPI/Events/IModEvents.cs b/src/SMAPI/Events/IModEvents.cs index 2603961b..a1aacbce 100644 --- a/src/SMAPI/Events/IModEvents.cs +++ b/src/SMAPI/Events/IModEvents.cs @@ -1,3 +1,5 @@ +#nullable disable + namespace StardewModdingAPI.Events { /// Manages access to events raised by SMAPI. diff --git a/src/SMAPI/Events/IMultiplayerEvents.cs b/src/SMAPI/Events/IMultiplayerEvents.cs index af9b5f17..c50eaf04 100644 --- a/src/SMAPI/Events/IMultiplayerEvents.cs +++ b/src/SMAPI/Events/IMultiplayerEvents.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; namespace StardewModdingAPI.Events diff --git a/src/SMAPI/Events/IPlayerEvents.cs b/src/SMAPI/Events/IPlayerEvents.cs index 81e17b1a..9d18bfad 100644 --- a/src/SMAPI/Events/IPlayerEvents.cs +++ b/src/SMAPI/Events/IPlayerEvents.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; namespace StardewModdingAPI.Events diff --git a/src/SMAPI/Events/ISpecialisedEvents.cs b/src/SMAPI/Events/ISpecialisedEvents.cs index bf70956d..0ec5bf54 100644 --- a/src/SMAPI/Events/ISpecialisedEvents.cs +++ b/src/SMAPI/Events/ISpecialisedEvents.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; namespace StardewModdingAPI.Events diff --git a/src/SMAPI/Events/IWorldEvents.cs b/src/SMAPI/Events/IWorldEvents.cs index c023e1f0..785dfa8f 100644 --- a/src/SMAPI/Events/IWorldEvents.cs +++ b/src/SMAPI/Events/IWorldEvents.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; namespace StardewModdingAPI.Events diff --git a/src/SMAPI/Events/InventoryChangedEventArgs.cs b/src/SMAPI/Events/InventoryChangedEventArgs.cs index 40cd4128..58c0ff8f 100644 --- a/src/SMAPI/Events/InventoryChangedEventArgs.cs +++ b/src/SMAPI/Events/InventoryChangedEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using System.Collections.Generic; using StardewValley; diff --git a/src/SMAPI/Events/ItemStackSizeChange.cs b/src/SMAPI/Events/ItemStackSizeChange.cs index 35369be2..5d0986aa 100644 --- a/src/SMAPI/Events/ItemStackSizeChange.cs +++ b/src/SMAPI/Events/ItemStackSizeChange.cs @@ -1,3 +1,5 @@ +#nullable disable + using StardewValley; namespace StardewModdingAPI.Events diff --git a/src/SMAPI/Events/LargeTerrainFeatureListChangedEventArgs.cs b/src/SMAPI/Events/LargeTerrainFeatureListChangedEventArgs.cs index 59d79f0f..aedb0e46 100644 --- a/src/SMAPI/Events/LargeTerrainFeatureListChangedEventArgs.cs +++ b/src/SMAPI/Events/LargeTerrainFeatureListChangedEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/SMAPI/Events/LevelChangedEventArgs.cs b/src/SMAPI/Events/LevelChangedEventArgs.cs index c7303603..3beb9fd5 100644 --- a/src/SMAPI/Events/LevelChangedEventArgs.cs +++ b/src/SMAPI/Events/LevelChangedEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using StardewModdingAPI.Enums; using StardewValley; diff --git a/src/SMAPI/Events/LocaleChangedEventArgs.cs b/src/SMAPI/Events/LocaleChangedEventArgs.cs index 09d3f6e5..015e7ec8 100644 --- a/src/SMAPI/Events/LocaleChangedEventArgs.cs +++ b/src/SMAPI/Events/LocaleChangedEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using LanguageCode = StardewValley.LocalizedContentManager.LanguageCode; diff --git a/src/SMAPI/Events/LocationListChangedEventArgs.cs b/src/SMAPI/Events/LocationListChangedEventArgs.cs index 1ebb3e2d..055463dd 100644 --- a/src/SMAPI/Events/LocationListChangedEventArgs.cs +++ b/src/SMAPI/Events/LocationListChangedEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/SMAPI/Events/MenuChangedEventArgs.cs b/src/SMAPI/Events/MenuChangedEventArgs.cs index 977ba38b..362accec 100644 --- a/src/SMAPI/Events/MenuChangedEventArgs.cs +++ b/src/SMAPI/Events/MenuChangedEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using StardewValley.Menus; diff --git a/src/SMAPI/Events/ModMessageReceivedEventArgs.cs b/src/SMAPI/Events/ModMessageReceivedEventArgs.cs index d75a7540..671bdf38 100644 --- a/src/SMAPI/Events/ModMessageReceivedEventArgs.cs +++ b/src/SMAPI/Events/ModMessageReceivedEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using StardewModdingAPI.Framework.Networking; using StardewModdingAPI.Toolkit.Serialization; diff --git a/src/SMAPI/Events/NpcListChangedEventArgs.cs b/src/SMAPI/Events/NpcListChangedEventArgs.cs index 3a37f1e7..fb6dc1c5 100644 --- a/src/SMAPI/Events/NpcListChangedEventArgs.cs +++ b/src/SMAPI/Events/NpcListChangedEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/SMAPI/Events/ObjectListChangedEventArgs.cs b/src/SMAPI/Events/ObjectListChangedEventArgs.cs index b21d2867..b1a636aa 100644 --- a/src/SMAPI/Events/ObjectListChangedEventArgs.cs +++ b/src/SMAPI/Events/ObjectListChangedEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/SMAPI/Events/PeerConnectedEventArgs.cs b/src/SMAPI/Events/PeerConnectedEventArgs.cs index bfaa2bd3..3d11a3b5 100644 --- a/src/SMAPI/Events/PeerConnectedEventArgs.cs +++ b/src/SMAPI/Events/PeerConnectedEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; namespace StardewModdingAPI.Events diff --git a/src/SMAPI/Events/PeerContextReceivedEventArgs.cs b/src/SMAPI/Events/PeerContextReceivedEventArgs.cs index 151a295c..35a4b20d 100644 --- a/src/SMAPI/Events/PeerContextReceivedEventArgs.cs +++ b/src/SMAPI/Events/PeerContextReceivedEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; namespace StardewModdingAPI.Events diff --git a/src/SMAPI/Events/PeerDisconnectedEventArgs.cs b/src/SMAPI/Events/PeerDisconnectedEventArgs.cs index 8517988a..0675b8fe 100644 --- a/src/SMAPI/Events/PeerDisconnectedEventArgs.cs +++ b/src/SMAPI/Events/PeerDisconnectedEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; namespace StardewModdingAPI.Events diff --git a/src/SMAPI/Events/RenderedActiveMenuEventArgs.cs b/src/SMAPI/Events/RenderedActiveMenuEventArgs.cs index efd4163b..3da0b4b4 100644 --- a/src/SMAPI/Events/RenderedActiveMenuEventArgs.cs +++ b/src/SMAPI/Events/RenderedActiveMenuEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using Microsoft.Xna.Framework.Graphics; using StardewValley; diff --git a/src/SMAPI/Events/RenderedEventArgs.cs b/src/SMAPI/Events/RenderedEventArgs.cs index d6341b19..e8beaaac 100644 --- a/src/SMAPI/Events/RenderedEventArgs.cs +++ b/src/SMAPI/Events/RenderedEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using Microsoft.Xna.Framework.Graphics; using StardewValley; diff --git a/src/SMAPI/Events/RenderedHudEventArgs.cs b/src/SMAPI/Events/RenderedHudEventArgs.cs index 46e89013..b25ecd4c 100644 --- a/src/SMAPI/Events/RenderedHudEventArgs.cs +++ b/src/SMAPI/Events/RenderedHudEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using Microsoft.Xna.Framework.Graphics; using StardewValley; diff --git a/src/SMAPI/Events/RenderedWorldEventArgs.cs b/src/SMAPI/Events/RenderedWorldEventArgs.cs index 56145381..a99d6ab3 100644 --- a/src/SMAPI/Events/RenderedWorldEventArgs.cs +++ b/src/SMAPI/Events/RenderedWorldEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using Microsoft.Xna.Framework.Graphics; using StardewValley; diff --git a/src/SMAPI/Events/RenderingActiveMenuEventArgs.cs b/src/SMAPI/Events/RenderingActiveMenuEventArgs.cs index 103f56df..3e3f3258 100644 --- a/src/SMAPI/Events/RenderingActiveMenuEventArgs.cs +++ b/src/SMAPI/Events/RenderingActiveMenuEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using Microsoft.Xna.Framework.Graphics; using StardewValley; diff --git a/src/SMAPI/Events/RenderingEventArgs.cs b/src/SMAPI/Events/RenderingEventArgs.cs index 5acbef09..8f6b3557 100644 --- a/src/SMAPI/Events/RenderingEventArgs.cs +++ b/src/SMAPI/Events/RenderingEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using Microsoft.Xna.Framework.Graphics; using StardewValley; diff --git a/src/SMAPI/Events/RenderingHudEventArgs.cs b/src/SMAPI/Events/RenderingHudEventArgs.cs index 84c96ecd..87269b90 100644 --- a/src/SMAPI/Events/RenderingHudEventArgs.cs +++ b/src/SMAPI/Events/RenderingHudEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using Microsoft.Xna.Framework.Graphics; using StardewValley; diff --git a/src/SMAPI/Events/RenderingWorldEventArgs.cs b/src/SMAPI/Events/RenderingWorldEventArgs.cs index d0d44789..2fc9964f 100644 --- a/src/SMAPI/Events/RenderingWorldEventArgs.cs +++ b/src/SMAPI/Events/RenderingWorldEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using Microsoft.Xna.Framework.Graphics; using StardewValley; diff --git a/src/SMAPI/Events/TerrainFeatureListChangedEventArgs.cs b/src/SMAPI/Events/TerrainFeatureListChangedEventArgs.cs index cdf1e6dc..77a73102 100644 --- a/src/SMAPI/Events/TerrainFeatureListChangedEventArgs.cs +++ b/src/SMAPI/Events/TerrainFeatureListChangedEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using System.Collections.Generic; using System.Linq; diff --git a/src/SMAPI/Events/WarpedEventArgs.cs b/src/SMAPI/Events/WarpedEventArgs.cs index 9afe4a4e..92a8ea77 100644 --- a/src/SMAPI/Events/WarpedEventArgs.cs +++ b/src/SMAPI/Events/WarpedEventArgs.cs @@ -1,3 +1,5 @@ +#nullable disable + using System; using StardewValley; -- cgit From 5ae87fbc01a8829a1a23f90efc25a5dbaada6e68 Mon S