Made AnimationEditor compatible with Dictionary SpriteMaps
Added MonoGame Pipeline's IntermediateSerializer and needed classes from the pipeline and MonoGame.Framework.Utilities to make AnimationEditor capable of reading Dictionaries
This commit is contained in:
@@ -13,6 +13,8 @@ using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using QURO.AnimationLibrary;
|
||||
using QURO;
|
||||
using System.Xml;
|
||||
using Microsoft.Xna.Framework.Content.Pipeline.Serialization.Intermediate;
|
||||
|
||||
namespace AnimationEditor
|
||||
{
|
||||
@@ -41,17 +43,24 @@ namespace AnimationEditor
|
||||
if (loadSpriteMapDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
||||
{
|
||||
|
||||
XmlSerializer mapSerializer = new XmlSerializer(typeof(List<SpriteMapRegion>));
|
||||
TextReader mapReader = new StreamReader(loadSpriteMapDialog.FileName);
|
||||
Dictionary<string, SpriteMapRegion> loadedSpriteMap;
|
||||
using (XmlReader xmlRead = XmlReader.Create(loadSpriteMapDialog.FileName))
|
||||
{
|
||||
loadedSpriteMap = IntermediateSerializer.Deserialize<Dictionary<string, SpriteMapRegion>>(xmlRead, null);
|
||||
}
|
||||
|
||||
Sprites = new BindingList<SpriteMapRegion>();
|
||||
foreach (KeyValuePair<string, SpriteMapRegion> sprite in loadedSpriteMap)
|
||||
{
|
||||
Sprites.Add(sprite.Value);
|
||||
}
|
||||
|
||||
Sprites = new BindingList<SpriteMapRegion>((List<SpriteMapRegion>)mapSerializer.Deserialize(mapReader));
|
||||
spriteListBox.DataSource = Sprites;
|
||||
spriteListBox.DisplayMember = "Name";
|
||||
spriteListBox.ValueMember = "Bounds";
|
||||
Rectangle[] frames = new Rectangle[] { Sprites[0].Bounds, Sprites[1].Bounds, Sprites[2].Bounds };
|
||||
animationPreview.CurrentAnimation = new Animation("Test", frames, 1f / 60f, true);
|
||||
animationPreview.PreviewSprite = new AnimatedSprite(animationPreview.SpriteSheet, animationPreview.CurrentAnimation);
|
||||
mapReader.Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user