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
|
||||
{
|
||||
[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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<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));
|
||||
context.AddDependency(atlas.textureName);
|
||||
return atlas;
|
||||
return File.ReadAllText(filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,13 +4,14 @@ using System.Text;
|
||||
|
||||
namespace RecrownedAthenaeum.Pipeline.TextureAtlas
|
||||
{
|
||||
[ContentProcessor(DisplayName = "Texture Atlas Processor - RecrownedAthenaeum")]
|
||||
class TextureAtlasProcessor : ContentProcessor<TextureAtlasData, byte[]>
|
||||
[ContentProcessor(DisplayName = "Texture Atlas - RecrownedAthenaeum")]
|
||||
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);
|
||||
return Encoding.UTF8.GetBytes(serialized);
|
||||
TextureAtlasData textureAtlasData = JsonConvert.DeserializeObject<TextureAtlasData>(input);
|
||||
context.AddDependency(textureAtlasData.textureName);
|
||||
return textureAtlasData;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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<byte[]>
|
||||
class TextureAtlasWriter : ContentTypeWriter<TWrite>
|
||||
{
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -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<TextureAtlasData>(Encoding.UTF8.GetString(bytes));
|
||||
string serialized = input.ReadString();
|
||||
TextureAtlasData atlasData = JsonConvert.DeserializeObject<TextureAtlasData>(serialized);
|
||||
|
||||
DataTypes.TextureAtlas atlas;
|
||||
Texture2D atlasTexture = input.ContentManager.Load<Texture2D>(atlasData.textureName);
|
||||
|
Loading…
Reference in New Issue
Block a user