diff --git a/RecrownedAthenaeum.Pipeline/NinePatch/NinePatchImporter.cs b/RecrownedAthenaeum.Pipeline/NinePatch/NinePatchImporter.cs index bb353c5..c1a9ef2 100644 --- a/RecrownedAthenaeum.Pipeline/NinePatch/NinePatchImporter.cs +++ b/RecrownedAthenaeum.Pipeline/NinePatch/NinePatchImporter.cs @@ -5,17 +5,11 @@ using System.IO; namespace RecrownedAthenaeum.Pipeline.NinePatch { [ContentImporter(".9p", DisplayName = "Nine Patch Importer", DefaultProcessor = "NinePatchProcessor")] - internal class NinePatchImporter : ContentImporter + internal class NinePatchImporter : ContentImporter { - 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(stream.ReadToEnd()); - } - context.AddDependency(data.textureName); - return data; + return File.ReadAllText(filename); } } } diff --git a/RecrownedAthenaeum.Pipeline/NinePatch/NinePatchProcessor.cs b/RecrownedAthenaeum.Pipeline/NinePatch/NinePatchProcessor.cs index 9ce9466..cc6aec6 100644 --- a/RecrownedAthenaeum.Pipeline/NinePatch/NinePatchProcessor.cs +++ b/RecrownedAthenaeum.Pipeline/NinePatch/NinePatchProcessor.cs @@ -4,13 +4,14 @@ using System.Text; namespace RecrownedAthenaeum.Pipeline.NinePatch { - [ContentImporter(DisplayName = "Nine Patch Importer - RecrownedAthenaeum")] - class NinePatchProcessor : ContentProcessor + [ContentImporter(DisplayName = "Nine Patch - RecrownedAthenaeum")] + class NinePatchProcessor : ContentProcessor { - 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(input); + context.AddDependency(ninePatchData.textureName); + return ninePatchData; } } } diff --git a/RecrownedAthenaeum.Pipeline/NinePatch/NinePatchWriter.cs b/RecrownedAthenaeum.Pipeline/NinePatch/NinePatchWriter.cs index 3266ee6..853155c 100644 --- a/RecrownedAthenaeum.Pipeline/NinePatch/NinePatchWriter.cs +++ b/RecrownedAthenaeum.Pipeline/NinePatch/NinePatchWriter.cs @@ -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 + class NinePatchWriter : ContentTypeWriter { 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)); } } } diff --git a/RecrownedAthenaeum.Pipeline/TextureAtlas/TextureAtlasImporter.cs b/RecrownedAthenaeum.Pipeline/TextureAtlas/TextureAtlasImporter.cs index d224fdd..19d7135 100644 --- a/RecrownedAthenaeum.Pipeline/TextureAtlas/TextureAtlasImporter.cs +++ b/RecrownedAthenaeum.Pipeline/TextureAtlas/TextureAtlasImporter.cs @@ -1,17 +1,16 @@ using Microsoft.Xna.Framework.Content.Pipeline; using Newtonsoft.Json; using System.IO; +using TImport = System.String; namespace RecrownedAthenaeum.Pipeline.TextureAtlas { [ContentImporter(".tatlas", DisplayName = "Texture Atlas Importer", DefaultProcessor = "TextureAtlasProcessor")] - internal class TextureAtlasImporter : ContentImporter + internal class TextureAtlasImporter : ContentImporter { - public override TextureAtlasData Import(string filename, ContentImporterContext context) + public override TImport Import(string filename, ContentImporterContext context) { - TextureAtlasData atlas = JsonConvert.DeserializeObject(File.ReadAllText(filename)); - context.AddDependency(atlas.textureName); - return atlas; + return File.ReadAllText(filename); } } } diff --git a/RecrownedAthenaeum.Pipeline/TextureAtlas/TextureAtlasProcessor.cs b/RecrownedAthenaeum.Pipeline/TextureAtlas/TextureAtlasProcessor.cs index df515af..fa61b19 100644 --- a/RecrownedAthenaeum.Pipeline/TextureAtlas/TextureAtlasProcessor.cs +++ b/RecrownedAthenaeum.Pipeline/TextureAtlas/TextureAtlasProcessor.cs @@ -4,13 +4,14 @@ using System.Text; namespace RecrownedAthenaeum.Pipeline.TextureAtlas { - [ContentProcessor(DisplayName = "Texture Atlas Processor - RecrownedAthenaeum")] - class TextureAtlasProcessor : ContentProcessor + [ContentProcessor(DisplayName = "Texture Atlas - RecrownedAthenaeum")] + class TextureAtlasProcessor : ContentProcessor { - public override byte[] Process(TextureAtlasData input, ContentProcessorContext context) + public override TextureAtlasData Process(string input, ContentProcessorContext context) { - string serialized = JsonConvert.SerializeObject(input); - return Encoding.UTF8.GetBytes(serialized); + TextureAtlasData textureAtlasData = JsonConvert.DeserializeObject(input); + context.AddDependency(textureAtlasData.textureName); + return textureAtlasData; } } } diff --git a/RecrownedAthenaeum.Pipeline/TextureAtlas/TextureAtlasWriter.cs b/RecrownedAthenaeum.Pipeline/TextureAtlas/TextureAtlasWriter.cs index 9f8a904..d1fd5b5 100644 --- a/RecrownedAthenaeum.Pipeline/TextureAtlas/TextureAtlasWriter.cs +++ b/RecrownedAthenaeum.Pipeline/TextureAtlas/TextureAtlasWriter.cs @@ -1,20 +1,22 @@ using Microsoft.Xna.Framework.Content.Pipeline; using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler; +using Newtonsoft.Json; +using System; +using TWrite = RecrownedAthenaeum.Pipeline.TextureAtlas.TextureAtlasData; namespace RecrownedAthenaeum.Pipeline.TextureAtlas { [ContentTypeWriter] - class TextureAtlasWriter : ContentTypeWriter + class TextureAtlasWriter : ContentTypeWriter { public override string GetRuntimeReader(TargetPlatform targetPlatform) { return "RecrownedAthenaeum.Pipeline, TextureAtlasDataReader"; } - protected override void Write(ContentWriter output, byte[] value) + protected override void Write(ContentWriter output, TWrite value) { - output.Write(value.Length); - output.Write(value); + output.Write(JsonConvert.SerializeObject(value)); } } } diff --git a/RecrownedAthenaeum.Tools/Tools.cs b/RecrownedAthenaeum.Tools/Tools.cs index 1cb8e50..18240f1 100644 --- a/RecrownedAthenaeum.Tools/Tools.cs +++ b/RecrownedAthenaeum.Tools/Tools.cs @@ -27,9 +27,11 @@ namespace RecrownedAthenaeum.Tools ConsoleUtilities.WriteWrappedLine("Executing as one time use."); StringBuilder sb = new StringBuilder(); for (int i = 0; i < args.Length; i++) sb.Append(args[i] + ' '); + string commandAndArgs = sb.ToString().TrimEnd(); try { - ce.Process(sb.ToString().Trim()); + ConsoleUtilities.WriteWrappedLine("Command and argument received: " + commandAndArgs); + ce.Process(commandAndArgs); } catch (ArgumentException e) { diff --git a/RecrownedAthenaeum/Pipeline/TextureAtlasDataReader.cs b/RecrownedAthenaeum/Pipeline/TextureAtlasDataReader.cs index 29235ca..cf0abc0 100644 --- a/RecrownedAthenaeum/Pipeline/TextureAtlasDataReader.cs +++ b/RecrownedAthenaeum/Pipeline/TextureAtlasDataReader.cs @@ -11,9 +11,8 @@ namespace RecrownedAthenaeum.Pipeline { protected override DataTypes.TextureAtlas Read(ContentReader input, DataTypes.TextureAtlas existingInstance) { - int length = input.ReadInt32(); - byte[] bytes = input.ReadBytes(length); - TextureAtlasData atlasData = JsonConvert.DeserializeObject(Encoding.UTF8.GetString(bytes)); + string serialized = input.ReadString(); + TextureAtlasData atlasData = JsonConvert.DeserializeObject(serialized); DataTypes.TextureAtlas atlas; Texture2D atlasTexture = input.ContentManager.Load(atlasData.textureName);