26 lines
1.0 KiB
C#
26 lines
1.0 KiB
C#
using Microsoft.Xna.Framework.Content;
|
|
using Microsoft.Xna.Framework.Graphics;
|
|
using Newtonsoft.Json;
|
|
using RecrownedAthenaeum.Data;
|
|
using RecrownedAthenaeum.SpecialTypes;
|
|
using System.IO;
|
|
using System.Text;
|
|
|
|
namespace RecrownedAthenaeum.ContentReaders
|
|
{
|
|
class NinePatchDataReader : ContentTypeReader<NinePatch>
|
|
{
|
|
protected override NinePatch Read(ContentReader input, NinePatch existingInstance)
|
|
{
|
|
Texture2D texture;
|
|
using (MemoryStream stream = new MemoryStream(input.ReadBytes(input.ReadInt32())))
|
|
{
|
|
texture = Texture2D.FromStream(Configuration.GraphicsDeviceManager.GraphicsDevice, stream);
|
|
}
|
|
NinePatchData ninePatchData = JsonConvert.DeserializeObject<NinePatchData>(Encoding.ASCII.GetString(input.ReadBytes(input.ReadInt32())));
|
|
NinePatch ninePatch = new NinePatch(texture, ninePatchData.left, ninePatchData.right, ninePatchData.bottom, ninePatchData.top);
|
|
return ninePatch;
|
|
}
|
|
}
|
|
}
|