fixed up pipeline extension process because monogame is weird.
This commit is contained in:
parent
0b812f45fe
commit
4ac011f3cf
@ -5,17 +5,11 @@ using System.IO;
|
|||||||
namespace RecrownedAthenaeum.Pipeline.NinePatch
|
namespace RecrownedAthenaeum.Pipeline.NinePatch
|
||||||
{
|
{
|
||||||
[ContentImporter(".9p", DisplayName = "Nine Patch Importer", DefaultProcessor = "NinePatchProcessor")]
|
[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;
|
return File.ReadAllText(filename);
|
||||||
using (StreamReader stream = new StreamReader(filename))
|
|
||||||
{
|
|
||||||
data = JsonConvert.DeserializeObject<NinePatchData>(stream.ReadToEnd());
|
|
||||||
}
|
|
||||||
context.AddDependency(data.textureName);
|
|
||||||
return data;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,13 +4,14 @@ using System.Text;
|
|||||||
|
|
||||||
namespace RecrownedAthenaeum.Pipeline.NinePatch
|
namespace RecrownedAthenaeum.Pipeline.NinePatch
|
||||||
{
|
{
|
||||||
[ContentImporter(DisplayName = "Nine Patch Importer - RecrownedAthenaeum")]
|
[ContentImporter(DisplayName = "Nine Patch - RecrownedAthenaeum")]
|
||||||
class NinePatchProcessor : ContentProcessor<NinePatchData, byte[]>
|
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);
|
NinePatchData ninePatchData = JsonConvert.DeserializeObject<NinePatchData>(input);
|
||||||
return Encoding.UTF8.GetBytes(serialized);
|
context.AddDependency(ninePatchData.textureName);
|
||||||
|
return ninePatchData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
using Microsoft.Xna.Framework.Content.Pipeline;
|
using Microsoft.Xna.Framework.Content.Pipeline;
|
||||||
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
|
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace RecrownedAthenaeum.Pipeline.NinePatch
|
namespace RecrownedAthenaeum.Pipeline.NinePatch
|
||||||
{
|
{
|
||||||
[ContentTypeWriter]
|
[ContentTypeWriter]
|
||||||
class NinePatchWriter : ContentTypeWriter<byte[]>
|
class NinePatchWriter : ContentTypeWriter<NinePatchData>
|
||||||
{
|
{
|
||||||
public override string GetRuntimeReader(TargetPlatform targetPlatform)
|
public override string GetRuntimeReader(TargetPlatform targetPlatform)
|
||||||
{
|
{
|
||||||
return "RecrownedAthenaeum.Pipeline, NinePatchDataReader";
|
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(JsonConvert.SerializeObject(value));
|
||||||
output.Write(value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,16 @@
|
|||||||
using Microsoft.Xna.Framework.Content.Pipeline;
|
using Microsoft.Xna.Framework.Content.Pipeline;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using TImport = System.String;
|
||||||
|
|
||||||
namespace RecrownedAthenaeum.Pipeline.TextureAtlas
|
namespace RecrownedAthenaeum.Pipeline.TextureAtlas
|
||||||
{
|
{
|
||||||
[ContentImporter(".tatlas", DisplayName = "Texture Atlas Importer", DefaultProcessor = "TextureAtlasProcessor")]
|
[ContentImporter(".tatlas", DisplayName = "Texture Atlas Importer", DefaultProcessor = "TextureAtlasProcessor")]
|
||||||
internal class TextureAtlasImporter : ContentImporter<TextureAtlasData>
|
internal class TextureAtlasImporter : ContentImporter<TImport>
|
||||||
{
|
{
|
||||||
public override TextureAtlasData Import(string filename, ContentImporterContext context)
|
public override TImport Import(string filename, ContentImporterContext context)
|
||||||
{
|
{
|
||||||
TextureAtlasData atlas = JsonConvert.DeserializeObject<TextureAtlasData>(File.ReadAllText(filename));
|
return File.ReadAllText(filename);
|
||||||
context.AddDependency(atlas.textureName);
|
|
||||||
return atlas;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,13 +4,14 @@ using System.Text;
|
|||||||
|
|
||||||
namespace RecrownedAthenaeum.Pipeline.TextureAtlas
|
namespace RecrownedAthenaeum.Pipeline.TextureAtlas
|
||||||
{
|
{
|
||||||
[ContentProcessor(DisplayName = "Texture Atlas Processor - RecrownedAthenaeum")]
|
[ContentProcessor(DisplayName = "Texture Atlas - RecrownedAthenaeum")]
|
||||||
class TextureAtlasProcessor : ContentProcessor<TextureAtlasData, byte[]>
|
class TextureAtlasProcessor : ContentProcessor<string, TextureAtlasData>
|
||||||
{
|
{
|
||||||
public override byte[] Process(TextureAtlasData input, ContentProcessorContext context)
|
public override TextureAtlasData Process(string input, ContentProcessorContext context)
|
||||||
{
|
{
|
||||||
string serialized = JsonConvert.SerializeObject(input);
|
TextureAtlasData textureAtlasData = JsonConvert.DeserializeObject<TextureAtlasData>(input);
|
||||||
return Encoding.UTF8.GetBytes(serialized);
|
context.AddDependency(textureAtlasData.textureName);
|
||||||
|
return textureAtlasData;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,22 @@
|
|||||||
using Microsoft.Xna.Framework.Content.Pipeline;
|
using Microsoft.Xna.Framework.Content.Pipeline;
|
||||||
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
|
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System;
|
||||||
|
using TWrite = RecrownedAthenaeum.Pipeline.TextureAtlas.TextureAtlasData;
|
||||||
|
|
||||||
namespace RecrownedAthenaeum.Pipeline.TextureAtlas
|
namespace RecrownedAthenaeum.Pipeline.TextureAtlas
|
||||||
{
|
{
|
||||||
[ContentTypeWriter]
|
[ContentTypeWriter]
|
||||||
class TextureAtlasWriter : ContentTypeWriter<byte[]>
|
class TextureAtlasWriter : ContentTypeWriter<TWrite>
|
||||||
{
|
{
|
||||||
public override string GetRuntimeReader(TargetPlatform targetPlatform)
|
public override string GetRuntimeReader(TargetPlatform targetPlatform)
|
||||||
{
|
{
|
||||||
return "RecrownedAthenaeum.Pipeline, TextureAtlasDataReader";
|
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(JsonConvert.SerializeObject(value));
|
||||||
output.Write(value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,9 +27,11 @@ namespace RecrownedAthenaeum.Tools
|
|||||||
ConsoleUtilities.WriteWrappedLine("Executing as one time use.");
|
ConsoleUtilities.WriteWrappedLine("Executing as one time use.");
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (int i = 0; i < args.Length; i++) sb.Append(args[i] + ' ');
|
for (int i = 0; i < args.Length; i++) sb.Append(args[i] + ' ');
|
||||||
|
string commandAndArgs = sb.ToString().TrimEnd();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
ce.Process(sb.ToString().Trim());
|
ConsoleUtilities.WriteWrappedLine("Command and argument received: " + commandAndArgs);
|
||||||
|
ce.Process(commandAndArgs);
|
||||||
}
|
}
|
||||||
catch (ArgumentException e)
|
catch (ArgumentException e)
|
||||||
{
|
{
|
||||||
|
@ -11,9 +11,8 @@ namespace RecrownedAthenaeum.Pipeline
|
|||||||
{
|
{
|
||||||
protected override DataTypes.TextureAtlas Read(ContentReader input, DataTypes.TextureAtlas existingInstance)
|
protected override DataTypes.TextureAtlas Read(ContentReader input, DataTypes.TextureAtlas existingInstance)
|
||||||
{
|
{
|
||||||
int length = input.ReadInt32();
|
string serialized = input.ReadString();
|
||||||
byte[] bytes = input.ReadBytes(length);
|
TextureAtlasData atlasData = JsonConvert.DeserializeObject<TextureAtlasData>(serialized);
|
||||||
TextureAtlasData atlasData = JsonConvert.DeserializeObject<TextureAtlasData>(Encoding.UTF8.GetString(bytes));
|
|
||||||
|
|
||||||
DataTypes.TextureAtlas atlas;
|
DataTypes.TextureAtlas atlas;
|
||||||
Texture2D atlasTexture = input.ContentManager.Load<Texture2D>(atlasData.textureName);
|
Texture2D atlasTexture = input.ContentManager.Load<Texture2D>(atlasData.textureName);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user