From 3585d8afd47b9bd18452b98c01f15b936d2021a2 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 29 May 2016 12:46:32 +0100 Subject: [PATCH] Remove legacy installation logic. --- OpenRA.Game/ContentInstaller.cs | 43 ---- OpenRA.Game/Game.cs | 6 +- OpenRA.Game/ModMetadata.cs | 4 - OpenRA.Game/OpenRA.Game.csproj | 1 - OpenRA.Mods.Common/InstallUtils.cs | 189 --------------- OpenRA.Mods.Common/OpenRA.Mods.Common.csproj | 4 - .../Traits/World/MusicPlaylist.cs | 6 +- .../Installation/DownloadPackagesLogic.cs | 159 ------------- .../Logic/Installation/InstallFromCDLogic.cs | 218 ------------------ .../Logic/Installation/InstallLogic.cs | 44 ---- .../Widgets/Logic/ModBrowserLogic.cs | 31 +-- mods/modchooser/install.yaml | 196 ---------------- mods/modchooser/mod.yaml | 1 - 13 files changed, 15 insertions(+), 887 deletions(-) delete mode 100644 OpenRA.Game/ContentInstaller.cs delete mode 100644 OpenRA.Mods.Common/InstallUtils.cs delete mode 100644 OpenRA.Mods.Common/Widgets/Logic/Installation/DownloadPackagesLogic.cs delete mode 100644 OpenRA.Mods.Common/Widgets/Logic/Installation/InstallFromCDLogic.cs delete mode 100644 OpenRA.Mods.Common/Widgets/Logic/Installation/InstallLogic.cs delete mode 100644 mods/modchooser/install.yaml diff --git a/OpenRA.Game/ContentInstaller.cs b/OpenRA.Game/ContentInstaller.cs deleted file mode 100644 index 7847ccfbdd..0000000000 --- a/OpenRA.Game/ContentInstaller.cs +++ /dev/null @@ -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 CopyFilesFromCD = new Dictionary(); - public readonly Dictionary ExtractFilesFromCD = new Dictionary(); - - public readonly string PackageMirrorList = null; - - public readonly string MusicPackageMirrorList = null; - public readonly int ShippedSoundtracks = 0; - - /// InstallShield .CAB file IDs, used to extract Mod-specific files. - public readonly HashSet InstallShieldCABFileIds = new HashSet(); - - /// InstallShield .CAB file IDs, used to extract Mod-specific archives and extract contents of ExtractFilesFromCD. - public readonly HashSet InstallShieldCABFilePackageIds = new HashSet(); - } -} diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index 0e669f5c74..ea17fed72d 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -344,8 +344,10 @@ namespace OpenRA using (new PerfTimer("LoadMaps")) ModData.MapCache.LoadMaps(); - var installData = ModData.Manifest.Get(); - var isModContentInstalled = installData.TestFiles.All(f => File.Exists(Platform.ResolvePath(f))); + var content = ModData.Manifest.Get(); + 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) diff --git a/OpenRA.Game/ModMetadata.cs b/OpenRA.Game/ModMetadata.cs index 12c95206b5..a85728d426 100644 --- a/OpenRA.Game/ModMetadata.cs +++ b/OpenRA.Game/ModMetadata.cs @@ -30,7 +30,6 @@ namespace OpenRA public bool Hidden; public Dictionary RequiresMods; - public ContentInstaller Content; public ModContent ModContent; public IReadOnlyPackage Package; @@ -79,9 +78,6 @@ namespace OpenRA else metadata.RequiresMods = new Dictionary(); - if (nd.ContainsKey("ContentInstaller")) - metadata.Content = FieldLoader.Load(nd["ContentInstaller"]); - if (nd.ContainsKey("ModContent")) metadata.ModContent = FieldLoader.Load(nd["ModContent"]); diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index 3679465ac8..060a15d2ab 100644 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -103,7 +103,6 @@ - diff --git a/OpenRA.Mods.Common/InstallUtils.cs b/OpenRA.Mods.Common/InstallUtils.cs deleted file mode 100644 index 8486133cb4..0000000000 --- a/OpenRA.Mods.Common/InstallUtils.cs +++ /dev/null @@ -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 GetEntries(this ZipInputStream z) - { - for (;;) - { - var e = z.GetNextEntry(); - if (e != null) yield return e; else break; - } - } - - public static string GetMountedDisk(Func 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 filesByDirectory, - string destPath, bool overwrite, ContentInstaller.FilenameCase caseModifier, Action onProgress, Action 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 files, string destPath, - bool overwrite, ContentInstaller.FilenameCase caseModifier, Action onProgress, Action 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 onProgress, Action onError) - { - if (!File.Exists(zipFile)) - { - onError("Invalid path: " + zipFile); - return false; - } - - var extracted = new List(); - 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 extracted, Action 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(); - } - } -} diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index cfd2d52455..b101e1b150 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -610,10 +610,7 @@ - - - @@ -661,7 +658,6 @@ - diff --git a/OpenRA.Mods.Common/Traits/World/MusicPlaylist.cs b/OpenRA.Mods.Common/Traits/World/MusicPlaylist.cs index ab6122f3a8..3510b733b8 100644 --- a/OpenRA.Mods.Common/Traits/World/MusicPlaylist.cs +++ b/OpenRA.Mods.Common/Traits/World/MusicPlaylist.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(); - if (playlist.Length > installData.ShippedSoundtracks) - currentSong = random.FirstOrDefault(); + // Start playback with a random song + currentSong = random.FirstOrDefault(); } if (SongExists(info.StartingMusic)) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Installation/DownloadPackagesLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Installation/DownloadPackagesLogic.cs deleted file mode 100644 index 0101ddb27c..0000000000 --- a/OpenRA.Mods.Common/Widgets/Logic/Installation/DownloadPackagesLogic.cs +++ /dev/null @@ -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("PROGRESS_BAR"); - statusLabel = panel.Get("STATUS_LABEL"); - - var text = "Downloading {0} assets...".F(ModMetadata.AllMods[modId].Title); - panel.Get("TITLE").Text = text; - - ShowDownloadDialog(); - } - - void ShowDownloadDialog() - { - statusLabel.GetText = () => "Fetching list of mirrors..."; - progressBar.Indeterminate = true; - - var retryButton = panel.Get("RETRY_BUTTON"); - retryButton.IsVisible = () => false; - - var cancelButton = panel.Get("CANCEL_BUTTON"); - - var file = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); - var dest = Platform.ResolvePath("^", "Content", modId); - - Action 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 onExtractProgress = s => Game.RunAfterTick(() => statusLabel.GetText = () => s); - - Action onError = s => Game.RunAfterTick(() => - { - statusLabel.GetText = () => "Error: " + s; - retryButton.IsVisible = () => true; - }); - - Action 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 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(); }; - } - } -} diff --git a/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallFromCDLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallFromCDLogic.cs deleted file mode 100644 index e1de4d41fb..0000000000 --- a/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallFromCDLogic.cs +++ /dev/null @@ -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("PROGRESS_BAR"); - statusLabel = panel.Get("STATUS_LABEL"); - - backButton = panel.Get("BACK_BUTTON"); - backButton.OnClick = Ui.CloseWindow; - - retryButton = panel.Get("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("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)(s => { }); - var overwrite = installData.OverwriteFiles; - - var onProgress = (Action)(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)(s => Game.RunAfterTick(() => - { - progressBar.Percentage = installCounter * 100 / installTotal; - installCounter++; - - statusLabel.GetText = () => s; - })); - - var onError = (Action)(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(); - } - } -} diff --git a/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallLogic.cs deleted file mode 100644 index 3d2d693901..0000000000 --- a/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallLogic.cs +++ /dev/null @@ -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("DESC1").Text = text; - - var downloadButton = panel.Get("DOWNLOAD_BUTTON"); - downloadButton.OnClick = () => Ui.OpenWindow("INSTALL_DOWNLOAD_PANEL", widgetArgs); - downloadButton.IsDisabled = () => string.IsNullOrEmpty(mod.Content.PackageMirrorList); - - panel.Get("INSTALL_BUTTON").OnClick = () => - Ui.OpenWindow("INSTALL_FROMCD_PANEL", widgetArgs); - - panel.Get("BACK_BUTTON").OnClick = Ui.CloseWindow; - } - } -} diff --git a/OpenRA.Mods.Common/Widgets/Logic/ModBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/ModBrowserLogic.cs index aed538ce94..7a74dbd966 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ModBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ModBrowserLogic.cs @@ -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)))); } } } diff --git a/mods/modchooser/install.yaml b/mods/modchooser/install.yaml deleted file mode 100644 index 655c9ea1b1..0000000000 --- a/mods/modchooser/install.yaml +++ /dev/null @@ -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 diff --git a/mods/modchooser/mod.yaml b/mods/modchooser/mod.yaml index b18a2cdd6c..148466d6ac 100644 --- a/mods/modchooser/mod.yaml +++ b/mods/modchooser/mod.yaml @@ -22,7 +22,6 @@ Assemblies: ChromeLayout: modchooser|modchooser.yaml - modchooser|install.yaml modchooser|content.yaml Notifications: