diff --git a/source/Directory.Build.props b/source/Directory.Build.props
index b572e0479..8df9eb209 100644
--- a/source/Directory.Build.props
+++ b/source/Directory.Build.props
@@ -18,8 +18,8 @@
-
-
+
+
DisposeableAssets
}
}
+
+#if KNI || FNA
+ private Dictionary _loadedAssets;
+ public Dictionary LoadedAssets
+ {
+ get
+ {
+ if(_loadedAssets is null)
+ {
+ // KNI please make this public so I don't have to use reflection
+ FieldInfo field = typeof(ContentManager).GetField(nameof(_loadedAssets), BindingFlags.NonPublic | BindingFlags.Instance);
+ if (field is null)
+ {
+ throw new InvalidOperationException("Unable to get source loaded assets field");
+ }
+ _loadedAssets = field.GetValue(this) as Dictionary;
+ }
+
+ return _loadedAssets;
+ }
+ }
+#endif
+
public ExtendedContentManager(IServiceProvider serviceProvider) : base(serviceProvider)
{
_graphicsDeviceService = serviceProvider.GetService(typeof(IGraphicsDeviceService)) as IGraphicsDeviceService;
@@ -51,7 +74,40 @@ public ExtendedContentManager(IServiceProvider serviceProvider, string rootDirec
{
_graphicsDeviceService = serviceProvider.GetService(typeof(IGraphicsDeviceService)) as IGraphicsDeviceService;
}
+
+#if KNI || FNA
+ ///
+ /// Loads a asset.
+ ///
+ ///
+ /// If the parameter is a relative path, it must be relative to the
+ /// path.
+ ///
+ /// The path to the asset to load
+ ///
+ /// Specifies whether the color data of the texture should be premultiplied by its alpha value.
+ ///
+ ///
+ public Texture2D LoadTexture2D(string path)
+ {
+ if (TryGetCachedAsset(path, out Texture2D texture))
+ {
+ return texture;
+ }
+
+ if (NoExtension(path))
+ {
+ return Load(path);
+ }
+
+ using Stream stream = GetStream(path);
+ texture = Texture2D.FromStream(_graphicsDeviceService.GraphicsDevice, stream);
+ texture.Name = path;
+ CacheAsset(path, texture);
+ return texture;
+ }
+#else
///
/// Loads a asset.
///
@@ -95,6 +151,7 @@ public Texture2D LoadTexture2D(string path, bool premultiplyAlpha)
CacheAsset(path, texture);
return texture;
}
+#endif
///
/// Loads a asset.
@@ -178,11 +235,18 @@ public BitmapFont LoadBitmapFont(string path)
/// Loads a from a TexturePacker JSON file.
///
/// The path to the TexturePacker JSON file
+
+#if !KNI && !FNA
///
/// Specifies whether the color data of the texture should be premultiplied by its alpha value.
///
+#endif
/// The created from the TexturePacker JSON file content.
+#if KNI || FNA
+ public Texture2DAtlas LoadTexturePacker(string path)
+#else
public Texture2DAtlas LoadTexturePacker(string path, bool premultiplyAlpha)
+#endif
{
if (TryGetCachedAsset(path, out var atlas))
{
@@ -199,8 +263,12 @@ public Texture2DAtlas LoadTexturePacker(string path, bool premultiplyAlpha)
var tpFile = TexturePackerFileReader.Read(stream);
var dir = Path.GetDirectoryName(path);
var imageAssetPath = Path.Combine(dir, tpFile.Meta.Image);
- var texture = LoadTexture2D(imageAssetPath, premultiplyAlpha);
+#if KNI || FNA
+ var texture = LoadTexture2D(imageAssetPath);
+#else
+ var texture = LoadTexture2D(imageAssetPath, premultiplyAlpha);
+#endif
atlas = new Texture2DAtlas(Path.GetFileNameWithoutExtension(tpFile.Meta.Image), texture);
foreach(var region in tpFile.Regions)
diff --git a/source/MonoGame.Extended/KNI.Extended.csproj b/source/MonoGame.Extended/KNI.Extended.csproj
index 5278f109c..2c68ed8ce 100644
--- a/source/MonoGame.Extended/KNI.Extended.csproj
+++ b/source/MonoGame.Extended/KNI.Extended.csproj
@@ -15,6 +15,8 @@
<_Parameter1>Kni.Extended.Content.Pipeline
-
+
+
+
diff --git a/tests/MonoGame.Extended.Tests/FNA.Extended.Tests.csproj b/tests/MonoGame.Extended.Tests/FNA.Extended.Tests.csproj
index 21424fc23..6d051b294 100644
--- a/tests/MonoGame.Extended.Tests/FNA.Extended.Tests.csproj
+++ b/tests/MonoGame.Extended.Tests/FNA.Extended.Tests.csproj
@@ -6,7 +6,6 @@
-