fixed up pipeline extension process because monogame is weird.

This commit is contained in:
2019-01-13 22:05:34 -06:00
parent 0b812f45fe
commit 4ac011f3cf
8 changed files with 34 additions and 36 deletions

View File

@@ -5,17 +5,11 @@ using System.IO;
namespace RecrownedAthenaeum.Pipeline.NinePatch
{
[ContentImporter(".9p", DisplayName = "Nine Patch Importer", DefaultProcessor = "NinePatchProcessor")]
internal class NinePatchImporter : ContentImporter<NinePatchData>
internal class NinePatchImporter : ContentImporter<string>
{
public override NinePatchData Import(string filename, ContentImporterContext context)
public override string Import(string filename, ContentImporterContext context)
{
NinePatchData data;
using (StreamReader stream = new StreamReader(filename))
{
data = JsonConvert.DeserializeObject<NinePatchData>(stream.ReadToEnd());
}
context.AddDependency(data.textureName);
return data;
return File.ReadAllText(filename);
}
}
}

View File

@@ -4,13 +4,14 @@ using System.Text;
namespace RecrownedAthenaeum.Pipeline.NinePatch
{
[ContentImporter(DisplayName = "Nine Patch Importer - RecrownedAthenaeum")]
class NinePatchProcessor : ContentProcessor<NinePatchData, byte[]>
[ContentImporter(DisplayName = "Nine Patch - RecrownedAthenaeum")]
class NinePatchProcessor : ContentProcessor<string, NinePatchData>
{
public override byte[] Process(NinePatchData input, ContentProcessorContext context)
public override NinePatchData Process(string input, ContentProcessorContext context)
{
string serialized = JsonConvert.SerializeObject(input);
return Encoding.UTF8.GetBytes(serialized);
NinePatchData ninePatchData = JsonConvert.DeserializeObject<NinePatchData>(input);
context.AddDependency(ninePatchData.textureName);
return ninePatchData;
}
}
}

View File

@@ -1,20 +1,20 @@
using Microsoft.Xna.Framework.Content.Pipeline;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
using Newtonsoft.Json;
namespace RecrownedAthenaeum.Pipeline.NinePatch
{
[ContentTypeWriter]
class NinePatchWriter : ContentTypeWriter<byte[]>
class NinePatchWriter : ContentTypeWriter<NinePatchData>
{
public override string GetRuntimeReader(TargetPlatform targetPlatform)
{
return "RecrownedAthenaeum.Pipeline, NinePatchDataReader";
}
protected override void Write(ContentWriter output, byte[] value)
protected override void Write(ContentWriter output, NinePatchData value)
{
output.Write(value.Length);
output.Write(value);
output.Write(JsonConvert.SerializeObject(value));
}
}
}