cleanup; update ninepatch reader to work with pipeline changes made a while back; fixed extension issue for atlas reader.
This commit is contained in:
parent
60bef9a88a
commit
fbf6c5d1aa
@ -1,6 +1,5 @@
|
|||||||
using Microsoft.Xna.Framework.Content;
|
using Microsoft.Xna.Framework.Content;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
namespace RecrownedAthenaeum.ContentReaders
|
namespace RecrownedAthenaeum.ContentReaders
|
||||||
{
|
{
|
||||||
@ -8,10 +7,9 @@ namespace RecrownedAthenaeum.ContentReaders
|
|||||||
{
|
{
|
||||||
protected override SpecialTypes.NinePatch Read(ContentReader input, SpecialTypes.NinePatch existingInstance)
|
protected override SpecialTypes.NinePatch Read(ContentReader input, SpecialTypes.NinePatch existingInstance)
|
||||||
{
|
{
|
||||||
int length = input.ReadInt32();
|
string serialized = input.ReadString();
|
||||||
byte[] bytes = input.ReadBytes(length);
|
|
||||||
|
|
||||||
return JsonConvert.DeserializeObject<SpecialTypes.NinePatch>(Encoding.UTF8.GetString(bytes));
|
return JsonConvert.DeserializeObject<SpecialTypes.NinePatch>(serialized);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ using Microsoft.Xna.Framework.Graphics;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using RecrownedAthenaeum.Data;
|
using RecrownedAthenaeum.Data;
|
||||||
using RecrownedAthenaeum.SpecialTypes;
|
using RecrownedAthenaeum.SpecialTypes;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace RecrownedAthenaeum.ContentReaders
|
namespace RecrownedAthenaeum.ContentReaders
|
||||||
{
|
{
|
||||||
@ -12,12 +13,18 @@ namespace RecrownedAthenaeum.ContentReaders
|
|||||||
{
|
{
|
||||||
string serialized = input.ReadString();
|
string serialized = input.ReadString();
|
||||||
TextureAtlasData atlasData = JsonConvert.DeserializeObject<TextureAtlasData>(serialized);
|
TextureAtlasData atlasData = JsonConvert.DeserializeObject<TextureAtlasData>(serialized);
|
||||||
Texture2D atlasTexture = input.ContentManager.Load<Texture2D>(atlasData.textureName);
|
Texture2D atlasTexture = input.ContentManager.Load<Texture2D>(Path.GetFileNameWithoutExtension(atlasData.textureName));
|
||||||
TextureAtlas atlas = new TextureAtlas(atlasTexture, GenerateAtlasRegionsFromData(atlasData, atlasTexture));
|
TextureAtlas atlas = new TextureAtlas(atlasTexture, GenerateAtlasRegionsFromData(atlasData, atlasTexture));
|
||||||
|
|
||||||
return atlas;
|
return atlas;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Generates region given <see cref="TextureAtlasData"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="textureAtlasData">The data to generate the regions from.</param>
|
||||||
|
/// <param name="atlasTexture">The texture containing the atlas.</param>
|
||||||
|
/// <returns>An array of regions.</returns>
|
||||||
public TextureAtlas.Region[] GenerateAtlasRegionsFromData(TextureAtlasData textureAtlasData, Texture2D atlasTexture)
|
public TextureAtlas.Region[] GenerateAtlasRegionsFromData(TextureAtlasData textureAtlasData, Texture2D atlasTexture)
|
||||||
{
|
{
|
||||||
TextureAtlas.Region[] regions = new TextureAtlas.Region[textureAtlasData.regions.Length];
|
TextureAtlas.Region[] regions = new TextureAtlas.Region[textureAtlasData.regions.Length];
|
||||||
|
@ -4,7 +4,6 @@ using RecrownedAthenaeum.SpecialTypes;
|
|||||||
using RecrownedAthenaeum.UI.Skin.Definitions;
|
using RecrownedAthenaeum.UI.Skin.Definitions;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace RecrownedAthenaeum.UI.Skin
|
namespace RecrownedAthenaeum.UI.Skin
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user