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