Remove legacy installation logic.
This commit is contained in:
@@ -1,43 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2016 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
namespace OpenRA
|
||||
{
|
||||
// Referenced from ModMetadata, so needs to be in OpenRA.Game :(
|
||||
public class ContentInstaller : IGlobalModData
|
||||
{
|
||||
public enum FilenameCase { Input, ForceLower, ForceUpper }
|
||||
|
||||
public readonly string[] TestFiles = { };
|
||||
public readonly string[] DiskTestFiles = { };
|
||||
public readonly string PackageToExtractFromCD = null;
|
||||
public readonly bool OverwriteFiles = true;
|
||||
|
||||
public readonly FilenameCase OutputFilenameCase = FilenameCase.ForceLower;
|
||||
public readonly Dictionary<string, string[]> CopyFilesFromCD = new Dictionary<string, string[]>();
|
||||
public readonly Dictionary<string, string[]> ExtractFilesFromCD = new Dictionary<string, string[]>();
|
||||
|
||||
public readonly string PackageMirrorList = null;
|
||||
|
||||
public readonly string MusicPackageMirrorList = null;
|
||||
public readonly int ShippedSoundtracks = 0;
|
||||
|
||||
/// <summary> InstallShield .CAB file IDs, used to extract Mod-specific files. </summary>
|
||||
public readonly HashSet<int> InstallShieldCABFileIds = new HashSet<int>();
|
||||
|
||||
/// <summary> InstallShield .CAB file IDs, used to extract Mod-specific archives and extract contents of ExtractFilesFromCD. </summary>
|
||||
public readonly HashSet<string> InstallShieldCABFilePackageIds = new HashSet<string>();
|
||||
}
|
||||
}
|
||||
@@ -344,8 +344,10 @@ namespace OpenRA
|
||||
using (new PerfTimer("LoadMaps"))
|
||||
ModData.MapCache.LoadMaps();
|
||||
|
||||
var installData = ModData.Manifest.Get<ContentInstaller>();
|
||||
var isModContentInstalled = installData.TestFiles.All(f => File.Exists(Platform.ResolvePath(f)));
|
||||
var content = ModData.Manifest.Get<ModContent>();
|
||||
var isModContentInstalled = content.Packages
|
||||
.Where(p => p.Value.Required)
|
||||
.All(p => p.Value.TestFiles.All(f => File.Exists(Platform.ResolvePath(f))));
|
||||
|
||||
// Mod assets are missing!
|
||||
if (!isModContentInstalled)
|
||||
|
||||
@@ -30,7 +30,6 @@ namespace OpenRA
|
||||
public bool Hidden;
|
||||
|
||||
public Dictionary<string, string> RequiresMods;
|
||||
public ContentInstaller Content;
|
||||
public ModContent ModContent;
|
||||
public IReadOnlyPackage Package;
|
||||
|
||||
@@ -79,9 +78,6 @@ namespace OpenRA
|
||||
else
|
||||
metadata.RequiresMods = new Dictionary<string, string>();
|
||||
|
||||
if (nd.ContainsKey("ContentInstaller"))
|
||||
metadata.Content = FieldLoader.Load<ContentInstaller>(nd["ContentInstaller"]);
|
||||
|
||||
if (nd.ContainsKey("ModContent"))
|
||||
metadata.ModContent = FieldLoader.Load<ModContent>(nd["ModContent"]);
|
||||
|
||||
|
||||
@@ -103,7 +103,6 @@
|
||||
<Compile Include="FileSystem\BagFile.cs" />
|
||||
<Compile Include="Map\MapGrid.cs" />
|
||||
<Compile Include="Map\MapPlayers.cs" />
|
||||
<Compile Include="ContentInstaller.cs" />
|
||||
<Compile Include="MPos.cs" />
|
||||
<Compile Include="Download.cs" />
|
||||
<Compile Include="Effects\AsyncAction.cs" />
|
||||
|
||||
@@ -1,189 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2016 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using ICSharpCode.SharpZipLib;
|
||||
using ICSharpCode.SharpZipLib.Zip;
|
||||
using OpenRA.FileSystem;
|
||||
|
||||
namespace OpenRA.Mods.Common
|
||||
{
|
||||
public static class InstallUtils
|
||||
{
|
||||
static IEnumerable<ZipEntry> GetEntries(this ZipInputStream z)
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
var e = z.GetNextEntry();
|
||||
if (e != null) yield return e; else break;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetMountedDisk(Func<string, bool> isValidDisk)
|
||||
{
|
||||
var volumes = DriveInfo.GetDrives()
|
||||
.Where(v => v.DriveType == DriveType.CDRom && v.IsReady)
|
||||
.Select(v => v.RootDirectory.FullName);
|
||||
|
||||
return volumes.FirstOrDefault(isValidDisk);
|
||||
}
|
||||
|
||||
static string GetFileName(string path, ContentInstaller.FilenameCase caseModifier)
|
||||
{
|
||||
// Gets the file path, splitting on both / and \
|
||||
var index = path.LastIndexOfAny(new[] { '\\', '/' });
|
||||
var output = path.Substring(index + 1);
|
||||
|
||||
switch (caseModifier)
|
||||
{
|
||||
case ContentInstaller.FilenameCase.ForceLower:
|
||||
return output.ToLowerInvariant();
|
||||
case ContentInstaller.FilenameCase.ForceUpper:
|
||||
return output.ToUpperInvariant();
|
||||
default:
|
||||
return output;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: The package should be mounted into its own context to avoid name collisions with installed files
|
||||
public static bool ExtractFromPackage(FileSystem.FileSystem fileSystem, string srcPath, string package, Dictionary<string, string[]> filesByDirectory,
|
||||
string destPath, bool overwrite, ContentInstaller.FilenameCase caseModifier, Action<string> onProgress, Action<string> onError)
|
||||
{
|
||||
Directory.CreateDirectory(destPath);
|
||||
|
||||
Log.Write("debug", "Mounting {0}".F(srcPath));
|
||||
fileSystem.Mount(srcPath);
|
||||
Log.Write("debug", "Mounting {0}".F(package));
|
||||
fileSystem.Mount(package);
|
||||
|
||||
foreach (var directory in filesByDirectory)
|
||||
{
|
||||
var targetDir = directory.Key;
|
||||
|
||||
foreach (var file in directory.Value)
|
||||
{
|
||||
var containingDir = Path.Combine(destPath, targetDir);
|
||||
var dest = Path.Combine(containingDir, GetFileName(file, caseModifier));
|
||||
if (File.Exists(dest))
|
||||
{
|
||||
if (overwrite)
|
||||
File.Delete(dest);
|
||||
else
|
||||
{
|
||||
Log.Write("debug", "Skipping {0}".F(dest));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(containingDir);
|
||||
|
||||
using (var sourceStream = fileSystem.Open(file))
|
||||
using (var destStream = File.Create(dest))
|
||||
{
|
||||
Log.Write("debug", "Extracting {0} to {1}".F(file, dest));
|
||||
onProgress("Extracting " + file);
|
||||
destStream.Write(sourceStream.ReadAllBytes());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool CopyFiles(string srcPath, Dictionary<string, string[]> files, string destPath,
|
||||
bool overwrite, ContentInstaller.FilenameCase caseModifier, Action<string> onProgress, Action<string> onError)
|
||||
{
|
||||
Directory.CreateDirectory(destPath);
|
||||
|
||||
foreach (var folder in files)
|
||||
{
|
||||
var targetDir = folder.Key;
|
||||
|
||||
foreach (var file in folder.Value)
|
||||
{
|
||||
var sourcePath = Path.Combine(srcPath, file);
|
||||
if (!File.Exists(sourcePath))
|
||||
{
|
||||
onError("Cannot find " + file);
|
||||
return false;
|
||||
}
|
||||
|
||||
var destFile = GetFileName(file, caseModifier);
|
||||
var containingDir = Path.Combine(destPath, targetDir);
|
||||
var dest = Path.Combine(containingDir, destFile);
|
||||
if (File.Exists(dest) && !overwrite)
|
||||
{
|
||||
Log.Write("debug", "Skipping {0}".F(dest));
|
||||
continue;
|
||||
}
|
||||
|
||||
Directory.CreateDirectory(containingDir);
|
||||
|
||||
onProgress("Copying " + destFile);
|
||||
Log.Write("debug", "Copy {0} to {1}".F(sourcePath, dest));
|
||||
File.Copy(sourcePath, dest, true);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static bool ExtractZip(string zipFile, string dest, Action<string> onProgress, Action<string> onError)
|
||||
{
|
||||
if (!File.Exists(zipFile))
|
||||
{
|
||||
onError("Invalid path: " + zipFile);
|
||||
return false;
|
||||
}
|
||||
|
||||
var extracted = new List<string>();
|
||||
try
|
||||
{
|
||||
using (var stream = File.OpenRead(zipFile))
|
||||
using (var z = new ZipInputStream(stream))
|
||||
z.ExtractZip(dest, extracted, s => onProgress("Extracting " + s));
|
||||
}
|
||||
catch (SharpZipBaseException)
|
||||
{
|
||||
foreach (var f in extracted)
|
||||
File.Delete(f);
|
||||
|
||||
onError("Invalid archive");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// TODO: this belongs in FileSystem/ZipFile
|
||||
static void ExtractZip(this ZipInputStream z, string destPath, List<string> extracted, Action<string> onProgress)
|
||||
{
|
||||
foreach (var entry in z.GetEntries())
|
||||
{
|
||||
if (!entry.IsFile) continue;
|
||||
|
||||
onProgress(entry.Name);
|
||||
|
||||
Directory.CreateDirectory(Path.Combine(destPath, Path.GetDirectoryName(entry.Name)));
|
||||
var path = Path.Combine(destPath, entry.Name);
|
||||
extracted.Add(path);
|
||||
|
||||
using (var f = File.Create(path))
|
||||
z.CopyTo(f);
|
||||
}
|
||||
|
||||
z.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -610,10 +610,7 @@
|
||||
<Compile Include="Widgets\Logic\Ingame\SupportPowerBinLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\Ingame\SupportPowerTooltipLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\Ingame\WorldTooltipLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\Installation\InstallFromCDLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\Installation\DownloadPackagesLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\Installation\InstallModLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\Installation\InstallLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\Lobby\ClientTooltipLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\Lobby\KickClientLogic.cs" />
|
||||
<Compile Include="Widgets\Logic\Lobby\KickSpectatorsLogic.cs" />
|
||||
@@ -661,7 +658,6 @@
|
||||
<Compile Include="LoadScreens\LogoStripeLoadScreen.cs" />
|
||||
<Compile Include="LoadScreens\BlankLoadScreen.cs" />
|
||||
<Compile Include="Widgets\Logic\ReplayUtils.cs" />
|
||||
<Compile Include="InstallUtils.cs" />
|
||||
<Compile Include="Graphics\DefaultSpriteSequence.cs" />
|
||||
<Compile Include="Widgets\BackgroundWidget.cs" />
|
||||
<Compile Include="Widgets\ButtonWidget.cs" />
|
||||
|
||||
@@ -74,10 +74,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
else
|
||||
{
|
||||
// Start playback with a random song, but only if the player has installed more music
|
||||
var installData = Game.ModData.Manifest.Get<ContentInstaller>();
|
||||
if (playlist.Length > installData.ShippedSoundtracks)
|
||||
currentSong = random.FirstOrDefault();
|
||||
// Start playback with a random song
|
||||
currentSong = random.FirstOrDefault();
|
||||
}
|
||||
|
||||
if (SongExists(info.StartingMusic))
|
||||
|
||||
@@ -1,159 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2016 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Text;
|
||||
using OpenRA.Support;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
public class DownloadPackagesLogic : ChromeLogic
|
||||
{
|
||||
static readonly string[] SizeSuffixes = { "bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" };
|
||||
readonly Widget panel;
|
||||
readonly string modId;
|
||||
readonly string mirrorListUrl;
|
||||
readonly ProgressBarWidget progressBar;
|
||||
readonly LabelWidget statusLabel;
|
||||
readonly Action afterInstall;
|
||||
string mirror;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public DownloadPackagesLogic(Widget widget, Action afterInstall, string mirrorListUrl, string modId)
|
||||
{
|
||||
this.mirrorListUrl = mirrorListUrl;
|
||||
this.afterInstall = afterInstall;
|
||||
this.modId = modId;
|
||||
|
||||
panel = widget.Get("INSTALL_DOWNLOAD_PANEL");
|
||||
progressBar = panel.Get<ProgressBarWidget>("PROGRESS_BAR");
|
||||
statusLabel = panel.Get<LabelWidget>("STATUS_LABEL");
|
||||
|
||||
var text = "Downloading {0} assets...".F(ModMetadata.AllMods[modId].Title);
|
||||
panel.Get<LabelWidget>("TITLE").Text = text;
|
||||
|
||||
ShowDownloadDialog();
|
||||
}
|
||||
|
||||
void ShowDownloadDialog()
|
||||
{
|
||||
statusLabel.GetText = () => "Fetching list of mirrors...";
|
||||
progressBar.Indeterminate = true;
|
||||
|
||||
var retryButton = panel.Get<ButtonWidget>("RETRY_BUTTON");
|
||||
retryButton.IsVisible = () => false;
|
||||
|
||||
var cancelButton = panel.Get<ButtonWidget>("CANCEL_BUTTON");
|
||||
|
||||
var file = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
|
||||
var dest = Platform.ResolvePath("^", "Content", modId);
|
||||
|
||||
Action<DownloadProgressChangedEventArgs> onDownloadProgress = i =>
|
||||
{
|
||||
var dataReceived = 0.0f;
|
||||
var dataTotal = 0.0f;
|
||||
var mag = 0;
|
||||
var dataSuffix = "";
|
||||
|
||||
if (i.TotalBytesToReceive < 0)
|
||||
{
|
||||
dataTotal = float.NaN;
|
||||
dataReceived = i.BytesReceived;
|
||||
dataSuffix = SizeSuffixes[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
mag = (int)Math.Log(i.TotalBytesToReceive, 1024);
|
||||
dataTotal = i.TotalBytesToReceive / (float)(1L << (mag * 10));
|
||||
dataReceived = i.BytesReceived / (float)(1L << (mag * 10));
|
||||
dataSuffix = SizeSuffixes[mag];
|
||||
}
|
||||
|
||||
progressBar.Indeterminate = false;
|
||||
progressBar.Percentage = i.ProgressPercentage;
|
||||
|
||||
statusLabel.GetText = () => "Downloading from {4} {1:0.00}/{2:0.00} {3} ({0}%)".F(i.ProgressPercentage,
|
||||
dataReceived, dataTotal, dataSuffix,
|
||||
mirror != null ? new Uri(mirror).Host : "unknown host");
|
||||
};
|
||||
|
||||
Action<string> onExtractProgress = s => Game.RunAfterTick(() => statusLabel.GetText = () => s);
|
||||
|
||||
Action<string> onError = s => Game.RunAfterTick(() =>
|
||||
{
|
||||
statusLabel.GetText = () => "Error: " + s;
|
||||
retryButton.IsVisible = () => true;
|
||||
});
|
||||
|
||||
Action<AsyncCompletedEventArgs, bool> onDownloadComplete = (i, cancelled) =>
|
||||
{
|
||||
if (i.Error != null)
|
||||
{
|
||||
onError(Download.FormatErrorMessage(i.Error));
|
||||
return;
|
||||
}
|
||||
|
||||
if (cancelled)
|
||||
{
|
||||
onError("Download cancelled");
|
||||
return;
|
||||
}
|
||||
|
||||
// Automatically extract
|
||||
statusLabel.GetText = () => "Extracting...";
|
||||
progressBar.Indeterminate = true;
|
||||
if (InstallUtils.ExtractZip(file, dest, onExtractProgress, onError))
|
||||
{
|
||||
Game.RunAfterTick(() =>
|
||||
{
|
||||
Ui.CloseWindow();
|
||||
afterInstall();
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
Action<DownloadDataCompletedEventArgs, bool> onFetchMirrorsComplete = (i, cancelled) =>
|
||||
{
|
||||
progressBar.Indeterminate = true;
|
||||
|
||||
if (i.Error != null)
|
||||
{
|
||||
onError(Download.FormatErrorMessage(i.Error));
|
||||
return;
|
||||
}
|
||||
|
||||
if (cancelled)
|
||||
{
|
||||
onError("Download cancelled");
|
||||
return;
|
||||
}
|
||||
|
||||
var data = Encoding.UTF8.GetString(i.Result);
|
||||
var mirrorList = data.Split(new[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
mirror = mirrorList.Random(new MersenneTwister());
|
||||
|
||||
// Save the package to a temp file
|
||||
var dl = new Download(mirror, file, onDownloadProgress, onDownloadComplete);
|
||||
cancelButton.OnClick = () => { dl.Cancel(); Ui.CloseWindow(); };
|
||||
retryButton.OnClick = () => { dl.Cancel(); ShowDownloadDialog(); };
|
||||
};
|
||||
|
||||
// Get the list of mirrors
|
||||
var updateMirrors = new Download(mirrorListUrl, onDownloadProgress, onFetchMirrorsComplete);
|
||||
cancelButton.OnClick = () => { updateMirrors.Cancel(); Ui.CloseWindow(); };
|
||||
retryButton.OnClick = () => { updateMirrors.Cancel(); ShowDownloadDialog(); };
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,218 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2016 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using OpenRA.FileSystem;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
public class InstallFromCDLogic : ChromeLogic
|
||||
{
|
||||
readonly ModData modData;
|
||||
readonly string modId;
|
||||
readonly Widget panel;
|
||||
readonly ProgressBarWidget progressBar;
|
||||
readonly LabelWidget statusLabel;
|
||||
readonly Action afterInstall;
|
||||
readonly ButtonWidget retryButton, backButton;
|
||||
readonly Widget installingContainer, insertDiskContainer;
|
||||
readonly ContentInstaller installData;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public InstallFromCDLogic(Widget widget, ModData modData, Action afterInstall, string modId)
|
||||
{
|
||||
this.modData = modData;
|
||||
this.modId = modId;
|
||||
installData = ModMetadata.AllMods[modId].Content;
|
||||
this.afterInstall = afterInstall;
|
||||
panel = widget.Get("INSTALL_FROMCD_PANEL");
|
||||
progressBar = panel.Get<ProgressBarWidget>("PROGRESS_BAR");
|
||||
statusLabel = panel.Get<LabelWidget>("STATUS_LABEL");
|
||||
|
||||
backButton = panel.Get<ButtonWidget>("BACK_BUTTON");
|
||||
backButton.OnClick = Ui.CloseWindow;
|
||||
|
||||
retryButton = panel.Get<ButtonWidget>("RETRY_BUTTON");
|
||||
retryButton.OnClick = CheckForDisk;
|
||||
|
||||
installingContainer = panel.Get("INSTALLING");
|
||||
insertDiskContainer = panel.Get("INSERT_DISK");
|
||||
CheckForDisk();
|
||||
}
|
||||
|
||||
bool IsValidDisk(string diskRoot)
|
||||
{
|
||||
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()
|
||||
{
|
||||
var path = InstallUtils.GetMountedDisk(IsValidDisk);
|
||||
|
||||
if (path != null)
|
||||
Install(path);
|
||||
else if ((installData.InstallShieldCABFileIds.Count != 0 || installData.InstallShieldCABFilePackageIds.Count != 0)
|
||||
&& (path = InstallUtils.GetMountedDisk(IsTFD)) != null)
|
||||
InstallTFD(Platform.ResolvePath(path, "data1.hdr"));
|
||||
else
|
||||
{
|
||||
var text = "Please insert a {0} install CD and click Retry.".F(ModMetadata.AllMods[modId].Title);
|
||||
insertDiskContainer.Get<LabelWidget>("INFO2").Text = text;
|
||||
|
||||
insertDiskContainer.IsVisible = () => true;
|
||||
installingContainer.IsVisible = () => false;
|
||||
}
|
||||
}
|
||||
|
||||
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(modData.ModFiles, source))
|
||||
{
|
||||
var denom = installData.InstallShieldCABFileIds.Count;
|
||||
var extractFiles = installData.ExtractFilesFromCD;
|
||||
|
||||
if (installData.InstallShieldCABFilePackageIds.Count > 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", modId, filename.ToLowerInvariant());
|
||||
cabExtractor.ExtractFile(index, dest);
|
||||
progressBar.Percentage += installPercent;
|
||||
}
|
||||
|
||||
var ArchivesToExtract = installData.InstallShieldCABFilePackageIds.Select(x => x.Split(':'));
|
||||
var destDir = Platform.ResolvePath("^", "Content", modId);
|
||||
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", modId, filename.ToLowerInvariant());
|
||||
cabExtractor.ExtractFile(uint.Parse(archive[0]), destFile);
|
||||
InstallUtils.ExtractFromPackage(modData.ModFiles, source, destFile, extractFiles, destDir, overwrite, installData.OutputFilenameCase, onProgress, onError);
|
||||
progressBar.Percentage += installPercent;
|
||||
}
|
||||
}
|
||||
|
||||
Game.RunAfterTick(() =>
|
||||
{
|
||||
Ui.CloseWindow();
|
||||
afterInstall();
|
||||
});
|
||||
}) { IsBackground = true }.Start();
|
||||
}
|
||||
|
||||
void Install(string source)
|
||||
{
|
||||
backButton.IsDisabled = () => true;
|
||||
retryButton.IsDisabled = () => true;
|
||||
insertDiskContainer.IsVisible = () => false;
|
||||
installingContainer.IsVisible = () => true;
|
||||
var dest = Platform.ResolvePath("^", "Content", modId);
|
||||
var copyFiles = installData.CopyFilesFromCD;
|
||||
|
||||
var packageToExtract = installData.PackageToExtractFromCD.Split(':');
|
||||
var extractPackage = packageToExtract.First();
|
||||
|
||||
var extractFiles = installData.ExtractFilesFromCD;
|
||||
|
||||
var overwrite = installData.OverwriteFiles;
|
||||
var installCounter = 0;
|
||||
var installTotal = copyFiles.SelectMany(x => x.Value).Count() + extractFiles.SelectMany(x => x.Value).Count();
|
||||
var onProgress = (Action<string>)(s => Game.RunAfterTick(() =>
|
||||
{
|
||||
progressBar.Percentage = installCounter * 100 / installTotal;
|
||||
installCounter++;
|
||||
|
||||
statusLabel.GetText = () => s;
|
||||
}));
|
||||
|
||||
var onError = (Action<string>)(s => Game.RunAfterTick(() =>
|
||||
{
|
||||
statusLabel.GetText = () => "Error: " + s;
|
||||
backButton.IsDisabled = () => false;
|
||||
retryButton.IsDisabled = () => false;
|
||||
}));
|
||||
|
||||
new Thread(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
if (!InstallUtils.CopyFiles(source, copyFiles, dest, overwrite, installData.OutputFilenameCase, onProgress, onError))
|
||||
{
|
||||
onError("Copying files from CD failed.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(extractPackage))
|
||||
{
|
||||
if (!InstallUtils.ExtractFromPackage(modData.ModFiles, source, extractPackage, extractFiles, dest,
|
||||
overwrite, installData.OutputFilenameCase, onProgress, onError))
|
||||
{
|
||||
onError("Extracting files from CD failed.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Game.RunAfterTick(() =>
|
||||
{
|
||||
statusLabel.GetText = () => "Game assets have been extracted.";
|
||||
Ui.CloseWindow();
|
||||
afterInstall();
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
onError("Installation failed.\n{0}".F(e.Message));
|
||||
Log.Write("debug", e.ToString());
|
||||
return;
|
||||
}
|
||||
}) { IsBackground = true }.Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2016 The OpenRA Developers (see AUTHORS)
|
||||
* This file is part of OpenRA, which is free software. It is made
|
||||
* available to you under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation, either version 3 of
|
||||
* the License, or (at your option) any later version. For more
|
||||
* information, see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using OpenRA.Widgets;
|
||||
|
||||
namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
public class InstallLogic : ChromeLogic
|
||||
{
|
||||
[ObjectCreator.UseCtor]
|
||||
public InstallLogic(Widget widget, string mirrorListUrl, string modId)
|
||||
{
|
||||
var panel = widget.Get("INSTALL_PANEL");
|
||||
var widgetArgs = new WidgetArgs
|
||||
{
|
||||
{ "afterInstall", () => { Game.InitializeMod(modId, new Arguments()); } },
|
||||
{ "mirrorListUrl", mirrorListUrl },
|
||||
{ "modId", modId }
|
||||
};
|
||||
|
||||
var mod = ModMetadata.AllMods[modId];
|
||||
var text = "OpenRA requires the original {0} game content.".F(mod.Title);
|
||||
panel.Get<LabelWidget>("DESC1").Text = text;
|
||||
|
||||
var downloadButton = panel.Get<ButtonWidget>("DOWNLOAD_BUTTON");
|
||||
downloadButton.OnClick = () => Ui.OpenWindow("INSTALL_DOWNLOAD_PANEL", widgetArgs);
|
||||
downloadButton.IsDisabled = () => string.IsNullOrEmpty(mod.Content.PackageMirrorList);
|
||||
|
||||
panel.Get<ButtonWidget>("INSTALL_BUTTON").OnClick = () =>
|
||||
Ui.OpenWindow("INSTALL_FROMCD_PANEL", widgetArgs);
|
||||
|
||||
panel.Get<ButtonWidget>("BACK_BUTTON").OnClick = Ui.CloseWindow;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -185,29 +185,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
if (!IsModInstalled(mod))
|
||||
{
|
||||
if (mod.ModContent != null)
|
||||
var widgetArgs = new WidgetArgs
|
||||
{
|
||||
var widgetArgs = new WidgetArgs
|
||||
{
|
||||
{ "continueLoading", () =>
|
||||
Game.RunAfterTick(() => Game.InitializeMod(mod.Id, new Arguments())) },
|
||||
{ "modId", mod.Id }
|
||||
};
|
||||
{ "continueLoading", () =>
|
||||
Game.RunAfterTick(() => Game.InitializeMod(mod.Id, new Arguments())) },
|
||||
{ "modId", mod.Id }
|
||||
};
|
||||
|
||||
Ui.OpenWindow("CONTENT_PROMPT_PANEL", widgetArgs);
|
||||
}
|
||||
else
|
||||
{
|
||||
var widgetArgs = new WidgetArgs
|
||||
{
|
||||
{ "continueLoading", () =>
|
||||
Game.RunAfterTick(() => Game.InitializeMod(Game.Settings.Game.Mod, new Arguments())) },
|
||||
{ "mirrorListUrl", mod.Content.PackageMirrorList },
|
||||
{ "modId", mod.Id }
|
||||
};
|
||||
|
||||
Ui.OpenWindow("INSTALL_PANEL", widgetArgs);
|
||||
}
|
||||
Ui.OpenWindow("CONTENT_PROMPT_PANEL", widgetArgs);
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -222,7 +207,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
|
||||
static bool IsModInstalled(ModMetadata mod)
|
||||
{
|
||||
return mod.Content.TestFiles.All(file => File.Exists(Path.GetFullPath(Platform.ResolvePath(file))));
|
||||
return mod.ModContent.Packages
|
||||
.Where(p => p.Value.Required)
|
||||
.All(p => p.Value.TestFiles.All(f => File.Exists(Platform.ResolvePath(f))));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,196 +0,0 @@
|
||||
Container@INSTALL_PANEL:
|
||||
Logic: InstallLogic
|
||||
X: (WINDOW_RIGHT - WIDTH)/2
|
||||
Y: (WINDOW_BOTTOM - HEIGHT)/2
|
||||
Width: 500
|
||||
Height: 177
|
||||
Children:
|
||||
Background:
|
||||
Width: PARENT_RIGHT
|
||||
Height: PARENT_BOTTOM
|
||||
Background: panel-bg
|
||||
Background@RULE:
|
||||
X: 30
|
||||
Y: 50
|
||||
Width: 440
|
||||
Height:150
|
||||
Background:panel-rule
|
||||
Label@TITLE:
|
||||
X: 0
|
||||
Y: 12
|
||||
Width: PARENT_RIGHT
|
||||
Height: 25
|
||||
Text: Install Assets
|
||||
Align: Center
|
||||
Font: MediumBold
|
||||
Label@DESC1:
|
||||
X: 0
|
||||
Y: 65
|
||||
Width: PARENT_RIGHT
|
||||
Height: 25
|
||||
Align: Center
|
||||
Label@DESC2:
|
||||
X: 0
|
||||
Y: 85
|
||||
Width: PARENT_RIGHT
|
||||
Height: 25
|
||||
Text: Content can be downloaded (if available), or copied from the install CD.
|
||||
Align: Center
|
||||
Button@DOWNLOAD_BUTTON:
|
||||
X: 20
|
||||
Y: PARENT_BOTTOM - 52
|
||||
Background:button-highlighted
|
||||
Width: 110
|
||||
Height: 32
|
||||
Text: Download
|
||||
Font: Bold
|
||||
Button@INSTALL_BUTTON:
|
||||
X: 140
|
||||
Y: PARENT_BOTTOM - 52
|
||||
Background:button-highlighted
|
||||
Width: 110
|
||||
Height: 32
|
||||
Text: Use CD
|
||||
Font: Bold
|
||||
Button@BACK_BUTTON:
|
||||
X: PARENT_RIGHT - 130
|
||||
Y: PARENT_BOTTOM - 52
|
||||
Background:button-highlighted
|
||||
Width: 110
|
||||
Height: 32
|
||||
Text: Back
|
||||
Font: Bold
|
||||
Key: escape
|
||||
|
||||
Container@INSTALL_DOWNLOAD_PANEL:
|
||||
Logic: DownloadPackagesLogic
|
||||
X: (WINDOW_RIGHT - WIDTH)/2
|
||||
Y: (WINDOW_BOTTOM - HEIGHT)/2
|
||||
Width: 500
|
||||
Height: 177
|
||||
Children:
|
||||
Background:
|
||||
Width: PARENT_RIGHT
|
||||
Height: PARENT_BOTTOM
|
||||
Background: panel-bg
|
||||
Background@RULE:
|
||||
X: 30
|
||||
Y: 50
|
||||
Width: 440
|
||||
Height:150
|
||||
Background:panel-rule
|
||||
Label@TITLE:
|
||||
X: 0
|
||||
Y: 12
|
||||
Width: PARENT_RIGHT
|
||||
Height: 25
|
||||
Align: Center
|
||||
Font: MediumBold
|
||||
ProgressBar@PROGRESS_BAR:
|
||||
X: 50
|
||||
Y: 64
|
||||
Width: PARENT_RIGHT - 100
|
||||
Height: 16
|
||||
BarMargin: 0, 0
|
||||
Label@STATUS_LABEL:
|
||||
X: 36
|
||||
Y: 85
|
||||
Width: PARENT_RIGHT - 100
|
||||
Height: 25
|
||||
Align: Left
|
||||
Button@RETRY_BUTTON:
|
||||
X: PARENT_RIGHT - 280
|
||||
Y: PARENT_BOTTOM - 52
|
||||
Background:button-highlighted
|
||||
Width: 120
|
||||
Height: 32
|
||||
Visible: false
|
||||
Text: Retry
|
||||
Font: Bold
|
||||
Key: return
|
||||
Button@CANCEL_BUTTON:
|
||||
X: PARENT_RIGHT - 130
|
||||
Y: PARENT_BOTTOM - 52
|
||||
Background:button-highlighted
|
||||
Width: 110
|
||||
Height: 32
|
||||
Text: Cancel
|
||||
Font: Bold
|
||||
Key: escape
|
||||
|
||||
Container@INSTALL_FROMCD_PANEL:
|
||||
Logic: InstallFromCDLogic
|
||||
X: (WINDOW_RIGHT - WIDTH)/2
|
||||
Y: (WINDOW_BOTTOM - HEIGHT)/2
|
||||
Width: 500
|
||||
Height: 177
|
||||
Children:
|
||||
Background:
|
||||
Width: PARENT_RIGHT
|
||||
Height: PARENT_BOTTOM
|
||||
Background: panel-bg
|
||||
Background@RULE:
|
||||
X: 30
|
||||
Y: 50
|
||||
Width: 440
|
||||
Height:150
|
||||
Background:panel-rule
|
||||
Label@TITLE:
|
||||
X: 0
|
||||
Y: 12
|
||||
Width: PARENT_RIGHT
|
||||
Height: 25
|
||||
Text: Fetching assets from CD...
|
||||
Align: Center
|
||||
Font: MediumBold
|
||||
Container@INSTALLING:
|
||||
Width: PARENT_RIGHT
|
||||
Height: PARENT_BOTTOM
|
||||
Visible: false
|
||||
Children:
|
||||
ProgressBar@PROGRESS_BAR:
|
||||
X: 50
|
||||
Y: 60
|
||||
Width: PARENT_RIGHT - 100
|
||||
Height: 16
|
||||
BarMargin: 0, 0
|
||||
Label@STATUS_LABEL:
|
||||
X: 36
|
||||
Y: 80
|
||||
Width: PARENT_RIGHT - 100
|
||||
Height: 25
|
||||
Align: Left
|
||||
Container@INSERT_DISK:
|
||||
Width: PARENT_RIGHT
|
||||
Height: PARENT_BOTTOM
|
||||
Visible: false
|
||||
Children:
|
||||
Label@INFO1:
|
||||
Y: 65
|
||||
Width: PARENT_RIGHT
|
||||
Height: 25
|
||||
Text: Disk not found.
|
||||
Align: Center
|
||||
Label@INFO2:
|
||||
Y: 85
|
||||
Width: PARENT_RIGHT
|
||||
Height: 25
|
||||
Align: Center
|
||||
Button@RETRY_BUTTON:
|
||||
X: 20
|
||||
Y: PARENT_BOTTOM - 52
|
||||
Background:button-highlighted
|
||||
Width: 110
|
||||
Height: 32
|
||||
Text: Retry
|
||||
Font: Bold
|
||||
Key: return
|
||||
Button@BACK_BUTTON:
|
||||
X: PARENT_RIGHT - 130
|
||||
Y: PARENT_BOTTOM - 52
|
||||
Background:button-highlighted
|
||||
Width: 110
|
||||
Height: 32
|
||||
Text: Back
|
||||
Font: Bold
|
||||
Key: escape
|
||||
@@ -22,7 +22,6 @@ Assemblies:
|
||||
|
||||
ChromeLayout:
|
||||
modchooser|modchooser.yaml
|
||||
modchooser|install.yaml
|
||||
modchooser|content.yaml
|
||||
|
||||
Notifications:
|
||||
|
||||
Reference in New Issue
Block a user