Unhardcode modchooser mod for content installation.
This commit is contained in:
@@ -379,16 +379,12 @@ namespace OpenRA
|
|||||||
ModData = new ModData(Mods[mod], Mods, true);
|
ModData = new ModData(Mods[mod], Mods, true);
|
||||||
ExternalMods.Register(ModData.Manifest);
|
ExternalMods.Register(ModData.Manifest);
|
||||||
|
|
||||||
|
if (!ModData.LoadScreen.BeforeLoad())
|
||||||
|
return;
|
||||||
|
|
||||||
using (new PerfTimer("LoadMaps"))
|
using (new PerfTimer("LoadMaps"))
|
||||||
ModData.MapCache.LoadMaps();
|
ModData.MapCache.LoadMaps();
|
||||||
|
|
||||||
// Mod assets are missing!
|
|
||||||
if (!ModData.LoadScreen.RequiredContentIsInstalled())
|
|
||||||
{
|
|
||||||
InitializeMod("modchooser", new Arguments());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
ModData.InitializeLoaders(ModData.DefaultFileSystem);
|
ModData.InitializeLoaders(ModData.DefaultFileSystem);
|
||||||
Renderer.InitializeFonts(ModData);
|
Renderer.InitializeFonts(ModData);
|
||||||
|
|
||||||
|
|||||||
@@ -222,9 +222,19 @@ namespace OpenRA
|
|||||||
|
|
||||||
public interface ILoadScreen : IDisposable
|
public interface ILoadScreen : IDisposable
|
||||||
{
|
{
|
||||||
|
/// <summary>Initializes the loadscreen with yaml data from the LoadScreen block in mod.yaml.</summary>
|
||||||
void Init(ModData m, Dictionary<string, string> info);
|
void Init(ModData m, Dictionary<string, string> info);
|
||||||
|
|
||||||
|
/// <summary>Called at arbitrary times during mod load to rerender the loadscreen.</summary>
|
||||||
void Display();
|
void Display();
|
||||||
bool RequiredContentIsInstalled();
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called before loading the mod assets.
|
||||||
|
/// Returns false if mod loading should be aborted (e.g. switching to another mod instead).
|
||||||
|
/// </summary>
|
||||||
|
bool BeforeLoad();
|
||||||
|
|
||||||
|
/// <summary>Called when the engine expects to connect to a server/replay or load the shellmap.</summary>
|
||||||
void StartGame(Arguments args);
|
void StartGame(Arguments args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -109,12 +109,23 @@ namespace OpenRA.Mods.Common.LoadScreens
|
|||||||
GC.SuppressFinalize(this);
|
GC.SuppressFinalize(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool RequiredContentIsInstalled()
|
public bool BeforeLoad()
|
||||||
{
|
{
|
||||||
|
// If a ModContent section is defined then we need to make sure that the
|
||||||
|
// required content is installed or switch to the defined content installer.
|
||||||
|
if (!modData.Manifest.Contains<ModContent>())
|
||||||
|
return true;
|
||||||
|
|
||||||
var content = modData.Manifest.Get<ModContent>();
|
var content = modData.Manifest.Get<ModContent>();
|
||||||
return content.Packages
|
var contentInstalled = content.Packages
|
||||||
.Where(p => p.Value.Required)
|
.Where(p => p.Value.Required)
|
||||||
.All(p => p.Value.TestFiles.All(f => File.Exists(Platform.ResolvePath(f))));
|
.All(p => p.Value.TestFiles.All(f => File.Exists(Platform.ResolvePath(f))));
|
||||||
|
|
||||||
|
if (contentInstalled)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
Game.InitializeMod(content.ContentInstallerMod, new Arguments());
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -58,7 +58,7 @@ namespace OpenRA.Mods.Common.LoadScreens
|
|||||||
sprite.Sheet.Dispose();
|
sprite.Sheet.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool RequiredContentIsInstalled()
|
public bool BeforeLoad()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ namespace OpenRA
|
|||||||
public readonly string InstallPromptMessage;
|
public readonly string InstallPromptMessage;
|
||||||
public readonly string QuickDownload;
|
public readonly string QuickDownload;
|
||||||
public readonly string HeaderMessage;
|
public readonly string HeaderMessage;
|
||||||
|
public readonly string ContentInstallerMod = "modchooser";
|
||||||
|
|
||||||
[FieldLoader.LoadUsing("LoadPackages")]
|
[FieldLoader.LoadUsing("LoadPackages")]
|
||||||
public readonly Dictionary<string, ModPackage> Packages = new Dictionary<string, ModPackage>();
|
public readonly Dictionary<string, ModPackage> Packages = new Dictionary<string, ModPackage>();
|
||||||
|
|||||||
Reference in New Issue
Block a user