recrownedgtk/RecrownedAthenaeum.Pipeline/TextureAtlas/TextureAtlasImporter.cs

26 lines
919 B
C#

using Microsoft.Xna.Framework.Content.Pipeline;
using Newtonsoft.Json;
using RecrownedAthenaeum.Data;
using System.IO;
namespace RecrownedAthenaeum.Pipeline.TextureAtlas
{
[ContentImporter(".tatlas", DisplayName = "Texture Atlas Importer", DefaultProcessor = "TextureAtlasProcessor")]
internal class TextureAtlasImporter : ContentImporter<TextureAtlasImporter.Package>
{
public override Package Import(string filename, ContentImporterContext context)
{
Package package;
package.textureAtlasData = JsonConvert.DeserializeObject<TextureAtlasData>(File.ReadAllText(filename));
package.textureBytes = File.ReadAllBytes(package.textureAtlasData.textureName);
return package;
}
internal struct Package
{
internal TextureAtlasData textureAtlasData;
internal byte[] textureBytes;
}
}
}