fixed up pipeline extension process because monogame is weird.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user