added The First Decade Installation Logic
This commit is contained in:
@@ -39,6 +39,12 @@ namespace OpenRA.Mods.Common
|
|||||||
public readonly string MusicPackageMirrorList = null;
|
public readonly string MusicPackageMirrorList = null;
|
||||||
public readonly int ShippedSoundtracks = 0;
|
public readonly int ShippedSoundtracks = 0;
|
||||||
|
|
||||||
|
/// <summary> InstallShield .cab File Ids, used to extract Mod specific files </summary>
|
||||||
|
public readonly int[] InstallShieldCABFileIds = { };
|
||||||
|
|
||||||
|
/// <summary> InstallShield .cab File Ids, used to extract Mod specific archives and extract contents of ExtractFilesFromCD </summary>
|
||||||
|
public readonly string[] InstallShieldCABFilePackageIds = { };
|
||||||
|
|
||||||
public static Dictionary<string, string[]> LoadFilesToExtract(MiniYaml yaml)
|
public static Dictionary<string, string[]> LoadFilesToExtract(MiniYaml yaml)
|
||||||
{
|
{
|
||||||
var md = yaml.ToDictionary();
|
var md = yaml.ToDictionary();
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ using System;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
using OpenRA.FileSystem;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
|
|
||||||
namespace OpenRA.Mods.Common.Widgets.Logic
|
namespace OpenRA.Mods.Common.Widgets.Logic
|
||||||
@@ -51,12 +52,26 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
return installData.DiskTestFiles.All(f => File.Exists(Path.Combine(diskRoot, f)));
|
return installData.DiskTestFiles.All(f => File.Exists(Path.Combine(diskRoot, f)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IsTFD(string diskpath)
|
||||||
|
{
|
||||||
|
var test = File.Exists(Path.Combine(diskpath, "data1.hdr"));
|
||||||
|
var i = 0;
|
||||||
|
|
||||||
|
while (test && i < 14)
|
||||||
|
test &= File.Exists(Path.Combine(diskpath, "data{0}.cab".F(++i)));
|
||||||
|
|
||||||
|
return test;
|
||||||
|
}
|
||||||
|
|
||||||
void CheckForDisk()
|
void CheckForDisk()
|
||||||
{
|
{
|
||||||
var path = InstallUtils.GetMountedDisk(IsValidDisk);
|
var path = InstallUtils.GetMountedDisk(IsValidDisk);
|
||||||
|
|
||||||
if (path != null)
|
if (path != null)
|
||||||
Install(path);
|
Install(path);
|
||||||
|
else if ((installData.InstallShieldCABFileIds.Length != 0 || installData.InstallShieldCABFilePackageIds.Length != 0)
|
||||||
|
&& (path = InstallUtils.GetMountedDisk(IsTFD)) != null)
|
||||||
|
InstallTFD(Platform.ResolvePath(path, "data1.hdr"));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
insertDiskContainer.IsVisible = () => true;
|
insertDiskContainer.IsVisible = () => true;
|
||||||
@@ -64,6 +79,63 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void InstallTFD(string source)
|
||||||
|
{
|
||||||
|
backButton.IsDisabled = () => true;
|
||||||
|
retryButton.IsDisabled = () => true;
|
||||||
|
insertDiskContainer.IsVisible = () => false;
|
||||||
|
installingContainer.IsVisible = () => true;
|
||||||
|
progressBar.Percentage = 0;
|
||||||
|
|
||||||
|
new Thread(() =>
|
||||||
|
{
|
||||||
|
using (var cabExtractor = new InstallShieldCABExtractor(source))
|
||||||
|
{
|
||||||
|
var denom = installData.InstallShieldCABFileIds.Length;
|
||||||
|
var extractFiles = installData.ExtractFilesFromCD;
|
||||||
|
|
||||||
|
if (installData.InstallShieldCABFilePackageIds.Length > 0)
|
||||||
|
denom += extractFiles.SelectMany(x => x.Value).Count();
|
||||||
|
|
||||||
|
var installPercent = 100 / denom;
|
||||||
|
|
||||||
|
foreach (uint index in installData.InstallShieldCABFileIds)
|
||||||
|
{
|
||||||
|
var filename = cabExtractor.FileName(index);
|
||||||
|
statusLabel.GetText = () => "Extracting {0}".F(filename);
|
||||||
|
var dest = Platform.ResolvePath("^", "Content", Game.ModData.Manifest.Mod.Id, filename.ToLowerInvariant());
|
||||||
|
cabExtractor.ExtractFile(index, dest);
|
||||||
|
progressBar.Percentage += installPercent;
|
||||||
|
}
|
||||||
|
|
||||||
|
var ArchivesToExtract = installData.InstallShieldCABFilePackageIds.Select(x => x.Split(':'));
|
||||||
|
var destDir = Platform.ResolvePath("^", "Content", Game.ModData.Manifest.Mod.Id);
|
||||||
|
var onError = (Action<string>)(s => { });
|
||||||
|
var overwrite = installData.OverwriteFiles;
|
||||||
|
|
||||||
|
var onProgress = (Action<string>)(s => Game.RunAfterTick(() =>
|
||||||
|
{
|
||||||
|
progressBar.Percentage += installPercent;
|
||||||
|
|
||||||
|
statusLabel.GetText = () => s;
|
||||||
|
}));
|
||||||
|
|
||||||
|
foreach (var archive in ArchivesToExtract)
|
||||||
|
{
|
||||||
|
var filename = cabExtractor.FileName(uint.Parse(archive[0]));
|
||||||
|
statusLabel.GetText = () => "Extracting {0}".F(filename);
|
||||||
|
var destFile = Platform.ResolvePath("^", "Content", Game.ModData.Manifest.Mod.Id, filename.ToLowerInvariant());
|
||||||
|
cabExtractor.ExtractFile(uint.Parse(archive[0]), destFile);
|
||||||
|
var annotation = archive.Length > 1 ? archive[1] : null;
|
||||||
|
InstallUtils.ExtractFromPackage(source, destFile, annotation, extractFiles, destDir, overwrite, onProgress, onError);
|
||||||
|
progressBar.Percentage += installPercent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
continueLoading();
|
||||||
|
}) { IsBackground = true }.Start();
|
||||||
|
}
|
||||||
|
|
||||||
void Install(string source)
|
void Install(string source)
|
||||||
{
|
{
|
||||||
backButton.IsDisabled = () => true;
|
backButton.IsDisabled = () => true;
|
||||||
|
|||||||
@@ -153,6 +153,7 @@ ContentInstaller:
|
|||||||
.: conquer.mix, desert.mix, general.mix, scores.mix, sounds.mix, temperat.mix, winter.mix
|
.: 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
|
||||||
|
InstallShieldCABFileIds: 66, 45, 42, 65, 68, 67, 71, 47, 49, 60, 75, 73, 53
|
||||||
|
|
||||||
ServerTraits:
|
ServerTraits:
|
||||||
LobbyCommands
|
LobbyCommands
|
||||||
|
|||||||
@@ -152,6 +152,8 @@ ContentInstaller:
|
|||||||
.: INSTALL/REDALERT.MIX
|
.: INSTALL/REDALERT.MIX
|
||||||
ShippedSoundtracks: 2
|
ShippedSoundtracks: 2
|
||||||
MusicPackageMirrorList: http://www.openra.net/packages/ra-music-mirrors.txt
|
MusicPackageMirrorList: http://www.openra.net/packages/ra-music-mirrors.txt
|
||||||
|
InstallShieldCABFilePackageIds: 105
|
||||||
|
InstallShieldCABFileIds: 116
|
||||||
|
|
||||||
ServerTraits:
|
ServerTraits:
|
||||||
LobbyCommands
|
LobbyCommands
|
||||||
|
|||||||
@@ -201,6 +201,8 @@ ContentInstaller:
|
|||||||
.: cache.mix, conquer.mix, isosnow.mix, isotemp.mix, local.mix, sidec01.mix, sidec02.mix, sno.mix, snow.mix, sounds.mix, speech01.mix, tem.mix, temperat.mix
|
.: cache.mix, conquer.mix, isosnow.mix, isotemp.mix, local.mix, sidec01.mix, sidec02.mix, sno.mix, snow.mix, sounds.mix, speech01.mix, tem.mix, temperat.mix
|
||||||
ShippedSoundtracks: 2
|
ShippedSoundtracks: 2
|
||||||
MusicPackageMirrorList: http://www.openra.net/packages/ts-music-mirrors.txt
|
MusicPackageMirrorList: http://www.openra.net/packages/ts-music-mirrors.txt
|
||||||
|
InstallShieldCABFilePackageIds: 332:CRC32
|
||||||
|
InstallShieldCABFileIds: 323, 364
|
||||||
|
|
||||||
ServerTraits:
|
ServerTraits:
|
||||||
LobbyCommands
|
LobbyCommands
|
||||||
|
|||||||
Reference in New Issue
Block a user