diff --git a/MLEM.Data/Content/RawJsonReader.cs b/MLEM.Data/Content/JsonReader.cs
similarity index 92%
rename from MLEM.Data/Content/RawJsonReader.cs
rename to MLEM.Data/Content/JsonReader.cs
index dfe9ced..83a0b11 100644
--- a/MLEM.Data/Content/RawJsonReader.cs
+++ b/MLEM.Data/Content/JsonReader.cs
@@ -4,7 +4,7 @@ using Newtonsoft.Json;
namespace MLEM.Data.Content {
///
- public class RawJsonReader : RawContentReader {
+ public class JsonReader : RawContentReader {
///
public override bool CanRead(Type t) {
diff --git a/MLEM.Data/Content/RawContentManager.cs b/MLEM.Data/Content/RawContentManager.cs
index 5bfe04f..c1cbdeb 100644
--- a/MLEM.Data/Content/RawContentManager.cs
+++ b/MLEM.Data/Content/RawContentManager.cs
@@ -49,35 +49,31 @@ namespace MLEM.Data.Content {
return this.Read(assetName, default);
}
- private static RawContentReader GetReader() {
- var reader = Readers.FirstOrDefault(r => r.CanRead(typeof(T)));
- if (reader == null)
- throw new ContentLoadException($"{typeof(T)} has no RawContentReader");
- return reader;
- }
-
///
protected override void ReloadAsset(string originalAssetName, T currentAsset) {
this.Read(originalAssetName, currentAsset);
}
private T Read(string assetName, T existing) {
- var reader = GetReader();
- foreach (var ext in reader.GetFileExtensions()) {
- var file = new FileInfo(Path.Combine(this.RootDirectory, $"{assetName}.{ext}"));
- if (!file.Exists)
- continue;
- using (var stream = file.OpenRead()) {
- var read = reader.Read(this, assetName, stream, typeof(T), existing);
- if (!(read is T t))
- throw new ContentLoadException($"{reader} returned non-{typeof(T)} for asset {assetName}");
- this.LoadedAssets[assetName] = t;
- if (t is IDisposable d && !this.disposableAssets.Contains(d))
- this.disposableAssets.Add(d);
- return t;
+ var triedFiles = new List();
+ foreach (var reader in Readers.Where(r => r.CanRead(typeof(T)))) {
+ foreach (var ext in reader.GetFileExtensions()) {
+ var file = Path.Combine(this.RootDirectory, $"{assetName}.{ext}");
+ triedFiles.Add(file);
+ if (!File.Exists(file))
+ continue;
+ using (var stream = File.OpenRead(file)) {
+ var read = reader.Read(this, assetName, stream, typeof(T), existing);
+ if (!(read is T t))
+ throw new ContentLoadException($"{reader} returned non-{typeof(T)} for asset {assetName}");
+ this.LoadedAssets[assetName] = t;
+ if (t is IDisposable d && !this.disposableAssets.Contains(d))
+ this.disposableAssets.Add(d);
+ return t;
+ }
}
}
- throw new ContentLoadException($"Asset {assetName} not found");
+ throw new ContentLoadException($"Asset {assetName} not found. Tried files {string.Join(", ", triedFiles)}");
}
///