ResourceManager!
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace DaggerFramework.Resources
|
||||
{
|
||||
public interface IResourceLoader
|
||||
{
|
||||
public IEnumerable<string> SupportedExtensions { get; }
|
||||
public Type ResourceType { get; }
|
||||
public Resource Load(string path);
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace DaggerFramework
|
||||
{
|
||||
public abstract class ResourceLoader<T> : IDisposable where T : Resource
|
||||
{
|
||||
public void Dispose() { }
|
||||
public abstract T Load(string path);
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user