@@ -44,18 +44,21 @@ namespace OpenRA
|
|||||||
if (!Directory.Exists(destPath))
|
if (!Directory.Exists(destPath))
|
||||||
Directory.CreateDirectory(destPath);
|
Directory.CreateDirectory(destPath);
|
||||||
|
|
||||||
if (!GlobalFileSystem.Exists(srcPath)) { onError("Cannot find " + package); return false; }
|
Log.Write("debug", "Mounting {0}".F(srcPath));
|
||||||
GlobalFileSystem.Mount(srcPath);
|
GlobalFileSystem.Mount(srcPath);
|
||||||
if (!GlobalFileSystem.Exists(package)) { onError("Cannot find " + package); return false; }
|
Log.Write("debug", "Mounting {0}".F(package));
|
||||||
GlobalFileSystem.Mount(package);
|
GlobalFileSystem.Mount(package);
|
||||||
|
|
||||||
foreach (var s in files)
|
foreach (var file in files)
|
||||||
{
|
{
|
||||||
var destFile = Path.Combine(destPath, s);
|
var dest = Path.Combine(destPath, file);
|
||||||
using (var sourceStream = GlobalFileSystem.Open(s))
|
if (File.Exists(dest))
|
||||||
using (var destStream = File.Create(destFile))
|
File.Delete(dest);
|
||||||
|
using (var sourceStream = GlobalFileSystem.Open(file))
|
||||||
|
using (var destStream = File.Create(dest))
|
||||||
{
|
{
|
||||||
onProgress("Extracting " + s);
|
Log.Write("debug", "Extracting {0} to {1}".F(file, dest));
|
||||||
|
onProgress("Extracting " + file);
|
||||||
destStream.Write(sourceStream.ReadAllBytes());
|
destStream.Write(sourceStream.ReadAllBytes());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -75,8 +78,12 @@ namespace OpenRA
|
|||||||
}
|
}
|
||||||
|
|
||||||
var destFile = Path.GetFileName(file).ToLowerInvariant();
|
var destFile = Path.GetFileName(file).ToLowerInvariant();
|
||||||
onProgress("Extracting " + destFile);
|
var dest = Path.Combine(destPath, destFile);
|
||||||
File.Copy(fromPath, Path.Combine(destPath, destFile), true);
|
if (File.Exists(dest))
|
||||||
|
File.Delete(dest);
|
||||||
|
onProgress("Copying " + destFile);
|
||||||
|
Log.Write("debug", "Copy {0} to {1}".F(fromPath, dest));
|
||||||
|
File.Copy(fromPath, dest, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
|
|
||||||
bool IsValidDisk(string diskRoot)
|
bool IsValidDisk(string diskRoot)
|
||||||
{
|
{
|
||||||
var files = Game.modData.Manifest.ContentInstaller["DiskTestFiles"].Split(',');
|
var files = Game.modData.Manifest.ContentInstaller["DiskTestFiles"].Split(',').Select(x => x.Trim()).ToArray();
|
||||||
return files.All(f => File.Exists(Path.Combine(diskRoot, f)));
|
return files.All(f => File.Exists(Path.Combine(diskRoot, f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,10 +71,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
installingContainer.IsVisible = () => true;
|
installingContainer.IsVisible = () => true;
|
||||||
|
|
||||||
var dest = new string[] { Platform.SupportDir, "Content", Game.modData.Manifest.Mod.Id }.Aggregate(Path.Combine);
|
var dest = new string[] { Platform.SupportDir, "Content", Game.modData.Manifest.Mod.Id }.Aggregate(Path.Combine);
|
||||||
var copyFiles = Game.modData.Manifest.ContentInstaller["CopyFilesFromCD"].Split(',');
|
var copyFiles = Game.modData.Manifest.ContentInstaller["CopyFilesFromCD"].Split(',').Select(x => x.Trim()).ToArray();
|
||||||
|
|
||||||
var extractPackage = Game.modData.Manifest.ContentInstaller["PackageToExtractFromCD"];
|
var extractPackage = Game.modData.Manifest.ContentInstaller["PackageToExtractFromCD"].Trim();
|
||||||
var extractFiles = Game.modData.Manifest.ContentInstaller["ExtractFilesFromCD"].Split(',');
|
var extractFiles = Game.modData.Manifest.ContentInstaller["ExtractFilesFromCD"].Split(',').Select(x => x.Trim()).ToArray();
|
||||||
|
|
||||||
var installCounter = 0;
|
var installCounter = 0;
|
||||||
var installTotal = copyFiles.Count() + extractFiles.Count();
|
var installTotal = copyFiles.Count() + extractFiles.Count();
|
||||||
@@ -93,16 +93,24 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
retryButton.IsDisabled = () => false;
|
retryButton.IsDisabled = () => false;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
var t = new Thread( _ =>
|
new Thread(() =>
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!InstallUtils.CopyFiles(source, copyFiles, dest, onProgress, onError))
|
if (!InstallUtils.CopyFiles(source, copyFiles, dest, onProgress, onError))
|
||||||
|
{
|
||||||
|
onError("Copying files from CD failed.");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(extractPackage))
|
if (!string.IsNullOrEmpty(extractPackage))
|
||||||
|
{
|
||||||
if (!InstallUtils.ExtractFromPackage(source, extractPackage, extractFiles, dest, onProgress, onError))
|
if (!InstallUtils.ExtractFromPackage(source, extractPackage, extractFiles, dest, onProgress, onError))
|
||||||
|
{
|
||||||
|
onError("Extracting files from CD failed.");
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Game.RunAfterTick(() =>
|
Game.RunAfterTick(() =>
|
||||||
{
|
{
|
||||||
@@ -111,12 +119,13 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
|||||||
continueLoading();
|
continueLoading();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
catch
|
catch(Exception e)
|
||||||
{
|
{
|
||||||
onError("Installation failed");
|
onError("Installation failed.\n{0}".F(e.Message));
|
||||||
|
Log.Write("debug", e.ToString());
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}) { IsBackground = true };
|
}) { IsBackground = true }.Start();
|
||||||
t.Start();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,10 +137,10 @@ ContentInstaller:
|
|||||||
FilesToCopy: CONQUER.MIX, DESERT.MIX, SCORES.MIX, SOUNDS.MIX, TEMPERAT.MIX, WINTER.MIX
|
FilesToCopy: CONQUER.MIX, DESERT.MIX, SCORES.MIX, SOUNDS.MIX, TEMPERAT.MIX, WINTER.MIX
|
||||||
FilesToExtract: speech.mix, tempicnh.mix, transit.mix
|
FilesToExtract: speech.mix, tempicnh.mix, transit.mix
|
||||||
PackageMirrorList: http://openra.net/packages/cnc-mirrors.txt
|
PackageMirrorList: http://openra.net/packages/cnc-mirrors.txt
|
||||||
DiskTestFiles: CONQUER.MIX, DESERT.MIX INSTALL/SETUP.Z
|
DiskTestFiles: conquer.mix, desert.mix, install/setup.z
|
||||||
PackageToExtractFromCD: INSTALL/SETUP.Z
|
PackageToExtractFromCD: install/setup.z
|
||||||
ExtractFilesFromCD: speech.mix, tempicnh.mix, transit.mix
|
ExtractFilesFromCD: speech.mix, tempicnh.mix, transit.mix
|
||||||
CopyFilesFromCD: CONQUER.MIX, DESERT.MIX, SCORES.MIX, SOUNDS.MIX, TEMPERAT.MIX, WINTER.MIX
|
CopyFilesFromCD: conquer.mix, desert.mix, general.mix, scores.mix, sounds.mix, temperat.mix, winter.mix
|
||||||
ShippedSoundtracks: 2
|
ShippedSoundtracks: 2
|
||||||
MusicPackageMirrorList: http://www.openra.net/packages/cnc-music-mirrors.txt
|
MusicPackageMirrorList: http://www.openra.net/packages/cnc-music-mirrors.txt
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user