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.cs26
1 files changed, 7 insertions, 19 deletions
diff --git a/src/StardewModdingAPI/Framework/SContentManager.cs b/src/StardewModdingAPI/Framework/SContentManager.cs
index 0741d04d..0854c379 100644
--- a/src/StardewModdingAPI/Framework/SContentManager.cs
+++ b/src/StardewModdingAPI/Framework/SContentManager.cs
@@ -8,6 +8,7 @@ using Microsoft.Xna.Framework.Content;
using StardewModdingAPI.AssemblyRewriters;
using StardewModdingAPI.Framework.Content;
using StardewModdingAPI.Framework.Reflection;
+using StardewModdingAPI.Metadata;
using StardewValley;
namespace StardewModdingAPI.Framework
@@ -37,10 +38,10 @@ namespace StardewModdingAPI.Framework
private readonly IPrivateMethod GetKeyLocale;
/// <summary>The language codes used in asset keys.</summary>
- private IDictionary<string, LanguageCode> KeyLocales;
+ private readonly IDictionary<string, LanguageCode> KeyLocales;
- /// <summary>The game's static asset setters by normalised asset name.</summary>
- private readonly IDictionary<string, Action> CoreAssetSetters;
+ /// <summary>Provides metadata for core game assets.</summary>
+ private readonly CoreAssets CoreAssets;
/*********
@@ -89,22 +90,12 @@ namespace StardewModdingAPI.Framework
else
this.NormaliseAssetNameForPlatform = key => key.Replace('\\', '/'); // based on MonoGame's ContentManager.Load<T> logic
- // get asset key locales
+ // get asset data
+ this.CoreAssets = new CoreAssets(this.NormaliseAssetName);
this.KeyLocales = this.GetKeyLocales(reflection);
- this.CoreAssetSetters = this.GetCoreAssetSetters();
}
- /// <summary>Get methods to reload core game assets by normalised key.</summary>
- private IDictionary<string, Action> GetCoreAssetSetters()
- {
- return Constants.GetCoreAssetSetters()
- .ToDictionary<KeyValuePair<string, Action<SContentManager, string>>, string, Action>(
- p => this.NormaliseAssetName(p.Key),
- p => () => p.Value(this, p.Key)
- );
- }
-
/// <summary>Get the locale codes (like <c>ja-JP</c>) used in asset keys.</summary>
/// <param name="reflection">Simplifies access to private game code.</param>
private IDictionary<string, LanguageCode> GetKeyLocales(Reflector reflection)
@@ -246,11 +237,8 @@ namespace StardewModdingAPI.Framework
int reloaded = 0;
foreach (string key in purgeAssetKeys)
{
- if (this.CoreAssetSetters.TryGetValue(key, out Action reloadAsset))
- {
- reloadAsset();
+ if(this.CoreAssets.ReloadForKey(this, key))
reloaded++;
- }
}
// report result