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