Hi all.
Okay, so im trying to extend my Pak system loader class as show below
| public class PContentManager : ContentManager |
| { |
| public string packname; |
| public string packdir; |
| |
| Pak pak = new Pak(); |
| public PContentManager(IServiceProvider serviceProvider) |
| : base(serviceProvider) |
| { |
| } |
| |
| protected override Stream OpenStream(string assetName) |
| { |
| try |
| { |
| pak.OpenPack("Data/" + packname); |
| byte[ data = pak.GetFileData(assetName, packdir); |
| pak.Dispose(); |
| |
| MemoryStream stream = new MemoryStream(data); |
| return stream; |
| } |
| catch (Exception error) |
| { |
| throw new Exception(error.Message); |
| } |
| } |
| } |
So that i can load jpg,png,xml,ect ect ect files directly without having to convert to xnb files first.
This code above can load the xnb files from a pak file, but not non compiled files, and thats what i would like to do without having to make them xnb as temp store on disk ect first.
Something like :
| private PContentManager content; |
| Texture2D tex = content.Load<Texture2D>("demo.jpg"); |
So do i change my PContentManager class and check wich file type im loading, then compile, then return data, or do i have to write a custom override importer for it, or, do i have to write a whole new Texture2D class for it (and same for fonts,models (using XSI mod tool for models)) ect ?
What im going for is : Load Content from Pak (image.jpg for excample) -> Compile on fly in memory -> Return Texture2D (if Texture2D file)
Im like totally lost on where to begin in this.
I was beginning like this (am i on the right track here ?)
| [ContentImporter(new string[ { ".bmp", ".dds", ".dib", ".hdr", ".jpg", ".pfm", ".png", ".ppm", ".tga" }, DisplayName = "Texture - XNA Framework", DefaultProcessor = "SpriteTextureProcessor")] |
| public class Texture2D : ContentImporter<Texture2D> |
| { |
| public override Texture2D Import(string filename, ContentImporterContext context) |
| { |
| try |
| { |
| // All Textures are in Data/Textures |
| Texture2D textureContent = new Texture2D(); |
| |
| |
| |
| |
| // return content |
| return textureContent; |
| } |
| catch (Exception error) |
| { |
| throw (error); |
| } |
| } |
| } |
My guess is, i have to "compile the xnb" just AFTER i loaded the stream in PContentManager, and before i return it, and not in a class like i made above.
Knowledge is power, power corrupts. Study hard, be evil.!