summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI/Framework/SContentManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/StardewModdingAPI/Framework/SContentManager.cs')
-rw-r--r--src/StardewModdingAPI/Framework/SContentManager.cs42
1 files changed, 20 insertions, 22 deletions
diff --git a/src/StardewModdingAPI/Framework/SContentManager.cs b/src/StardewModdingAPI/Framework/SContentManager.cs
index e363e6b4..99814c94 100644
--- a/src/StardewModdingAPI/Framework/SContentManager.cs
+++ b/src/StardewModdingAPI/Framework/SContentManager.cs
@@ -83,6 +83,26 @@ namespace StardewModdingAPI.Framework
this.NormaliseAssetNameForPlatform = key => key.Replace('\\', '/'); // based on MonoGame's ContentManager.Load<T> logic
}
+ /// <summary>Normalise an asset name so it's consistent with the underlying cache.</summary>
+ /// <param name="assetName">The asset key.</param>
+ public string NormaliseAssetName(string assetName)
+ {
+ // ensure name format is consistent
+ string[] parts = assetName.Split(SContentManager.PossiblePathSeparators, StringSplitOptions.RemoveEmptyEntries);
+ assetName = string.Join(SContentManager.PreferredPathSeparator, parts);
+
+ // apply platform normalisation logic
+ return this.NormaliseAssetNameForPlatform(assetName);
+ }
+
+ /// <summary>Get whether the content manager has already loaded and cached the given asset.</summary>
+ /// <param name="assetName">The asset path relative to the loader root directory, not including the <c>.xnb</c> extension.</param>
+ public bool IsLoaded(string assetName)
+ {
+ assetName = this.NormaliseAssetName(assetName);
+ return this.IsNormalisedKeyLoaded(assetName);
+ }
+
/// <summary>Load an asset that has been processed by the content pipeline.</summary>
/// <typeparam name="T">The type of asset to load.</typeparam>
/// <param name="assetName">The asset path relative to the loader root directory, not including the <c>.xnb</c> extension.</param>
@@ -116,31 +136,9 @@ namespace StardewModdingAPI.Framework
this.Cache[assetName] = value;
}
- /// <summary>Get whether the content manager has already loaded and cached the given asset.</summary>
- /// <param name="assetName">The asset path relative to the loader root directory, not including the <c>.xnb</c> extension.</param>
- public bool IsLoaded(string assetName)
- {
- assetName = this.NormaliseAssetName(assetName);
- return this.IsNormalisedKeyLoaded(assetName);
-
- }
-
-
/*********
** Private methods
*********/
- /// <summary>Normalise an asset name so it's consistent with the underlying cache.</summary>
- /// <param name="assetName">The asset key.</param>
- private string NormaliseAssetName(string assetName)
- {
- // ensure name format is consistent
- string[] parts = assetName.Split(SContentManager.PossiblePathSeparators, StringSplitOptions.RemoveEmptyEntries);
- assetName = string.Join(SContentManager.PreferredPathSeparator, parts);
-
- // apply platform normalisation logic
- return this.NormaliseAssetNameForPlatform(assetName);
- }
-
/// <summary>Get whether an asset has already been loaded.</summary>
/// <param name="normalisedAssetName">The normalised asset name.</param>
private bool IsNormalisedKeyLoaded(string normalisedAssetName)