private void LoadResourceRepositories(bool ModuleOnly)
{
string HomeDirectory = SystemInfo.GetHomeDirectory();
string InstallDirectory = SystemInfo.GetGameInstallationDirectory();
string ModPath;
string DataPath;
//
// Create a dummy resource manager to keep OEIShared happy. We do
// not use it explicitly, but some OEIShared code uses
// ResourceManager.Instance and hopes to get something back.
//
if (OEIShared.IO.ResourceManager.Instance == null)
new DummyOEIResourceManager();
if (ModuleResourceName == null)
ModuleResourceName = SystemInfo.GetModuleResourceName();
if (ModuleResourceName == null)
throw new ApplicationException("Cannot determine module resource name.");
Repositories = new List<ResourceRepository>();
ModPath = String.Format("{0}\\modules\\{1}.mod", HomeDirectory, ModuleResourceName);
if (File.Exists(ModPath))
{
Repositories.Add(new ALFAERFResourceRepository(ModPath));
}
else
{
ModPath = String.Format("{0}\\modules\\{1}\\", HomeDirectory, ModuleResourceName);
Repositories.Add(new DirectoryResourceRepository(ModPath));
}
if (!ModuleOnly)
{
GFFFile ModuleIfo = OpenModuleIfo();
AddModuleHaks(ModuleIfo, HomeDirectory, InstallDirectory);
AddModuleCampaign(ModuleIfo, HomeDirectory, InstallDirectory);
foreach (string PathName in new string[] { HomeDirectory, InstallDirectory })
{
string overrideFolder = String.Format("{0}\\override", PathName);
if (Directory.Exists(overrideFolder))
{
Repositories.Add(new DirectoryResourceRepository(overrideFolder));
}
}
DataPath = String.Format("{0}\\Data", InstallDirectory);
foreach (string ZipPath in Directory.EnumerateFiles(DataPath, "*.zip"))
{
Repositories.Add(new ZIPResourceRepository(ZipPath));
}
}
//
// Finally, populate all of the repositories, which may take time.
//
foreach (ResourceRepository Repository in Repositories)
{
Repository.PopulateRepository();
}
}