Move AvailableMaps into ModData

This commit is contained in:
Paul Chote
2010-08-21 20:07:28 +12:00
parent 94dd73cb48
commit 4e2d76f6ed
6 changed files with 27 additions and 52 deletions

View File

@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using OpenRA.FileFormats;
using OpenRA.Graphics;
using System.IO;
namespace OpenRA
{
@@ -13,7 +14,8 @@ namespace OpenRA
public readonly ObjectCreator ObjectCreator;
public readonly SheetBuilder SheetBuilder;
public readonly CursorSheetBuilder CursorSheetBuilder;
public readonly Dictionary<string, MapStub> AvailableMaps;
public ModData( params string[] mods )
{
Manifest = new Manifest( mods );
@@ -21,6 +23,20 @@ namespace OpenRA
FileSystem.LoadFromManifest( Manifest );
SheetBuilder = new SheetBuilder( TextureChannel.Red );
CursorSheetBuilder = new CursorSheetBuilder( this );
ChromeProvider.Initialize( Manifest.Chrome );
AvailableMaps = FindMaps( mods );
}
// TODO: Do this nicer
static 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();
return paths.Select(p => new MapStub(new Folder(p))).ToDictionary(m => m.Uid);
}
}
}