ResourceManager!

This commit is contained in:
2023-06-18 22:16:28 +02:00
parent c0bdb3d4a6
commit 2fb5125ece
9 changed files with 215 additions and 22 deletions

View File

@@ -1,8 +1,15 @@
namespace DaggerFramework;
namespace DaggerFramework.Resources;
public class FontLoader : ResourceLoader<Font>
public class FontLoader : IResourceLoader
{
public override Font Load(string path)
public IEnumerable<string> SupportedExtensions => new string[]
{
".ttf"
};
public Type ResourceType => typeof(Font);
public Resource Load(string path)
{
return default;
}

View File

@@ -0,0 +1,9 @@
namespace DaggerFramework.Resources
{
public interface IResourceLoader
{
public IEnumerable<string> SupportedExtensions { get; }
public Type ResourceType { get; }
public Resource Load(string path);
}
}

View File

@@ -1,8 +0,0 @@
namespace DaggerFramework
{
public abstract class ResourceLoader<T> : IDisposable where T : Resource
{
public void Dispose() { }
public abstract T Load(string path);
}
}

View File

@@ -1,10 +1,17 @@
using StbVorbisSharp;
namespace DaggerFramework
namespace DaggerFramework.Resources
{
public class SoundLoader : ResourceLoader<Sound>
public class SoundLoader : IResourceLoader
{
public override Sound Load(string path)
public IEnumerable<string> SupportedExtensions => new string[]
{
"ogg"
};
public Type ResourceType => typeof(Sound);
public Resource Load(string path)
{
Vorbis vorbis;
Sound result;

View File

@@ -1,10 +1,20 @@
using DaggerFramework.Resources;
using StbImageSharp;
namespace DaggerFramework
{
public class Texture2dLoader : ResourceLoader<Texture2d>
public class Texture2dLoader : IResourceLoader
{
public override Texture2d Load(string path)
public IEnumerable<string> SupportedExtensions => new string[]
{
".png",
".jpg",
".jpeg"
};
public Type ResourceType => typeof(Texture2d);
public Resource Load(string path)
{
ImageResult image;
using (var stream = File.OpenRead(path))
@@ -18,5 +28,10 @@ namespace DaggerFramework
return result;
}
Resource IResourceLoader.Load(string path)
{
throw new NotImplementedException();
}
}
}