Add an install from cd option for cnc. Remove music install options.
This commit is contained in:
@@ -52,24 +52,6 @@ namespace OpenRA.Utility
|
||||
}
|
||||
}
|
||||
|
||||
public static void InstallRAMusic(string path)
|
||||
{
|
||||
Util.ExtractPackagesFromMix(path, string.Format("mods{0}ra{0}packages", Path.DirectorySeparatorChar),
|
||||
"MAIN.MIX", "scores.mix");
|
||||
Console.WriteLine("Done");
|
||||
}
|
||||
|
||||
public static void InstallCncMusic(string path)
|
||||
{
|
||||
if (!Directory.Exists(path)) { Console.WriteLine("Error: Path {0} does not exist", path); return; }
|
||||
string scoresMixPath = path + Path.DirectorySeparatorChar + "SCORES.MIX";
|
||||
if (!File.Exists(scoresMixPath)) { Console.WriteLine("Error: Could not find SCORES.MIX in path {0}", path); return; }
|
||||
|
||||
File.Copy(scoresMixPath, string.Format("mods{0}cnc{0}packages{0}scores.mix", Path.DirectorySeparatorChar), true);
|
||||
|
||||
Console.WriteLine("Done");
|
||||
}
|
||||
|
||||
public static void DownloadPackages(string argValue)
|
||||
{
|
||||
string[] args = argValue.Split(',');
|
||||
@@ -128,19 +110,49 @@ namespace OpenRA.Utility
|
||||
|
||||
public static void InstallRAPackages(string path)
|
||||
{
|
||||
Util.ExtractPackagesFromMix(path, "mods{0}ra{0}packages".F(Path.DirectorySeparatorChar), "MAIN.MIX",
|
||||
"conquer.mix", "russian.mix", "allies.mix", "sounds.mix", "scores.mix",
|
||||
"snow.mix", "interior.mix", "temperat.mix");
|
||||
var redalertMixPath = "{0}{1}INSTALL{1}REDALERT.MIX".F(path, Path.DirectorySeparatorChar);
|
||||
if (!File.Exists(redalertMixPath)) { Console.WriteLine("Error: REDALERT.MIX could not be found on the CD"); return; }
|
||||
Console.WriteLine("Copying REDALERT.MIX");
|
||||
File.Copy(redalertMixPath, "mods{0}ra{0}packages{0}redalert.mix".F(Path.DirectorySeparatorChar),true);
|
||||
Console.WriteLine("Done");
|
||||
var basePath = "{0}{1}".F(path, Path.DirectorySeparatorChar);
|
||||
var toPath = "mods{0}ra{0}packages{0}".F(Path.DirectorySeparatorChar);
|
||||
var directCopy = new string[] {"INSTALL/REDALERT.MIX"};
|
||||
var extract = new string[] {"conquer.mix", "russian.mix", "allies.mix", "sounds.mix",
|
||||
"scores.mix", "snow.mix", "interior.mix", "temperat.mix"};
|
||||
if (!Directory.Exists(toPath))
|
||||
Directory.CreateDirectory(toPath);
|
||||
|
||||
Util.ExtractFromPackage(basePath, "MAIN.MIX", extract, toPath);
|
||||
foreach (var file in directCopy)
|
||||
{
|
||||
if (!File.Exists(basePath+file))
|
||||
{
|
||||
Console.WriteLine("Error: Could not find "+file);
|
||||
return;
|
||||
}
|
||||
Console.WriteLine("Extracting: {0}", file);
|
||||
File.Copy(basePath+file,toPath+Path.GetFileName(file).ToLower(), true);
|
||||
}
|
||||
}
|
||||
|
||||
public static void InstallCncPackages(string path)
|
||||
{
|
||||
Console.WriteLine("Error: NotI");
|
||||
var basePath = "{0}{1}".F(path, Path.DirectorySeparatorChar);
|
||||
var toPath = "mods{0}cnc{0}packages{0}".F(Path.DirectorySeparatorChar);
|
||||
var directCopy = new string[] {"CONQUER.MIX", "DESERT.MIX", "GENERAL.MIX", "SCORES.MIX",
|
||||
"SOUNDS.MIX", "TEMPERAT.MIX", "WINTER.MIX"};
|
||||
var extract = new string[] {"cclocal.mix", "speech.mix", "tempicnh.mix", "updatec.mix"};
|
||||
|
||||
if (!Directory.Exists(toPath))
|
||||
Directory.CreateDirectory(toPath);
|
||||
|
||||
Util.ExtractFromPackage(basePath+"INSTALL", "SETUP.Z", extract, toPath);
|
||||
foreach (var file in directCopy)
|
||||
{
|
||||
if (!File.Exists(basePath+file))
|
||||
{
|
||||
Console.WriteLine("Error: Could not find "+file);
|
||||
return;
|
||||
}
|
||||
Console.WriteLine("Extracting: {0}", file);
|
||||
File.Copy(basePath+file,toPath+Path.GetFileName(file).ToLower(), true);
|
||||
}
|
||||
}
|
||||
|
||||
public static void Settings(string argValue)
|
||||
|
||||
@@ -36,8 +36,6 @@ namespace OpenRA.Utility
|
||||
argCallbacks.Add("-l", Command.ListMods);
|
||||
argCallbacks.Add("--mod-info", Command.ListModInfo);
|
||||
argCallbacks.Add("-i", Command.ListModInfo);
|
||||
argCallbacks.Add("--install-ra-music", Command.InstallRAMusic);
|
||||
argCallbacks.Add("--install-cnc-music", Command.InstallCncMusic);
|
||||
argCallbacks.Add("--download-packages", Command.DownloadPackages);
|
||||
argCallbacks.Add("--install-ra-packages", Command.InstallRAPackages);
|
||||
argCallbacks.Add("--install-cnc-packages", Command.InstallCncPackages);
|
||||
@@ -83,8 +81,6 @@ namespace OpenRA.Utility
|
||||
Console.WriteLine();
|
||||
Console.WriteLine(" -l,--list-mods List currently installed mods");
|
||||
Console.WriteLine(" -i=MODS,--mod-info=MODS List metadata for MODS (comma separated list of mods)");
|
||||
Console.WriteLine(" --install-ra-music=PATH Install scores.mix from PATH to Red Alert CD");
|
||||
Console.WriteLine(" --install-cnc-music=PATH Install scores.mix from PATH to Command & Conquer CD");
|
||||
Console.WriteLine(" --download-packages=MOD{,DEST} Download packages for MOD to DEST (def: system temp folder) and install them");
|
||||
Console.WriteLine(" --install-ra-packages=PATH Install required packages for RA from PATH to CD");
|
||||
Console.WriteLine(" --install-cnc-packages=PATH Install required packages for C&C from PATH to CD");
|
||||
|
||||
@@ -17,23 +17,22 @@ namespace OpenRA.Utility
|
||||
{
|
||||
static class Util
|
||||
{
|
||||
public static void ExtractPackagesFromMix(string srcPath, string destPath, string mix, params string[] packages)
|
||||
public static void ExtractFromPackage(string srcPath, string package, string[] files, string destPath)
|
||||
{
|
||||
if (!Directory.Exists(srcPath)) { Console.WriteLine("Error: Path {0} does not exist", srcPath); return; }
|
||||
if (!Directory.Exists(destPath)) { Console.WriteLine("Error: Path {0} does not exist", destPath); return; }
|
||||
|
||||
FileSystem.Mount(srcPath);
|
||||
if (!FileSystem.Exists(mix)) { Console.WriteLine("Error: Could not find {1} in path {0}", srcPath, mix); return; }
|
||||
FileSystem.Mount(mix);
|
||||
if (!FileSystem.Exists(package)) { Console.WriteLine("Error: Could not find {0}", package); return; }
|
||||
FileSystem.Mount(package);
|
||||
|
||||
if (!Directory.Exists(destPath))
|
||||
Directory.CreateDirectory(destPath);
|
||||
|
||||
foreach (string s in packages)
|
||||
foreach (string s in files)
|
||||
{
|
||||
var destFile = "{0}{1}{2}".F(destPath, Path.DirectorySeparatorChar, s);
|
||||
using (var sourceStream = FileSystem.Open(s))
|
||||
using (var destStream = File.Create(destFile))
|
||||
{
|
||||
Console.WriteLine("Extracting {0}", s);
|
||||
Console.WriteLine("Extracting: {0}", s);
|
||||
destStream.Write(sourceStream.ReadAllBytes());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user