Convert ContentInstaller into a manifest module.
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -34,7 +34,6 @@ namespace OpenRA
|
||||
public readonly IReadOnlyDictionary<string, string> MapFolders;
|
||||
public readonly MiniYaml LoadScreen;
|
||||
public readonly MiniYaml LobbyDefaults;
|
||||
public readonly InstallData ContentInstaller;
|
||||
public readonly Dictionary<string, Pair<string, int>> 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<InstallData>(yaml["ContentInstaller"]);
|
||||
|
||||
Fonts = yaml["Fonts"].ToDictionary(my =>
|
||||
{
|
||||
var nd = my.ToDictionary();
|
||||
|
||||
@@ -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<ContentInstaller>();
|
||||
var installModContent = !installData.TestFiles.All(f => GlobalFileSystem.Exists(f));
|
||||
var installModMusic = args != null && args.Contains("Install.Music");
|
||||
|
||||
|
||||
@@ -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<ContentInstaller>();
|
||||
this.continueLoading = continueLoading;
|
||||
panel = widget.Get("INSTALL_FROMCD_PANEL");
|
||||
progressBar = panel.Get<ProgressBarWidget>("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;
|
||||
|
||||
@@ -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<ContentInstaller>();
|
||||
var panel = widget.Get("INSTALL_PANEL");
|
||||
var widgetArgs = new WidgetArgs()
|
||||
{
|
||||
{ "afterInstall", () => { Ui.CloseWindow(); continueLoading(); } },
|
||||
{ "continueLoading", continueLoading },
|
||||
{ "mirrorListUrl", mirrorListUrl },
|
||||
{ "mirrorListUrl", installData.PackageMirrorList },
|
||||
};
|
||||
|
||||
panel.Get<ButtonWidget>("DOWNLOAD_BUTTON").OnClick = () =>
|
||||
|
||||
@@ -42,13 +42,13 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var downloadButton = installMusicContainer.GetOrNull<ButtonWidget>("DOWNLOAD_BUTTON");
|
||||
if (downloadButton != null)
|
||||
{
|
||||
var mirrorListUrl = Game.ModData.Manifest.ContentInstaller.MusicPackageMirrorList;
|
||||
downloadButton.IsVisible = () => !string.IsNullOrEmpty(mirrorListUrl);
|
||||
var installData = Game.ModData.Manifest.Get<ContentInstaller>();
|
||||
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 },
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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<ContentInstaller>();
|
||||
installButton.IsVisible = () => modRules.InstalledMusic.ToArray().Length <= installData.ShippedSoundtracks;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user