Let FieldLoader do the hard work of loading fields.
This commit is contained in:
committed by
Matthias Mailänder
parent
352067eb48
commit
3f7293b206
@@ -21,17 +21,17 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
{
|
||||
public class DownloadPackagesLogic
|
||||
{
|
||||
Widget panel;
|
||||
IReadOnlyDictionary<string, string> installData;
|
||||
ProgressBarWidget progressBar;
|
||||
LabelWidget statusLabel;
|
||||
Action afterInstall;
|
||||
readonly Widget panel;
|
||||
readonly InstallData installData;
|
||||
readonly ProgressBarWidget progressBar;
|
||||
readonly LabelWidget statusLabel;
|
||||
readonly Action afterInstall;
|
||||
string mirror;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public DownloadPackagesLogic(Widget widget, IReadOnlyDictionary<string, string> installData, Action afterInstall)
|
||||
public DownloadPackagesLogic(Widget widget, Action afterInstall)
|
||||
{
|
||||
this.installData = installData;
|
||||
installData = Game.modData.Manifest.ContentInstaller;
|
||||
this.afterInstall = afterInstall;
|
||||
|
||||
panel = widget.Get("INSTALL_DOWNLOAD_PANEL");
|
||||
@@ -130,7 +130,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
};
|
||||
|
||||
// Get the list of mirrors
|
||||
var updateMirrors = new Download(installData["PackageMirrorList"], mirrorsFile, onDownloadProgress, onFetchMirrorsComplete);
|
||||
var updateMirrors = new Download(installData.PackageMirrorList, mirrorsFile, onDownloadProgress, onFetchMirrorsComplete);
|
||||
cancelButton.OnClick = () => { updateMirrors.Cancel(); Ui.CloseWindow(); };
|
||||
retryButton.OnClick = () => { updateMirrors.Cancel(); ShowDownloadDialog(); };
|
||||
}
|
||||
|
||||
@@ -46,8 +46,7 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
|
||||
bool IsValidDisk(string diskRoot)
|
||||
{
|
||||
var files = Game.modData.Manifest.ContentInstaller["DiskTestFiles"].Split(',').Select(x => x.Trim()).ToArray();
|
||||
return files.All(f => File.Exists(Path.Combine(diskRoot, f)));
|
||||
return Game.modData.Manifest.ContentInstaller.DiskTestFiles.All(f => File.Exists(Path.Combine(diskRoot, f)));
|
||||
}
|
||||
|
||||
void CheckForDisk()
|
||||
@@ -71,10 +70,10 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
installingContainer.IsVisible = () => true;
|
||||
|
||||
var dest = new string[] { Platform.SupportDir, "Content", Game.modData.Manifest.Mod.Id }.Aggregate(Path.Combine);
|
||||
var copyFiles = Game.modData.Manifest.ContentInstaller["CopyFilesFromCD"].Split(',').Select(x => x.TrimOrEmpty()).ToArray();
|
||||
var copyFiles = Game.modData.Manifest.ContentInstaller.CopyFilesFromCD;
|
||||
|
||||
var extractPackage = Game.modData.Manifest.ContentInstaller["PackageToExtractFromCD"].TrimOrEmpty();
|
||||
var extractFiles = Game.modData.Manifest.ContentInstaller["ExtractFilesFromCD"].Split(',').Select(x => x.TrimOrEmpty()).ToArray();
|
||||
var extractPackage = Game.modData.Manifest.ContentInstaller.PackageToExtractFromCD;
|
||||
var extractFiles = Game.modData.Manifest.ContentInstaller.ExtractFilesFromCD;
|
||||
|
||||
var installCounter = 0;
|
||||
var installTotal = copyFiles.Count() + extractFiles.Count();
|
||||
|
||||
@@ -17,13 +17,12 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
public class InstallLogic : Widget
|
||||
{
|
||||
[ObjectCreator.UseCtor]
|
||||
public InstallLogic(Widget widget, IReadOnlyDictionary<string, string> installData, Action continueLoading)
|
||||
public InstallLogic(Widget widget, Action continueLoading)
|
||||
{
|
||||
var panel = widget.Get("INSTALL_PANEL");
|
||||
var widgetArgs = new WidgetArgs()
|
||||
{
|
||||
{ "afterInstall", () => { Ui.CloseWindow(); continueLoading(); } },
|
||||
{ "installData", installData },
|
||||
{ "continueLoading", continueLoading }
|
||||
};
|
||||
|
||||
|
||||
@@ -45,15 +45,11 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
if (downloadButton != null)
|
||||
{
|
||||
var installData = Game.modData.Manifest.ContentInstaller;
|
||||
downloadButton.IsVisible = () => !string.IsNullOrEmpty(installData["MusicPackageMirrorList"]);
|
||||
var musicInstallData = new Dictionary<string, string> { };
|
||||
musicInstallData["PackageMirrorList"] = installData["MusicPackageMirrorList"];
|
||||
|
||||
downloadButton.IsVisible = () => !string.IsNullOrEmpty(installData.MusicPackageMirrorList);
|
||||
downloadButton.OnClick = () =>
|
||||
{
|
||||
Ui.OpenWindow("INSTALL_DOWNLOAD_PANEL", new WidgetArgs() {
|
||||
{ "afterInstall", () => Game.InitializeMod(Game.Settings.Game.Mod, null) },
|
||||
{ "installData", new ReadOnlyDictionary<string, string>(musicInstallData) },
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -90,9 +90,9 @@ namespace OpenRA.Mods.RA.Widgets.Logic
|
||||
Game.modData.LoadScreen.Display(); // HACK: prevent a flicker when transitioning to the installation dialog
|
||||
Game.InitializeMod(Game.Settings.Game.Mod, new Arguments(args));
|
||||
};
|
||||
|
||||
var installData = Game.modData.Manifest.ContentInstaller;
|
||||
installButton.IsVisible = () =>
|
||||
modRules.InstalledMusic.ToArray().Length <= Exts.ParseIntegerInvariant(installData["ShippedSoundtracks"]);
|
||||
installButton.IsVisible = () => modRules.InstalledMusic.ToArray().Length <= installData.ShippedSoundtracks;
|
||||
}
|
||||
|
||||
panel.Get<ButtonWidget>("BACK_BUTTON").OnClick = () => { Game.Settings.Save(); Ui.CloseWindow(); onExit(); };
|
||||
|
||||
Reference in New Issue
Block a user