From fbf6c5d1aae18cbf13f25c9ecc2120f2555bbc73 Mon Sep 17 00:00:00 2001 From: Harrison Deng Date: Sun, 20 Jan 2019 23:06:56 -0600 Subject: [PATCH] cleanup; update ninepatch reader to work with pipeline changes made a while back; fixed extension issue for atlas reader. --- RecrownedAthenaeum/ContentReaders/NinePatchDataReader.cs | 6 ++---- .../ContentReaders/TextureAtlasDataReader.cs | 9 ++++++++- RecrownedAthenaeum/UI/Skin/Skin.cs | 1 - 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/RecrownedAthenaeum/ContentReaders/NinePatchDataReader.cs b/RecrownedAthenaeum/ContentReaders/NinePatchDataReader.cs index b036afb..7b7c244 100644 --- a/RecrownedAthenaeum/ContentReaders/NinePatchDataReader.cs +++ b/RecrownedAthenaeum/ContentReaders/NinePatchDataReader.cs @@ -1,6 +1,5 @@ using Microsoft.Xna.Framework.Content; using Newtonsoft.Json; -using System.Text; namespace RecrownedAthenaeum.ContentReaders { @@ -8,10 +7,9 @@ namespace RecrownedAthenaeum.ContentReaders { protected override SpecialTypes.NinePatch Read(ContentReader input, SpecialTypes.NinePatch existingInstance) { - int length = input.ReadInt32(); - byte[] bytes = input.ReadBytes(length); + string serialized = input.ReadString(); - return JsonConvert.DeserializeObject(Encoding.UTF8.GetString(bytes)); + return JsonConvert.DeserializeObject(serialized); } } } diff --git a/RecrownedAthenaeum/ContentReaders/TextureAtlasDataReader.cs b/RecrownedAthenaeum/ContentReaders/TextureAtlasDataReader.cs index 76739d1..2f84b3d 100644 --- a/RecrownedAthenaeum/ContentReaders/TextureAtlasDataReader.cs +++ b/RecrownedAthenaeum/ContentReaders/TextureAtlasDataReader.cs @@ -3,6 +3,7 @@ using Microsoft.Xna.Framework.Graphics; using Newtonsoft.Json; using RecrownedAthenaeum.Data; using RecrownedAthenaeum.SpecialTypes; +using System.IO; namespace RecrownedAthenaeum.ContentReaders { @@ -12,12 +13,18 @@ namespace RecrownedAthenaeum.ContentReaders { string serialized = input.ReadString(); TextureAtlasData atlasData = JsonConvert.DeserializeObject(serialized); - Texture2D atlasTexture = input.ContentManager.Load(atlasData.textureName); + Texture2D atlasTexture = input.ContentManager.Load(Path.GetFileNameWithoutExtension(atlasData.textureName)); TextureAtlas atlas = new TextureAtlas(atlasTexture, GenerateAtlasRegionsFromData(atlasData, atlasTexture)); return atlas; } + /// + /// Generates region given . + /// + /// The data to generate the regions from. + /// The texture containing the atlas. + /// An array of regions. public TextureAtlas.Region[] GenerateAtlasRegionsFromData(TextureAtlasData textureAtlasData, Texture2D atlasTexture) { TextureAtlas.Region[] regions = new TextureAtlas.Region[textureAtlasData.regions.Length]; diff --git a/RecrownedAthenaeum/UI/Skin/Skin.cs b/RecrownedAthenaeum/UI/Skin/Skin.cs index 9d4f276..63b120e 100644 --- a/RecrownedAthenaeum/UI/Skin/Skin.cs +++ b/RecrownedAthenaeum/UI/Skin/Skin.cs @@ -4,7 +4,6 @@ using RecrownedAthenaeum.SpecialTypes; using RecrownedAthenaeum.UI.Skin.Definitions; using System; using System.Collections.Generic; -using System.IO; namespace RecrownedAthenaeum.UI.Skin {