removed compression step, added ninepatch stuff to pipeline.
This commit is contained in:
26
RecrownedAthenaeum.Pipeline/NinePatch/NinePatchImporter.cs
Normal file
26
RecrownedAthenaeum.Pipeline/NinePatch/NinePatchImporter.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
22
RecrownedAthenaeum.Pipeline/NinePatch/NinePatchProcessor.cs
Normal file
22
RecrownedAthenaeum.Pipeline/NinePatch/NinePatchProcessor.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
25
RecrownedAthenaeum.Pipeline/NinePatch/NinePatchWriter.cs
Normal file
25
RecrownedAthenaeum.Pipeline/NinePatch/NinePatchWriter.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user