Changed: Mounts the map' IFolder with least possible priority, allowing the map to has its own assets

This commit is contained in:
geckosoft
2010-11-15 04:09:45 +01:00
committed by Chris Forbes
parent 000dd6de7b
commit be9f52e029
2 changed files with 25 additions and 2 deletions

View File

@@ -69,6 +69,16 @@ namespace OpenRA.FileFormats
allFiles = new Cache<uint, List<IFolder>>( _ => new List<IFolder>() );
}
public static bool Unmount(IFolder mount)
{
return (mountedFolders.RemoveAll(f => f == mount) > 0);
}
public static void Mount(IFolder mount)
{
if (!mountedFolders.Contains(mount)) mountedFolders.Add(mount);
}
public static void LoadFromManifest( Manifest manifest )
{
UnmountAll();

View File

@@ -49,11 +49,13 @@ namespace OpenRA
.Where(p => Directory.Exists(p))
.SelectMany(p => Directory.GetDirectories(p)).ToList();
return paths.Select(p => new MapStub(new Folder(p, 0))).ToDictionary(m => m.Uid);
return paths.Select(p => new MapStub(new Folder(p, int.MaxValue))).ToDictionary(m => m.Uid);
}
string cachedTheatre = null;
IFolder previousMapMount = null;
public Map PrepareMap(string uid)
{
LoadScreen.Display();
@@ -63,6 +65,17 @@ namespace OpenRA
var map = new Map(AvailableMaps[uid]);
// unload the previous map mount if we have one
if (previousMapMount != null) FileSystem.Unmount(previousMapMount);
// Adds the map its container to the FileSystem
// allowing the map to use custom assets
// Container should have the lowest priority of all (ie int max)
FileSystem.Mount(map.Container);
// Store a reference so we can unload it next time
previousMapMount = map.Container;
Rules.LoadRules(Manifest, map);
if (map.Theater != cachedTheatre)