Rename IFolder to IPackage
This commit is contained in:
@@ -19,7 +19,7 @@ using OpenRA.Primitives;
|
|||||||
|
|
||||||
namespace OpenRA.FileSystem
|
namespace OpenRA.FileSystem
|
||||||
{
|
{
|
||||||
public sealed class BagFile : IFolder
|
public sealed class BagFile : IPackage
|
||||||
{
|
{
|
||||||
static readonly uint[] Nothing = { };
|
static readonly uint[] Nothing = { };
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ using System.Linq;
|
|||||||
|
|
||||||
namespace OpenRA.FileSystem
|
namespace OpenRA.FileSystem
|
||||||
{
|
{
|
||||||
public sealed class BigFile : IFolder
|
public sealed class BigFile : IPackage
|
||||||
{
|
{
|
||||||
public string Name { get; private set; }
|
public string Name { get; private set; }
|
||||||
public int Priority { get; private set; }
|
public int Priority { get; private set; }
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ using System.IO;
|
|||||||
|
|
||||||
namespace OpenRA.FileSystem
|
namespace OpenRA.FileSystem
|
||||||
{
|
{
|
||||||
public sealed class D2kSoundResources : IFolder
|
public sealed class D2kSoundResources : IPackage
|
||||||
{
|
{
|
||||||
readonly Stream s;
|
readonly Stream s;
|
||||||
|
|
||||||
|
|||||||
@@ -20,15 +20,15 @@ namespace OpenRA.FileSystem
|
|||||||
public class FileSystem
|
public class FileSystem
|
||||||
{
|
{
|
||||||
public readonly List<string> FolderPaths = new List<string>();
|
public readonly List<string> FolderPaths = new List<string>();
|
||||||
public readonly List<IFolder> MountedFolders = new List<IFolder>();
|
public readonly List<IPackage> MountedFolders = new List<IPackage>();
|
||||||
|
|
||||||
static readonly Dictionary<string, Assembly> AssemblyCache = new Dictionary<string, Assembly>();
|
static readonly Dictionary<string, Assembly> AssemblyCache = new Dictionary<string, Assembly>();
|
||||||
|
|
||||||
int order;
|
int order;
|
||||||
Cache<uint, List<IFolder>> crcHashIndex = new Cache<uint, List<IFolder>>(_ => new List<IFolder>());
|
Cache<uint, List<IPackage>> crcHashIndex = new Cache<uint, List<IPackage>>(_ => new List<IPackage>());
|
||||||
Cache<uint, List<IFolder>> classicHashIndex = new Cache<uint, List<IFolder>>(_ => new List<IFolder>());
|
Cache<uint, List<IPackage>> classicHashIndex = new Cache<uint, List<IPackage>>(_ => new List<IPackage>());
|
||||||
|
|
||||||
public IFolder CreatePackage(string filename, int order, Dictionary<string, byte[]> content)
|
public IPackage CreatePackage(string filename, int order, Dictionary<string, byte[]> content)
|
||||||
{
|
{
|
||||||
if (filename.EndsWith(".mix", StringComparison.InvariantCultureIgnoreCase))
|
if (filename.EndsWith(".mix", StringComparison.InvariantCultureIgnoreCase))
|
||||||
return new MixFile(this, filename, order, content);
|
return new MixFile(this, filename, order, content);
|
||||||
@@ -50,7 +50,7 @@ namespace OpenRA.FileSystem
|
|||||||
return new Folder(filename, order, content);
|
return new Folder(filename, order, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IFolder OpenPackage(string filename, string annotation, int order)
|
public IPackage OpenPackage(string filename, string annotation, int order)
|
||||||
{
|
{
|
||||||
if (filename.EndsWith(".mix", StringComparison.InvariantCultureIgnoreCase))
|
if (filename.EndsWith(".mix", StringComparison.InvariantCultureIgnoreCase))
|
||||||
{
|
{
|
||||||
@@ -81,7 +81,7 @@ namespace OpenRA.FileSystem
|
|||||||
return new Folder(filename, order);
|
return new Folder(filename, order);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Mount(IFolder mount)
|
public void Mount(IPackage mount)
|
||||||
{
|
{
|
||||||
if (!MountedFolders.Contains(mount))
|
if (!MountedFolders.Contains(mount))
|
||||||
MountedFolders.Add(mount);
|
MountedFolders.Add(mount);
|
||||||
@@ -105,26 +105,26 @@ namespace OpenRA.FileSystem
|
|||||||
a();
|
a();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MountInner(IFolder folder)
|
void MountInner(IPackage package)
|
||||||
{
|
{
|
||||||
MountedFolders.Add(folder);
|
MountedFolders.Add(package);
|
||||||
|
|
||||||
foreach (var hash in folder.ClassicHashes())
|
foreach (var hash in package.ClassicHashes())
|
||||||
{
|
{
|
||||||
var folderList = classicHashIndex[hash];
|
var folderList = classicHashIndex[hash];
|
||||||
if (!folderList.Contains(folder))
|
if (!folderList.Contains(package))
|
||||||
folderList.Add(folder);
|
folderList.Add(package);
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var hash in folder.CrcHashes())
|
foreach (var hash in package.CrcHashes())
|
||||||
{
|
{
|
||||||
var folderList = crcHashIndex[hash];
|
var folderList = crcHashIndex[hash];
|
||||||
if (!folderList.Contains(folder))
|
if (!folderList.Contains(package))
|
||||||
folderList.Add(folder);
|
folderList.Add(package);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Unmount(IFolder mount)
|
public bool Unmount(IPackage mount)
|
||||||
{
|
{
|
||||||
if (MountedFolders.Contains(mount))
|
if (MountedFolders.Contains(mount))
|
||||||
mount.Dispose();
|
mount.Dispose();
|
||||||
@@ -139,8 +139,8 @@ namespace OpenRA.FileSystem
|
|||||||
|
|
||||||
MountedFolders.Clear();
|
MountedFolders.Clear();
|
||||||
FolderPaths.Clear();
|
FolderPaths.Clear();
|
||||||
classicHashIndex = new Cache<uint, List<IFolder>>(_ => new List<IFolder>());
|
classicHashIndex = new Cache<uint, List<IPackage>>(_ => new List<IPackage>());
|
||||||
crcHashIndex = new Cache<uint, List<IFolder>>(_ => new List<IFolder>());
|
crcHashIndex = new Cache<uint, List<IPackage>>(_ => new List<IPackage>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LoadFromManifest(Manifest manifest)
|
public void LoadFromManifest(Manifest manifest)
|
||||||
@@ -189,8 +189,8 @@ namespace OpenRA.FileSystem
|
|||||||
filename = divide.Last();
|
filename = divide.Last();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check the cache for a quick lookup if the folder name is unknown
|
// Check the cache for a quick lookup if the package name is unknown
|
||||||
// TODO: This disables caching for explicit folder requests
|
// TODO: This disables caching for explicit package requests
|
||||||
if (filename.IndexOfAny(new char[] { '/', '\\' }) == -1 && !explicitFolder)
|
if (filename.IndexOfAny(new char[] { '/', '\\' }) == -1 && !explicitFolder)
|
||||||
{
|
{
|
||||||
s = GetFromCache(PackageHashType.Classic, filename);
|
s = GetFromCache(PackageHashType.Classic, filename);
|
||||||
@@ -203,15 +203,15 @@ namespace OpenRA.FileSystem
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ask each package individually
|
// Ask each package individually
|
||||||
IFolder folder;
|
IPackage package;
|
||||||
if (explicitFolder && !string.IsNullOrEmpty(foldername))
|
if (explicitFolder && !string.IsNullOrEmpty(foldername))
|
||||||
folder = MountedFolders.Where(x => x.Name == foldername).MaxByOrDefault(x => x.Priority);
|
package = MountedFolders.Where(x => x.Name == foldername).MaxByOrDefault(x => x.Priority);
|
||||||
else
|
else
|
||||||
folder = MountedFolders.Where(x => x.Exists(filename)).MaxByOrDefault(x => x.Priority);
|
package = MountedFolders.Where(x => x.Exists(filename)).MaxByOrDefault(x => x.Priority);
|
||||||
|
|
||||||
if (folder != null)
|
if (package != null)
|
||||||
{
|
{
|
||||||
s = folder.GetContent(filename);
|
s = package.GetContent(filename);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ using System.IO;
|
|||||||
|
|
||||||
namespace OpenRA.FileSystem
|
namespace OpenRA.FileSystem
|
||||||
{
|
{
|
||||||
public sealed class Folder : IFolder
|
public sealed class Folder : IPackage
|
||||||
{
|
{
|
||||||
readonly string path;
|
readonly string path;
|
||||||
readonly int priority;
|
readonly int priority;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ using System.IO;
|
|||||||
|
|
||||||
namespace OpenRA.FileSystem
|
namespace OpenRA.FileSystem
|
||||||
{
|
{
|
||||||
public interface IFolder : IDisposable
|
public interface IPackage : IDisposable
|
||||||
{
|
{
|
||||||
Stream GetContent(string filename);
|
Stream GetContent(string filename);
|
||||||
bool Exists(string filename);
|
bool Exists(string filename);
|
||||||
@@ -17,7 +17,7 @@ using ICSharpCode.SharpZipLib.Zip.Compression;
|
|||||||
|
|
||||||
namespace OpenRA.FileSystem
|
namespace OpenRA.FileSystem
|
||||||
{
|
{
|
||||||
public sealed class InstallShieldCABExtractor : IFolder
|
public sealed class InstallShieldCABExtractor : IPackage
|
||||||
{
|
{
|
||||||
const uint FileSplit = 0x1;
|
const uint FileSplit = 0x1;
|
||||||
const uint FileObfuscated = 0x2;
|
const uint FileObfuscated = 0x2;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ using OpenRA.FileFormats;
|
|||||||
|
|
||||||
namespace OpenRA.FileSystem
|
namespace OpenRA.FileSystem
|
||||||
{
|
{
|
||||||
public sealed class InstallShieldPackage : IFolder
|
public sealed class InstallShieldPackage : IPackage
|
||||||
{
|
{
|
||||||
readonly Dictionary<uint, PackageEntry> index = new Dictionary<uint, PackageEntry>();
|
readonly Dictionary<uint, PackageEntry> index = new Dictionary<uint, PackageEntry>();
|
||||||
readonly List<string> filenames;
|
readonly List<string> filenames;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ using OpenRA.Primitives;
|
|||||||
|
|
||||||
namespace OpenRA.FileSystem
|
namespace OpenRA.FileSystem
|
||||||
{
|
{
|
||||||
public sealed class MixFile : IFolder
|
public sealed class MixFile : IPackage
|
||||||
{
|
{
|
||||||
readonly Dictionary<uint, PackageEntry> index;
|
readonly Dictionary<uint, PackageEntry> index;
|
||||||
readonly long dataStart;
|
readonly long dataStart;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace OpenRA.FileSystem
|
|||||||
public string Filename;
|
public string Filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class PakFile : IFolder
|
public sealed class PakFile : IPackage
|
||||||
{
|
{
|
||||||
readonly string filename;
|
readonly string filename;
|
||||||
readonly int priority;
|
readonly int priority;
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ using SZipFile = ICSharpCode.SharpZipLib.Zip.ZipFile;
|
|||||||
|
|
||||||
namespace OpenRA.FileSystem
|
namespace OpenRA.FileSystem
|
||||||
{
|
{
|
||||||
public sealed class ZipFile : IFolder
|
public sealed class ZipFile : IPackage
|
||||||
{
|
{
|
||||||
readonly string filename;
|
readonly string filename;
|
||||||
readonly int priority;
|
readonly int priority;
|
||||||
|
|||||||
@@ -157,7 +157,7 @@ namespace OpenRA
|
|||||||
[FieldLoader.Ignore] public readonly WVec[] SubCellOffsets;
|
[FieldLoader.Ignore] public readonly WVec[] SubCellOffsets;
|
||||||
public readonly SubCell DefaultSubCell;
|
public readonly SubCell DefaultSubCell;
|
||||||
public readonly SubCell LastSubCell;
|
public readonly SubCell LastSubCell;
|
||||||
[FieldLoader.Ignore] public IFolder Container;
|
[FieldLoader.Ignore] public IPackage Container;
|
||||||
public string Path { get; private set; }
|
public string Path { get; private set; }
|
||||||
|
|
||||||
// Yaml map data
|
// Yaml map data
|
||||||
|
|||||||
@@ -96,7 +96,7 @@
|
|||||||
<Compile Include="CacheStorage.cs" />
|
<Compile Include="CacheStorage.cs" />
|
||||||
<Compile Include="FileFormats\VocLoader.cs" />
|
<Compile Include="FileFormats\VocLoader.cs" />
|
||||||
<Compile Include="FileSystem\IdxEntry.cs" />
|
<Compile Include="FileSystem\IdxEntry.cs" />
|
||||||
<Compile Include="FileSystem\IFolder.cs" />
|
<Compile Include="FileSystem\IPackage.cs" />
|
||||||
<Compile Include="LogProxy.cs" />
|
<Compile Include="LogProxy.cs" />
|
||||||
<Compile Include="FileFormats\IdxReader.cs" />
|
<Compile Include="FileFormats\IdxReader.cs" />
|
||||||
<Compile Include="FileSystem\BagFile.cs" />
|
<Compile Include="FileSystem\BagFile.cs" />
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
ScrollPanelWidget assetList;
|
ScrollPanelWidget assetList;
|
||||||
ScrollItemWidget template;
|
ScrollItemWidget template;
|
||||||
|
|
||||||
IFolder assetSource = null;
|
IPackage assetSource = null;
|
||||||
List<string> availableShps = new List<string>();
|
List<string> availableShps = new List<string>();
|
||||||
bool animateFrames = false;
|
bool animateFrames = false;
|
||||||
|
|
||||||
@@ -334,7 +334,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
bool ShowSourceDropdown(DropDownButtonWidget dropdown)
|
bool ShowSourceDropdown(DropDownButtonWidget dropdown)
|
||||||
{
|
{
|
||||||
Func<IFolder, ScrollItemWidget, ScrollItemWidget> setupItem = (source, itemTemplate) =>
|
Func<IPackage, ScrollItemWidget, ScrollItemWidget> setupItem = (source, itemTemplate) =>
|
||||||
{
|
{
|
||||||
var item = ScrollItemWidget.Setup(itemTemplate,
|
var item = ScrollItemWidget.Setup(itemTemplate,
|
||||||
() => assetSource == source,
|
() => assetSource == source,
|
||||||
@@ -344,7 +344,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Re-enable "All Packages" once list generation is done in a background thread
|
// TODO: Re-enable "All Packages" once list generation is done in a background thread
|
||||||
// var sources = new[] { (IFolder)null }.Concat(GlobalFileSystem.MountedFolders);
|
// var sources = new[] { (IPackage)null }.Concat(GlobalFileSystem.MountedFolders);
|
||||||
var sources = Game.ModData.ModFiles.MountedFolders;
|
var sources = Game.ModData.ModFiles.MountedFolders;
|
||||||
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 280, sources, setupItem);
|
dropdown.ShowDropDown("LABEL_DROPDOWN_TEMPLATE", 280, sources, setupItem);
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user