/// <summary> /// Reads a directory, building the list of level metadata available for browsing. /// </summary> /// <param name="dataSource"></param> /// <returns></returns> private void ReadDataSource(string folder, Genres tag, StorageSource sources) { string path = Path.Combine(BokuGame.Settings.MediaPath, BokuGame.LevelsPath, folder); string[] files = null; try { #if NETFX_CORE files = Storage4.GetFiles(path, @"*.Xml", sources); #else files = Storage4.GetFiles(path, @"*.Xml", sources, SearchOption.TopDirectoryOnly); #endif } catch { } if (files != null) { // Filter out AutoSave.Xml List <string> filteredFiles = new List <string>(); for (int i = 0; i < files.Length; ++i) { if (files[i].ToUpper().Contains("AUTOSAVE")) { continue; } filteredFiles.Add(files[i]); } files = filteredFiles.ToArray(); // Load level metadata records for (int i = 0; running && i < files.Length; i++) { try { string filename = Path.GetFileName(files[i]); string fullPath = Path.Combine(path, filename); XmlWorldData xml = XmlWorldData.Load(fullPath, XnaStorageHelper.Instance, (int)sources); if (xml == null) { continue; } LevelMetadata level = new LevelMetadata(); level.FromXml(xml); level.Genres |= tag; LevelBrowserState state = new LevelBrowserState(); state.level = level; level.BrowserState = state; // Force the creator name of built-ins to "Microsoft" if ((level.Genres & Genres.BuiltInWorlds) != 0) { level.Creator = "Kodu Team"; } AddLevel(level); } catch (Exception e) { Debug.WriteLine(e.Message); } } } }