Merge pull request #9263 from penev92/assetInstallation
Move asset installation to the ModChooser
This commit is contained in:
37
OpenRA.Game/ContentInstaller.cs
Normal file
37
OpenRA.Game/ContentInstaller.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
#region Copyright & License Information
|
||||
/*
|
||||
* Copyright 2007-2015 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. For more information,
|
||||
* see COPYING.
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace OpenRA
|
||||
{
|
||||
// Referenced from ModMetadata, so needs to be in OpenRA.Game :(
|
||||
public class ContentInstaller : IGlobalModData
|
||||
{
|
||||
public readonly string[] TestFiles = { };
|
||||
public readonly string[] DiskTestFiles = { };
|
||||
public readonly string PackageToExtractFromCD = null;
|
||||
public readonly bool OverwriteFiles = true;
|
||||
|
||||
public readonly Dictionary<string, string[]> CopyFilesFromCD = new Dictionary<string, string[]>();
|
||||
public readonly Dictionary<string, string[]> ExtractFilesFromCD = new Dictionary<string, string[]>();
|
||||
|
||||
public readonly string PackageMirrorList = null;
|
||||
|
||||
public readonly string MusicPackageMirrorList = null;
|
||||
public readonly int ShippedSoundtracks = 0;
|
||||
|
||||
/// <summary> InstallShield .CAB file IDs, used to extract Mod-specific files. </summary>
|
||||
public readonly HashSet<int> InstallShieldCABFileIds = new HashSet<int>();
|
||||
|
||||
/// <summary> InstallShield .CAB file IDs, used to extract Mod-specific archives and extract contents of ExtractFilesFromCD. </summary>
|
||||
public readonly HashSet<string> InstallShieldCABFilePackageIds = new HashSet<string>();
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
*/
|
||||
#endregion
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
@@ -24,6 +25,7 @@ namespace OpenRA
|
||||
public string Version;
|
||||
public string Author;
|
||||
public bool Hidden;
|
||||
public ContentInstaller Content;
|
||||
|
||||
static Dictionary<string, ModMetadata> ValidateMods()
|
||||
{
|
||||
@@ -34,19 +36,30 @@ namespace OpenRA
|
||||
var ret = new Dictionary<string, ModMetadata>();
|
||||
foreach (var m in mods)
|
||||
{
|
||||
var yamlPath = Platform.ResolvePath(".", "mods", m, "mod.yaml");
|
||||
if (!File.Exists(yamlPath))
|
||||
continue;
|
||||
try
|
||||
{
|
||||
var yamlPath = Platform.ResolvePath(".", "mods", m, "mod.yaml");
|
||||
if (!File.Exists(yamlPath))
|
||||
continue;
|
||||
|
||||
var yaml = new MiniYaml(null, MiniYaml.FromFile(yamlPath));
|
||||
var nd = yaml.ToDictionary();
|
||||
if (!nd.ContainsKey("Metadata"))
|
||||
continue;
|
||||
var yaml = new MiniYaml(null, MiniYaml.FromFile(yamlPath));
|
||||
var nd = yaml.ToDictionary();
|
||||
if (!nd.ContainsKey("Metadata"))
|
||||
continue;
|
||||
|
||||
var mod = FieldLoader.Load<ModMetadata>(nd["Metadata"]);
|
||||
mod.Id = m;
|
||||
var mod = FieldLoader.Load<ModMetadata>(nd["Metadata"]);
|
||||
mod.Id = m;
|
||||
|
||||
ret.Add(m, mod);
|
||||
if (nd.ContainsKey("ContentInstaller"))
|
||||
mod.Content = FieldLoader.Load<ContentInstaller>(nd["ContentInstaller"]);
|
||||
|
||||
ret.Add(m, mod);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("An exception occured when trying to load ModMetadata for `{0}`:".F(m));
|
||||
Console.WriteLine(ex.Message);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -95,6 +95,7 @@
|
||||
<Compile Include="FileFormats\IdxReader.cs" />
|
||||
<Compile Include="FileSystem\BagFile.cs" />
|
||||
<Compile Include="Map\MapPlayers.cs" />
|
||||
<Compile Include="ContentInstaller.cs" />
|
||||
<Compile Include="MPos.cs" />
|
||||
<Compile Include="Graphics\QuadRenderer.cs" />
|
||||
<Compile Include="Download.cs" />
|
||||
|
||||
Reference in New Issue
Block a user