start reworking map enumerator

This commit is contained in:
Chris Forbes
2010-12-28 18:27:40 +13:00
parent f7b34e1c5e
commit cc2efdfa4a

View File

@@ -43,11 +43,21 @@ namespace OpenRA
}
// TODO: Do this nicer
IEnumerable<string> FindMapsIn(string dir)
{
string[] NoMaps = { };
if (!Directory.Exists(dir))
return NoMaps;
// todo: look for compressed maps too.
return Directory.GetDirectories(dir);
}
Dictionary<string, MapStub> FindMaps(string[] mods)
{
var paths = new[] { "maps/" }.Concat(mods.Select(m => "mods/" + m + "/maps/"))
.Where(p => Directory.Exists(p))
.SelectMany(p => Directory.GetDirectories(p)).ToList();
var paths = new[] { "maps/" }.Concat(mods.Select(m => "mods/" + m + "/maps/"))
.SelectMany(p => FindMapsIn(p));
return paths.Select(p => new MapStub(new Folder(p, int.MaxValue))).ToDictionary(m => m.Uid);
}