removed compression step, added ninepatch stuff to pipeline.

This commit is contained in:
2018-12-23 11:04:11 -06:00
parent a97cfa0309
commit 5f525fbb9f
9 changed files with 102 additions and 32 deletions

View File

@@ -0,0 +1,26 @@
using Microsoft.Xna.Framework.Content.Pipeline;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RecrownedAthenaeum.Pipeline.NinePatch
{
[ContentImporter(".9p", DisplayName = "Nine Patch Importer")]
internal class NinePatchImporter : ContentImporter<NinePatchData>
{
public override NinePatchData 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;
}
}
}

View File

@@ -0,0 +1,22 @@
using Microsoft.Xna.Framework.Content.Pipeline;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RecrownedAthenaeum.Pipeline.NinePatch
{
[ContentImporter(DisplayName = "Nine Patch Importer")]
class NinePatchProcessor : ContentProcessor<NinePatchData, byte[]>
{
public override byte[] Process(NinePatchData input, ContentProcessorContext context)
{
string serialized = JsonConvert.SerializeObject(input);
return Encoding.UTF8.GetBytes(serialized);
}
}
}

View File

@@ -0,0 +1,25 @@
using Microsoft.Xna.Framework.Content.Pipeline;
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RecrownedAthenaeum.Pipeline.NinePatch
{
[ContentTypeWriter]
class NinePatchWriter : ContentTypeWriter<byte[]>
{
public override string GetRuntimeReader(TargetPlatform targetPlatform)
{
return "RecrownedAthenaeum.Pipeline, NinePatchDataReader";
}
protected override void Write(ContentWriter output, byte[] value)
{
output.Write(value.Length);
output.Write(value);
}
}
}