Let FieldLoader do the hard work of loading fields.
This commit is contained in:
committed by
Matthias Mailänder
parent
352067eb48
commit
3f7293b206
@@ -30,11 +30,6 @@ namespace OpenRA
|
||||
return string.Format(fmt, args);
|
||||
}
|
||||
|
||||
public static string TrimOrEmpty(this string input)
|
||||
{
|
||||
return input != null ? input.Trim() : string.Empty;
|
||||
}
|
||||
|
||||
public static T WithDefault<T>(T def, Func<T> f)
|
||||
{
|
||||
try { return f(); }
|
||||
|
||||
@@ -443,8 +443,8 @@ namespace OpenRA
|
||||
if (!string.IsNullOrEmpty(window))
|
||||
{
|
||||
var installData = modData.Manifest.ContentInstaller;
|
||||
if (installData.ContainsKey("InstallerBackgroundWidget"))
|
||||
Ui.LoadWidget(installData["InstallerBackgroundWidget"], Ui.Root, new WidgetArgs());
|
||||
if (installData.InstallerMenuWidget != null)
|
||||
Ui.LoadWidget(installData.InstallerMenuWidget, Ui.Root, new WidgetArgs());
|
||||
|
||||
Widgets.Ui.OpenWindow(window, new WidgetArgs());
|
||||
}
|
||||
@@ -463,16 +463,17 @@ namespace OpenRA
|
||||
{
|
||||
Ui.ResetAll();
|
||||
var installData = modData.Manifest.ContentInstaller;
|
||||
if (!installData["TestFiles"].Split(',').All(f => GlobalFileSystem.Exists(f.Trim())))
|
||||
if (!installData.TestFiles.All(f => GlobalFileSystem.Exists(f)))
|
||||
{
|
||||
var args = new WidgetArgs()
|
||||
{
|
||||
{ "continueLoading", () => InitializeMod(Game.Settings.Game.Mod, null) },
|
||||
{ "installData", installData }
|
||||
};
|
||||
if (installData.ContainsKey("InstallerBackgroundWidget"))
|
||||
Ui.LoadWidget(installData["InstallerBackgroundWidget"], Ui.Root, args);
|
||||
Ui.OpenWindow(installData["InstallerMenuWidget"], args);
|
||||
|
||||
if (installData.InstallerBackgroundWidget != null)
|
||||
Ui.LoadWidget(installData.InstallerBackgroundWidget, Ui.Root, args);
|
||||
|
||||
Ui.OpenWindow(installData.InstallerMenuWidget, args);
|
||||
}
|
||||
else
|
||||
LoadShellMap();
|
||||
|
||||
@@ -18,6 +18,22 @@ using OpenRA.FileSystem;
|
||||
|
||||
namespace OpenRA
|
||||
{
|
||||
public class InstallData
|
||||
{
|
||||
public readonly string InstallerMenuWidget = null;
|
||||
public readonly string InstallerBackgroundWidget = null;
|
||||
public readonly string[] TestFiles = {};
|
||||
public readonly string[] DiskTestFiles = {};
|
||||
public readonly string PackageToExtractFromCD = null;
|
||||
public readonly string[] ExtractFilesFromCD = {};
|
||||
public readonly string[] CopyFilesFromCD = {};
|
||||
|
||||
public readonly string PackageMirrorList = null;
|
||||
|
||||
public readonly string MusicPackageMirrorList = null;
|
||||
public readonly int ShippedSoundtracks = 0;
|
||||
}
|
||||
|
||||
public static class InstallUtils
|
||||
{
|
||||
static IEnumerable<ZipEntry> GetEntries(this ZipInputStream z)
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace OpenRA
|
||||
public readonly IReadOnlyDictionary<string, string> MapFolders;
|
||||
public readonly MiniYaml LoadScreen;
|
||||
public readonly MiniYaml LobbyDefaults;
|
||||
public readonly IReadOnlyDictionary<string, string> ContentInstaller;
|
||||
public readonly InstallData ContentInstaller;
|
||||
public readonly Dictionary<string, Pair<string, int>> Fonts;
|
||||
public readonly Size TileSize = new Size(24, 24);
|
||||
public readonly string NewsUrl;
|
||||
@@ -72,7 +72,10 @@ namespace OpenRA
|
||||
|
||||
LoadScreen = yaml["LoadScreen"];
|
||||
LobbyDefaults = yaml["LobbyDefaults"];
|
||||
ContentInstaller = YamlDictionary(yaml, "ContentInstaller");
|
||||
|
||||
if (yaml.ContainsKey("ContentInstaller"))
|
||||
ContentInstaller = FieldLoader.Load<InstallData>(yaml["ContentInstaller"]);
|
||||
|
||||
Fonts = yaml["Fonts"].ToDictionary(my =>
|
||||
{
|
||||
var nd = my.ToDictionary();
|
||||
|
||||
Reference in New Issue
Block a user