diff -r 9b4390d6d1d1278d0fd4ddf70defde338dbf52c9 -r 8687559a9f72f1bf9ca9656e9f0d1b6c04f69986 axios/Axios_settings.cs --- a/axios/Axios_settings.cs Sat May 12 18:36:46 2012 -0500 +++ b/axios/Axios_settings.cs Sat May 12 18:49:22 2012 -0500 @@ -73,6 +73,7 @@ * - Splitting the code for Gleed2D into seperate files * - Adding a cache for loading in textures for Gleed2D * - Adding GetStream(FileMode) to get the stream of a file + * - Adding support to load a Gleed2D level from a stream * */ diff -r 9b4390d6d1d1278d0fd4ddf70defde338dbf52c9 -r 8687559a9f72f1bf9ca9656e9f0d1b6c04f69986 axios/Engine/Gleed2D/Level.cs --- a/axios/Engine/Gleed2D/Level.cs Sat May 12 18:36:46 2012 -0500 +++ b/axios/Engine/Gleed2D/Level.cs Sat May 12 18:49:22 2012 -0500 @@ -38,15 +38,12 @@ /// public SerializableDictionary CustomProperties; - private Dictionary _texturecache; - public Level() { Visible = true; Layers = new List(); CustomProperties = new SerializableDictionary(); - _texturecache = new Dictionary(); } public Level(World world) @@ -55,11 +52,11 @@ Layers = new List(); CustomProperties = new SerializableDictionary(); _world = world; - _texturecache = new Dictionary(); } - public static Level FromFile(string filename, ContentManager cm, World world, ref Dictionary cache) + public static Level FromFile(string filename, ContentManager cm, World world) { + Dictionary cache = new Dictionary(); FileStream stream = System.IO.File.Open(filename, FileMode.Open); XmlSerializer serializer = new XmlSerializer(typeof(Level)); Level level = (Level)serializer.Deserialize(stream); @@ -77,6 +74,25 @@ return level; } + public static Level FromStream(FileStream stream, ContentManager cm, World world) + { + Dictionary cache = new Dictionary(); + XmlSerializer serializer = new XmlSerializer(typeof(Level)); + Level level = (Level)serializer.Deserialize(stream); + stream.Close(); + + foreach (Layer layer in level.Layers) + { + foreach (Item item in layer.Items) + { + item.CustomProperties.RestoreItemAssociations(level); + item.load(cm, world, ref cache); + } + } + + return level; + } + public Item getItemByName(string name) { foreach (Layer layer in Layers)