summaryrefslogtreecommitdiff
path: root/src/StardewModdingAPI
diff options
context:
space:
mode:
Diffstat (limited to 'src/StardewModdingAPI')
-rw-r--r--src/StardewModdingAPI/Framework/SContentManager.cs17
1 files changed, 16 insertions, 1 deletions
diff --git a/src/StardewModdingAPI/Framework/SContentManager.cs b/src/StardewModdingAPI/Framework/SContentManager.cs
index 27001a06..24237c63 100644
--- a/src/StardewModdingAPI/Framework/SContentManager.cs
+++ b/src/StardewModdingAPI/Framework/SContentManager.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Globalization;
using System.Threading;
using Microsoft.Xna.Framework;
+using StardewModdingAPI.AssemblyRewriters;
using StardewModdingAPI.Framework.Reflection;
using StardewValley;
@@ -49,7 +50,9 @@ namespace StardewModdingAPI.Framework
this.Cache = reflection
.GetPrivateField<Dictionary<string, object>>(this, "loadedAssets")
.GetValue();
- this.NormaliseAssetKey = reflection.GetPrivateMethod(typeof(TitleContainer), "GetCleanPath");
+ this.NormaliseAssetKey = Constants.TargetPlatform == Platform.Windows
+ ? reflection.GetPrivateMethod(typeof(TitleContainer), "GetCleanPath")
+ : reflection.GetPrivateMethod(this, nameof(this.NormaliseKeyForMono));
}
/// <summary>Load an asset that has been processed by the Content Pipeline.</summary>
@@ -57,7 +60,19 @@ namespace StardewModdingAPI.Framework
/// <param name="assetName">The asset path relative to the loader root directory, not including the <c>.xnb</c> extension.</param>
public override T Load<T>(string assetName)
{
+ assetName = this.NormaliseAssetKey.Invoke<string>(assetName);
return base.Load<T>(assetName);
}
+
+
+ /*********
+ ** Private methods
+ *********/
+ /// <summary>Normalise an asset key for Mono.</summary>
+ /// <param name="key">The asset key.</param>
+ private string NormaliseKeyForMono(string key)
+ {
+ return key.Replace('\\', '/'); // based on MonoGame's ContentManager.Load<T> logic
+ }
}
}