Merge pull request #3917 from Mailaender/map-folders
Removed hard-coded map folders
This commit is contained in:
@@ -19,8 +19,8 @@ namespace OpenRA.FileFormats
|
||||
public static class FileSystem
|
||||
{
|
||||
public static List<IFolder> MountedFolders = new List<IFolder>();
|
||||
static Cache<uint, List<IFolder>> classicHashIndex = new Cache<uint, List<IFolder>>( _ => new List<IFolder>() );
|
||||
static Cache<uint, List<IFolder>> crcHashIndex = new Cache<uint, List<IFolder>>( _ => new List<IFolder>() );
|
||||
static Cache<uint, List<IFolder>> classicHashIndex = new Cache<uint, List<IFolder>>(_ => new List<IFolder>());
|
||||
static Cache<uint, List<IFolder>> crcHashIndex = new Cache<uint, List<IFolder>>(_ => new List<IFolder>());
|
||||
|
||||
public static List<string> FolderPaths = new List<string>();
|
||||
|
||||
@@ -89,11 +89,12 @@ namespace OpenRA.FileFormats
|
||||
public static void Mount(string name, string annotation)
|
||||
{
|
||||
var optional = name.StartsWith("~");
|
||||
if (optional) name = name.Substring(1);
|
||||
if (optional)
|
||||
name = name.Substring(1);
|
||||
|
||||
// paths starting with ^ are relative to the support dir
|
||||
if (name.StartsWith("^"))
|
||||
name = Platform.SupportDir+name.Substring(1);
|
||||
name = Platform.SupportDir + name.Substring(1);
|
||||
|
||||
FolderPaths.Add(name);
|
||||
Action a = () => FileSystem.MountInner(OpenPackage(name, annotation, order++));
|
||||
@@ -115,7 +116,7 @@ namespace OpenRA.FileFormats
|
||||
|
||||
public static bool Unmount(IFolder mount)
|
||||
{
|
||||
return (MountedFolders.RemoveAll(f => f == mount) > 0);
|
||||
return MountedFolders.RemoveAll(f => f == mount) > 0;
|
||||
}
|
||||
|
||||
public static void Mount(IFolder mount)
|
||||
@@ -151,7 +152,7 @@ namespace OpenRA.FileFormats
|
||||
|
||||
public static Stream OpenWithExts(string filename, params string[] exts)
|
||||
{
|
||||
if (filename.IndexOfAny(new char[] { '/', '\\' } ) == -1)
|
||||
if (filename.IndexOfAny(new char[] { '/', '\\' }) == -1)
|
||||
{
|
||||
foreach (var ext in exts)
|
||||
{
|
||||
@@ -19,7 +19,7 @@ namespace OpenRA.FileFormats
|
||||
public class Manifest
|
||||
{
|
||||
public readonly string[]
|
||||
Mods, Folders, Rules, ServerTraits,
|
||||
Mods, Folders, MapFolders, Rules, ServerTraits,
|
||||
Sequences, VoxelSequences, Cursors, Chrome, Assemblies, ChromeLayout,
|
||||
Weapons, Voices, Notifications, Music, Movies, Translations, TileSets,
|
||||
ChromeMetrics, PackageContents;
|
||||
@@ -39,6 +39,7 @@ namespace OpenRA.FileFormats
|
||||
|
||||
// TODO: Use fieldloader
|
||||
Folders = YamlList(yaml, "Folders");
|
||||
MapFolders = YamlList(yaml, "MapFolders");
|
||||
Packages = yaml["Packages"].NodesDict.ToDictionary(x => x.Key, x => x.Value.Value);
|
||||
Rules = YamlList(yaml, "Rules");
|
||||
ServerTraits = YamlList(yaml, "ServerTraits");
|
||||
|
||||
@@ -90,11 +90,6 @@
|
||||
<Compile Include="FileFormats\Format40.cs" />
|
||||
<Compile Include="FileFormats\Format80.cs" />
|
||||
<Compile Include="FileFormats\IniFile.cs" />
|
||||
<Compile Include="Filesystem\FileSystem.cs" />
|
||||
<Compile Include="Filesystem\Folder.cs" />
|
||||
<Compile Include="Filesystem\InstallShieldPackage.cs" />
|
||||
<Compile Include="Filesystem\MixFile.cs" />
|
||||
<Compile Include="Filesystem\ZipFile.cs" />
|
||||
<Compile Include="Graphics\Dune2ShpReader.cs" />
|
||||
<Compile Include="Graphics\IGraphicsDevice.cs" />
|
||||
<Compile Include="Graphics\IInputHandler.cs" />
|
||||
@@ -148,11 +143,16 @@
|
||||
<Compile Include="Graphics\HvaReader.cs" />
|
||||
<Compile Include="StreamExts.cs" />
|
||||
<Compile Include="FileFormats\WavLoader.cs" />
|
||||
<Compile Include="Filesystem\D2kSoundResources.cs" />
|
||||
<Compile Include="Graphics\R8Reader.cs" />
|
||||
<Compile Include="Graphics\TileSetRenderer.cs" />
|
||||
<Compile Include="Keycode.cs" />
|
||||
<Compile Include="Hotkey.cs" />
|
||||
<Compile Include="FileSystem\FileSystem.cs" />
|
||||
<Compile Include="FileSystem\Folder.cs" />
|
||||
<Compile Include="FileSystem\InstallShieldPackage.cs" />
|
||||
<Compile Include="FileSystem\MixFile.cs" />
|
||||
<Compile Include="FileSystem\ZipFile.cs" />
|
||||
<Compile Include="FileSystem\D2kSoundResources.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
|
||||
|
||||
@@ -34,12 +34,21 @@ namespace OpenRA
|
||||
{
|
||||
string[] noMaps = { };
|
||||
|
||||
// ignore optional flag
|
||||
if (dir.StartsWith("~"))
|
||||
dir = dir.Substring(1);
|
||||
|
||||
// paths starting with ^ are relative to the user directory
|
||||
if (dir.StartsWith("^"))
|
||||
dir = Platform.SupportDir + dir.Substring(1);
|
||||
|
||||
if (!Directory.Exists(dir))
|
||||
return noMaps;
|
||||
|
||||
return Directory.GetDirectories(dir)
|
||||
.Concat(Directory.GetFiles(dir, "*.zip"))
|
||||
.Concat(Directory.GetFiles(dir, "*.oramap"));
|
||||
var dirsWithMaps = Directory.GetDirectories(dir)
|
||||
.Where(d => Directory.GetFiles(d, "map.yaml").Any() && Directory.GetFiles(d, "map.bin").Any());
|
||||
|
||||
return dirsWithMaps.Concat(Directory.GetFiles(dir, "*.oramap"));
|
||||
}
|
||||
|
||||
public ModData(params string[] mods)
|
||||
@@ -52,7 +61,7 @@ namespace OpenRA
|
||||
LoadScreen.Display();
|
||||
WidgetLoader = new WidgetLoader(this);
|
||||
|
||||
AvailableMaps = FindMaps(Manifest.Mods);
|
||||
AvailableMaps = FindMaps();
|
||||
|
||||
// HACK: Mount only local folders so we have a half-working environment for the asset installer
|
||||
FileSystem.UnmountAll();
|
||||
@@ -138,10 +147,9 @@ namespace OpenRA
|
||||
return map;
|
||||
}
|
||||
|
||||
Dictionary<string, Map> FindMaps(string[] mods)
|
||||
Dictionary<string, Map> FindMaps()
|
||||
{
|
||||
var paths = mods.SelectMany(p => FindMapsIn("mods{0}{1}{0}maps{0}".F(Path.DirectorySeparatorChar, p)))
|
||||
.Concat(mods.SelectMany(p => FindMapsIn("{1}maps{0}{2}{0}".F(Path.DirectorySeparatorChar, Platform.SupportDir, p))));
|
||||
var paths = Manifest.MapFolders.SelectMany(f => FindMapsIn(f));
|
||||
|
||||
var ret = new Dictionary<string, Map>();
|
||||
|
||||
|
||||
@@ -11,6 +11,10 @@ Folders:
|
||||
./mods/cnc/uibits
|
||||
~^/Content/cnc
|
||||
|
||||
MapFolders:
|
||||
./mods/cnc/maps
|
||||
~^/maps/cnc
|
||||
|
||||
Packages:
|
||||
overrides.mix
|
||||
bluetib.mix
|
||||
|
||||
@@ -14,6 +14,10 @@ Folders:
|
||||
~^/Content/d2k/GAMESFX
|
||||
~^/Content/d2k/Music
|
||||
|
||||
MapFolders:
|
||||
./mods/d2k/maps
|
||||
~^/maps/d2k
|
||||
|
||||
Packages:
|
||||
SOUND.RS
|
||||
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
crate:
|
||||
idle: DATA.R8
|
||||
Start: 102
|
||||
ZOffset: -511
|
||||
Offset: -16,-16
|
||||
land: DATA.R8
|
||||
Start: 102
|
||||
ZOffset: -511
|
||||
Offset: -16,-16
|
||||
|
||||
spicebloom:
|
||||
make: DATA.R8
|
||||
Start: 107
|
||||
Length: 3
|
||||
Offset: -16,-16
|
||||
active: DATA.R8
|
||||
Start: 109
|
||||
Length: 1
|
||||
ZOffset: -511
|
||||
Offset: -16,-16
|
||||
idle: DATA.R8
|
||||
Start: 109
|
||||
ZOffset: -511
|
||||
Offset: -16,-16
|
||||
@@ -12,6 +12,10 @@ Folders:
|
||||
./mods/ra/uibits
|
||||
~^/Content/ra
|
||||
|
||||
MapFolders:
|
||||
./mods/ra/maps
|
||||
~^/maps/ra
|
||||
|
||||
Packages:
|
||||
~main.mix
|
||||
redalert.mix
|
||||
|
||||
@@ -14,6 +14,10 @@ Folders:
|
||||
# Red Alert
|
||||
./mods/ra/uibits
|
||||
|
||||
MapFolders:
|
||||
./mods/ts/maps
|
||||
~^/maps/ts
|
||||
|
||||
Packages:
|
||||
# Red Alert
|
||||
interior.mix
|
||||
|
||||
Reference in New Issue
Block a user