removed compression step, added ninepatch stuff to pipeline.
This commit is contained in:
parent
a97cfa0309
commit
5f525fbb9f
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -50,7 +50,10 @@
|
|||||||
<Reference Include="System.Xml" />
|
<Reference Include="System.Xml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Compile Include="NinePatch\NinePatchImporter.cs" />
|
||||||
<Compile Include="NinePatch\NinePatchData.cs" />
|
<Compile Include="NinePatch\NinePatchData.cs" />
|
||||||
|
<Compile Include="NinePatch\NinePatchProcessor.cs" />
|
||||||
|
<Compile Include="NinePatch\NinePatchWriter.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="TextureAtlas\TextureAtlasWriter.cs" />
|
<Compile Include="TextureAtlas\TextureAtlasWriter.cs" />
|
||||||
<Compile Include="TextureAtlas\TextureAtlasImporter.cs" />
|
<Compile Include="TextureAtlas\TextureAtlasImporter.cs" />
|
||||||
|
@ -1,13 +1,6 @@
|
|||||||
using Microsoft.Xna.Framework.Content.Pipeline;
|
using Microsoft.Xna.Framework.Content.Pipeline;
|
||||||
using Microsoft.Xna.Framework.Graphics;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.Xml.Serialization;
|
|
||||||
|
|
||||||
namespace RecrownedAthenaeum.Pipeline.TextureAtlas
|
namespace RecrownedAthenaeum.Pipeline.TextureAtlas
|
||||||
{
|
{
|
||||||
|
@ -18,17 +18,7 @@ namespace RecrownedAthenaeum.Pipeline.TextureAtlas
|
|||||||
public override byte[] Process(TextureAtlasData input, ContentProcessorContext context)
|
public override byte[] Process(TextureAtlasData input, ContentProcessorContext context)
|
||||||
{
|
{
|
||||||
string serialized = JsonConvert.SerializeObject(input);
|
string serialized = JsonConvert.SerializeObject(input);
|
||||||
byte[] bytes = Encoding.UTF8.GetBytes(serialized);
|
return Encoding.UTF8.GetBytes(serialized);
|
||||||
|
|
||||||
using (MemoryStream outStream = new MemoryStream())
|
|
||||||
{
|
|
||||||
using (GZipStream gZipStream = new GZipStream(outStream, CompressionLevel.Optimal))
|
|
||||||
{
|
|
||||||
gZipStream.Write(bytes, 0, bytes.Length);
|
|
||||||
byte[] compressed = outStream.ToArray();
|
|
||||||
return compressed;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
22
RecrownedAthenaeum/Pipeline/NinePatchDataReader.cs
Normal file
22
RecrownedAthenaeum/Pipeline/NinePatchDataReader.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using Microsoft.Xna.Framework.Content;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using RecrownedAthenaeum.DataTypes;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace RecrownedAthenaeum.Pipeline
|
||||||
|
{
|
||||||
|
class NinePatchDataReader : ContentTypeReader<DataTypes.NinePatch>
|
||||||
|
{
|
||||||
|
protected override DataTypes.NinePatch Read(ContentReader input, DataTypes.NinePatch existingInstance)
|
||||||
|
{
|
||||||
|
int length = input.ReadInt32();
|
||||||
|
byte[] bytes = input.ReadBytes(length);
|
||||||
|
|
||||||
|
return JsonConvert.DeserializeObject<DataTypes.NinePatch>(Encoding.UTF8.GetString(bytes));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -19,20 +19,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();
|
int length = input.ReadInt32();
|
||||||
byte[] compressedBytes = input.ReadBytes(length);
|
byte[] bytes = input.ReadBytes(length);
|
||||||
byte[] decompressedBytes;
|
TextureAtlasData atlasData = JsonConvert.DeserializeObject<TextureAtlasData>(Encoding.UTF8.GetString(bytes));
|
||||||
using (MemoryStream inStream = new MemoryStream(compressedBytes))
|
|
||||||
{
|
|
||||||
using (GZipStream gZStream = new GZipStream(inStream, CompressionLevel.Optimal))
|
|
||||||
{
|
|
||||||
using (MemoryStream outStream = new MemoryStream())
|
|
||||||
{
|
|
||||||
gZStream.CopyTo(outStream);
|
|
||||||
decompressedBytes = outStream.ToArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
TextureAtlasData atlasData = JsonConvert.DeserializeObject<TextureAtlasData>(Encoding.UTF8.GetString(decompressedBytes));
|
|
||||||
|
|
||||||
DataTypes.TextureAtlas atlas;
|
DataTypes.TextureAtlas atlas;
|
||||||
Texture2D atlasTexture = input.ContentManager.Load<Texture2D>(atlasData.textureName);
|
Texture2D atlasTexture = input.ContentManager.Load<Texture2D>(atlasData.textureName);
|
||||||
|
@ -63,6 +63,7 @@
|
|||||||
<Compile Include="Input\InputUtilities.cs" />
|
<Compile Include="Input\InputUtilities.cs" />
|
||||||
<Compile Include="ParticleSystem\Particle.cs" />
|
<Compile Include="ParticleSystem\Particle.cs" />
|
||||||
<Compile Include="Persistence\PreferencesManager.cs" />
|
<Compile Include="Persistence\PreferencesManager.cs" />
|
||||||
|
<Compile Include="Pipeline\NinePatchDataReader.cs" />
|
||||||
<Compile Include="Pipeline\TextureAtlasDataReader.cs" />
|
<Compile Include="Pipeline\TextureAtlasDataReader.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="ScreenSystem\ITransition.cs" />
|
<Compile Include="ScreenSystem\ITransition.cs" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user