From 2de91a4c4e2841f444fcba56b90b9b0a699dbfa5 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sat, 7 Mar 2015 09:40:01 +0000 Subject: [PATCH] Convert ContentInstaller into a manifest module. --- OpenRA.Game/InstallUtils.cs | 2 +- OpenRA.Game/Manifest.cs | 6 +----- OpenRA.Mods.Common/LoadScreens/BlankLoadScreen.cs | 2 +- .../Widgets/Logic/Installation/InstallFromCDLogic.cs | 10 ++++++---- .../Widgets/Logic/Installation/InstallLogic.cs | 4 ++-- .../Widgets/Logic/Installation/InstallMusicLogic.cs | 6 +++--- OpenRA.Mods.Common/Widgets/Logic/MusicPlayerLogic.cs | 2 +- 7 files changed, 15 insertions(+), 17 deletions(-) diff --git a/OpenRA.Game/InstallUtils.cs b/OpenRA.Game/InstallUtils.cs index f33f447896..f59a2b0eaf 100644 --- a/OpenRA.Game/InstallUtils.cs +++ b/OpenRA.Game/InstallUtils.cs @@ -18,7 +18,7 @@ using OpenRA.FileSystem; namespace OpenRA { - public class InstallData + public class ContentInstaller : IGlobalModData { public readonly string MenuWidget = null; public readonly string MusicMenuWidget = null; diff --git a/OpenRA.Game/Manifest.cs b/OpenRA.Game/Manifest.cs index 094e92265f..b01f8f7f14 100644 --- a/OpenRA.Game/Manifest.cs +++ b/OpenRA.Game/Manifest.cs @@ -34,7 +34,6 @@ namespace OpenRA public readonly IReadOnlyDictionary MapFolders; public readonly MiniYaml LoadScreen; public readonly MiniYaml LobbyDefaults; - public readonly InstallData ContentInstaller; public readonly Dictionary> Fonts; public readonly Size TileSize = new Size(24, 24); public readonly TileShape TileShape = TileShape.Rectangle; @@ -58,7 +57,7 @@ namespace OpenRA readonly string[] reservedModuleNames = { "Metadata", "Folders", "MapFolders", "Packages", "Rules", "Sequences", "VoxelSequences", "Cursors", "Chrome", "Assemblies", "ChromeLayout", "Weapons", "Voices", "Notifications", "Music", "Translations", "TileSets", "ChromeMetrics", "Missions", - "ServerTraits", "LoadScreen", "LobbyDefaults", "ContentInstaller", "Fonts", "TileSize", + "ServerTraits", "LoadScreen", "LobbyDefaults", "Fonts", "TileSize", "TileShape", "SubCells", "SupportsMapsFrom", "SpriteFormats" }; readonly TypeDictionary modules = new TypeDictionary(); @@ -96,9 +95,6 @@ namespace OpenRA LoadScreen = yaml["LoadScreen"]; LobbyDefaults = yaml["LobbyDefaults"]; - if (yaml.ContainsKey("ContentInstaller")) - ContentInstaller = FieldLoader.Load(yaml["ContentInstaller"]); - Fonts = yaml["Fonts"].ToDictionary(my => { var nd = my.ToDictionary(); diff --git a/OpenRA.Mods.Common/LoadScreens/BlankLoadScreen.cs b/OpenRA.Mods.Common/LoadScreens/BlankLoadScreen.cs index 6a4bfe5ed0..37722cd67a 100644 --- a/OpenRA.Mods.Common/LoadScreens/BlankLoadScreen.cs +++ b/OpenRA.Mods.Common/LoadScreens/BlankLoadScreen.cs @@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.LoadScreens // Check whether the mod content is installed // TODO: The installation code has finally been beaten into shape, so we can // finally move it all into the planned "Manage Content" panel in the modchooser mod. - var installData = Game.ModData.Manifest.ContentInstaller; + var installData = Game.ModData.Manifest.Get(); var installModContent = !installData.TestFiles.All(f => GlobalFileSystem.Exists(f)); var installModMusic = args != null && args.Contains("Install.Music"); diff --git a/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallFromCDLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallFromCDLogic.cs index 4e81894ae0..0f2524265f 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallFromCDLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallFromCDLogic.cs @@ -24,10 +24,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic readonly Action continueLoading; readonly ButtonWidget retryButton, backButton; readonly Widget installingContainer, insertDiskContainer; + readonly ContentInstaller installData; [ObjectCreator.UseCtor] public InstallFromCDLogic(Widget widget, Action continueLoading) { + installData = Game.ModData.Manifest.Get(); this.continueLoading = continueLoading; panel = widget.Get("INSTALL_FROMCD_PANEL"); progressBar = panel.Get("PROGRESS_BAR"); @@ -46,7 +48,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic bool IsValidDisk(string diskRoot) { - return Game.ModData.Manifest.ContentInstaller.DiskTestFiles.All(f => File.Exists(Path.Combine(diskRoot, f))); + return installData.DiskTestFiles.All(f => File.Exists(Path.Combine(diskRoot, f))); } void CheckForDisk() @@ -70,13 +72,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic installingContainer.IsVisible = () => true; var dest = Platform.ResolvePath("^", "Content", Game.ModData.Manifest.Mod.Id); - var copyFiles = Game.ModData.Manifest.ContentInstaller.CopyFilesFromCD; + var copyFiles = installData.CopyFilesFromCD; - var packageToExtract = Game.ModData.Manifest.ContentInstaller.PackageToExtractFromCD.Split(':'); + var packageToExtract = installData.PackageToExtractFromCD.Split(':'); var extractPackage = packageToExtract.First(); var annotation = packageToExtract.Length > 1 ? packageToExtract.Last() : null; - var extractFiles = Game.ModData.Manifest.ContentInstaller.ExtractFilesFromCD; + var extractFiles = installData.ExtractFilesFromCD; var installCounter = 0; var installTotal = copyFiles.Length + extractFiles.Length; diff --git a/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallLogic.cs index e35bc9bea6..dff55c86e6 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallLogic.cs @@ -19,13 +19,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic [ObjectCreator.UseCtor] public InstallLogic(Widget widget, Action continueLoading) { - var mirrorListUrl = Game.ModData.Manifest.ContentInstaller.PackageMirrorList; + var installData = Game.ModData.Manifest.Get(); var panel = widget.Get("INSTALL_PANEL"); var widgetArgs = new WidgetArgs() { { "afterInstall", () => { Ui.CloseWindow(); continueLoading(); } }, { "continueLoading", continueLoading }, - { "mirrorListUrl", mirrorListUrl }, + { "mirrorListUrl", installData.PackageMirrorList }, }; panel.Get("DOWNLOAD_BUTTON").OnClick = () => diff --git a/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallMusicLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallMusicLogic.cs index be0134846f..b3c7017a6a 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallMusicLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Installation/InstallMusicLogic.cs @@ -42,13 +42,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic var downloadButton = installMusicContainer.GetOrNull("DOWNLOAD_BUTTON"); if (downloadButton != null) { - var mirrorListUrl = Game.ModData.Manifest.ContentInstaller.MusicPackageMirrorList; - downloadButton.IsVisible = () => !string.IsNullOrEmpty(mirrorListUrl); + var installData = Game.ModData.Manifest.Get(); + downloadButton.IsVisible = () => !string.IsNullOrEmpty(installData.MusicPackageMirrorList); downloadButton.OnClick = () => { Ui.OpenWindow("INSTALL_DOWNLOAD_PANEL", new WidgetArgs() { { "afterInstall", () => Game.InitializeMod(Game.Settings.Game.Mod, null) }, - { "mirrorListUrl", mirrorListUrl }, + { "mirrorListUrl", installData.MusicPackageMirrorList }, }); }; } diff --git a/OpenRA.Mods.Common/Widgets/Logic/MusicPlayerLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/MusicPlayerLogic.cs index e109d97a77..d8f9c41c75 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/MusicPlayerLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/MusicPlayerLogic.cs @@ -92,7 +92,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic Game.InitializeMod(Game.Settings.Game.Mod, new Arguments(args)); }; - var installData = Game.ModData.Manifest.ContentInstaller; + var installData = Game.ModData.Manifest.Get(); installButton.IsVisible = () => modRules.InstalledMusic.ToArray().Length <= installData.ShippedSoundtracks; }