Changed: Mounts the map' IFolder with least possible priority, allowing the map to has its own assets
This commit is contained in:
@@ -69,6 +69,16 @@ namespace OpenRA.FileFormats
|
|||||||
allFiles = new Cache<uint, List<IFolder>>( _ => new List<IFolder>() );
|
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 )
|
public static void LoadFromManifest( Manifest manifest )
|
||||||
{
|
{
|
||||||
UnmountAll();
|
UnmountAll();
|
||||||
|
|||||||
@@ -49,10 +49,12 @@ namespace OpenRA
|
|||||||
.Where(p => Directory.Exists(p))
|
.Where(p => Directory.Exists(p))
|
||||||
.SelectMany(p => Directory.GetDirectories(p)).ToList();
|
.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;
|
string cachedTheatre = null;
|
||||||
|
|
||||||
|
IFolder previousMapMount = null;
|
||||||
|
|
||||||
public Map PrepareMap(string uid)
|
public Map PrepareMap(string uid)
|
||||||
{
|
{
|
||||||
@@ -62,7 +64,18 @@ namespace OpenRA
|
|||||||
throw new InvalidDataException("Invalid map uid: {0}".F(uid));
|
throw new InvalidDataException("Invalid map uid: {0}".F(uid));
|
||||||
|
|
||||||
var map = new Map(AvailableMaps[uid]);
|
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);
|
Rules.LoadRules(Manifest, map);
|
||||||
|
|
||||||
if (map.Theater != cachedTheatre)
|
if (map.Theater != cachedTheatre)
|
||||||
|
|||||||
Reference in New Issue
Block a user