Added setup system. Changed reader and writer for texture atlas and nine patch to have image and serialized data be in same file. Some refactors occurred as well.
This commit is contained in:
@@ -1,14 +1,26 @@
|
||||
using Microsoft.Xna.Framework.Content.Pipeline;
|
||||
using Newtonsoft.Json;
|
||||
using RecrownedAthenaeum.Data;
|
||||
using System.IO;
|
||||
|
||||
namespace RecrownedAthenaeum.Pipeline.NinePatch
|
||||
{
|
||||
[ContentImporter(".9p", DisplayName = "Nine Patch Importer", DefaultProcessor = "NinePatchProcessor")]
|
||||
internal class NinePatchImporter : ContentImporter<string>
|
||||
internal class NinePatchImporter : ContentImporter<NinePatchImporter.Package>
|
||||
{
|
||||
public override string Import(string filename, ContentImporterContext context)
|
||||
public override Package Import(string filename, ContentImporterContext context)
|
||||
{
|
||||
return File.ReadAllText(filename);
|
||||
Package package;
|
||||
package.ninePatchData = JsonConvert.DeserializeObject<NinePatchData>(File.ReadAllText(filename));
|
||||
package.textureBytes = File.ReadAllBytes(package.ninePatchData.textureName);
|
||||
|
||||
return package;
|
||||
}
|
||||
|
||||
internal struct Package
|
||||
{
|
||||
internal byte[] textureBytes;
|
||||
internal NinePatchData ninePatchData;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,17 +1,25 @@
|
||||
using Microsoft.Xna.Framework.Content.Pipeline;
|
||||
using Newtonsoft.Json;
|
||||
using RecrownedAthenaeum.Data;
|
||||
using System.Text;
|
||||
|
||||
namespace RecrownedAthenaeum.Pipeline.NinePatch
|
||||
{
|
||||
[ContentImporter(DisplayName = "Nine Patch - RecrownedAthenaeum")]
|
||||
class NinePatchProcessor : ContentProcessor<string, NinePatchData>
|
||||
class NinePatchProcessor : ContentProcessor<NinePatchImporter.Package, NinePatchProcessor.Package>
|
||||
{
|
||||
public override NinePatchData Process(string input, ContentProcessorContext context)
|
||||
public override Package Process(NinePatchImporter.Package input, ContentProcessorContext context)
|
||||
{
|
||||
NinePatchData ninePatchData = JsonConvert.DeserializeObject<NinePatchData>(input);
|
||||
context.AddDependency(ninePatchData.textureName);
|
||||
return ninePatchData;
|
||||
Package package;
|
||||
package.ninePatchDataBytes = Encoding.ASCII.GetBytes(JsonConvert.SerializeObject(input.ninePatchData));
|
||||
package.textureBytes = input.textureBytes;
|
||||
return package;
|
||||
}
|
||||
|
||||
internal struct Package
|
||||
{
|
||||
internal byte[] ninePatchDataBytes;
|
||||
internal byte[] textureBytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -6,16 +6,19 @@ using RecrownedAthenaeum.Data;
|
||||
namespace RecrownedAthenaeum.Pipeline.NinePatch
|
||||
{
|
||||
[ContentTypeWriter]
|
||||
class NinePatchWriter : ContentTypeWriter<NinePatchData>
|
||||
class NinePatchWriter : ContentTypeWriter<NinePatchProcessor.Package>
|
||||
{
|
||||
public override string GetRuntimeReader(TargetPlatform targetPlatform)
|
||||
{
|
||||
return "RecrownedAthenaeum.ContentReaders.NinePatchDataReader, RecrownedAthenaeum";
|
||||
}
|
||||
|
||||
protected override void Write(ContentWriter output, NinePatchData value)
|
||||
protected override void Write(ContentWriter output, NinePatchProcessor.Package value)
|
||||
{
|
||||
output.Write(JsonConvert.SerializeObject(value));
|
||||
output.Write(value.textureBytes.Length);
|
||||
output.Write(value.textureBytes);
|
||||
output.Write(value.ninePatchDataBytes.Length);
|
||||
output.Write(value.ninePatchDataBytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,15 +1,25 @@
|
||||
using Microsoft.Xna.Framework.Content.Pipeline;
|
||||
using Newtonsoft.Json;
|
||||
using RecrownedAthenaeum.Data;
|
||||
using System.IO;
|
||||
using TImport = System.String;
|
||||
|
||||
namespace RecrownedAthenaeum.Pipeline.TextureAtlas
|
||||
{
|
||||
[ContentImporter(".tatlas", DisplayName = "Texture Atlas Importer", DefaultProcessor = "TextureAtlasProcessor")]
|
||||
internal class TextureAtlasImporter : ContentImporter<TImport>
|
||||
internal class TextureAtlasImporter : ContentImporter<TextureAtlasImporter.Package>
|
||||
{
|
||||
public override TImport Import(string filename, ContentImporterContext context)
|
||||
public override Package Import(string filename, ContentImporterContext context)
|
||||
{
|
||||
return File.ReadAllText(filename);
|
||||
Package package;
|
||||
package.textureAtlasData = JsonConvert.DeserializeObject<TextureAtlasData>(File.ReadAllText(filename));
|
||||
package.textureBytes = File.ReadAllBytes(package.textureAtlasData.textureName);
|
||||
return package;
|
||||
}
|
||||
|
||||
internal struct Package
|
||||
{
|
||||
internal TextureAtlasData textureAtlasData;
|
||||
internal byte[] textureBytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,17 +1,24 @@
|
||||
using Microsoft.Xna.Framework.Content.Pipeline;
|
||||
using Newtonsoft.Json;
|
||||
using RecrownedAthenaeum.Data;
|
||||
using System.Text;
|
||||
|
||||
namespace RecrownedAthenaeum.Pipeline.TextureAtlas
|
||||
{
|
||||
[ContentProcessor(DisplayName = "Texture Atlas - RecrownedAthenaeum")]
|
||||
class TextureAtlasProcessor : ContentProcessor<string, TextureAtlasData>
|
||||
class TextureAtlasProcessor : ContentProcessor<TextureAtlasImporter.Package, TextureAtlasProcessor.Package>
|
||||
{
|
||||
public override TextureAtlasData Process(string input, ContentProcessorContext context)
|
||||
public override Package Process(TextureAtlasImporter.Package input, ContentProcessorContext context)
|
||||
{
|
||||
TextureAtlasData textureAtlasData = JsonConvert.DeserializeObject<TextureAtlasData>(input);
|
||||
context.AddDependency(textureAtlasData.textureName);
|
||||
return textureAtlasData;
|
||||
Package package;
|
||||
package.textureBytes = input.textureBytes;
|
||||
package.textureAtlasDataBytes = Encoding.ASCII.GetBytes(JsonConvert.SerializeObject(input.textureAtlasData));
|
||||
return package;
|
||||
}
|
||||
|
||||
internal struct Package
|
||||
{
|
||||
public byte[] textureBytes;
|
||||
public byte[] textureAtlasDataBytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,21 +1,22 @@
|
||||
using Microsoft.Xna.Framework.Content.Pipeline;
|
||||
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Compiler;
|
||||
using Newtonsoft.Json;
|
||||
using RecrownedAthenaeum.Data;
|
||||
|
||||
namespace RecrownedAthenaeum.Pipeline.TextureAtlas
|
||||
{
|
||||
[ContentTypeWriter]
|
||||
class TextureAtlasWriter : ContentTypeWriter<TextureAtlasData>
|
||||
class TextureAtlasWriter : ContentTypeWriter<TextureAtlasProcessor.Package>
|
||||
{
|
||||
public override string GetRuntimeReader(TargetPlatform targetPlatform)
|
||||
{
|
||||
return "RecrownedAthenaeum.ContentReaders.TextureAtlasDataReader, RecrownedAthenaeum";
|
||||
}
|
||||
|
||||
protected override void Write(ContentWriter output, TextureAtlasData value)
|
||||
protected override void Write(ContentWriter output, TextureAtlasProcessor.Package value)
|
||||
{
|
||||
output.Write(JsonConvert.SerializeObject(value));
|
||||
output.Write(value.textureBytes.Length);
|
||||
output.Write(value.textureBytes);
|
||||
output.Write(value.textureAtlasDataBytes.Length);
|
||||
output.Write(value.textureAtlasDataBytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user