From cff8e949d82b592669a8b8aeffc47804f46cc301 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Fri, 5 Aug 2016 19:05:43 +0100 Subject: [PATCH] Move ModContent out of the engine. --- OpenRA.Game/Game.cs | 7 +------ OpenRA.Game/ModData.cs | 1 + OpenRA.Game/OpenRA.Game.csproj | 1 - OpenRA.Mods.Cnc/CncLoadScreen.cs | 2 ++ OpenRA.Mods.Common/LoadScreens/BlankLoadScreen.cs | 15 ++++++++++++++- .../LoadScreens/LogoStripeLoadScreen.cs | 2 ++ .../LoadScreens/ModChooserLoadScreen.cs | 6 +++++- {OpenRA.Game => OpenRA.Mods.Common}/ModContent.cs | 0 OpenRA.Mods.Common/OpenRA.Mods.Common.csproj | 1 + 9 files changed, 26 insertions(+), 9 deletions(-) rename {OpenRA.Game => OpenRA.Mods.Common}/ModContent.cs (100%) diff --git a/OpenRA.Game/Game.cs b/OpenRA.Game/Game.cs index d5e0eb6be8..d5190cfa98 100644 --- a/OpenRA.Game/Game.cs +++ b/OpenRA.Game/Game.cs @@ -364,13 +364,8 @@ namespace OpenRA using (new PerfTimer("LoadMaps")) ModData.MapCache.LoadMaps(); - var content = ModData.Manifest.Get(); - var isModContentInstalled = content.Packages - .Where(p => p.Value.Required) - .All(p => p.Value.TestFiles.All(f => File.Exists(Platform.ResolvePath(f)))); - // Mod assets are missing! - if (!isModContentInstalled) + if (!ModData.LoadScreen.RequiredContentIsInstalled()) { InitializeMod("modchooser", new Arguments()); return; diff --git a/OpenRA.Game/ModData.cs b/OpenRA.Game/ModData.cs index 51a88b4a3e..a039cc63f7 100644 --- a/OpenRA.Game/ModData.cs +++ b/OpenRA.Game/ModData.cs @@ -224,6 +224,7 @@ namespace OpenRA { void Init(ModData m, Dictionary info); void Display(); + bool RequiredContentIsInstalled(); void StartGame(Arguments args); } } diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj index 031793d901..3a6bd6c4f9 100644 --- a/OpenRA.Game/OpenRA.Game.csproj +++ b/OpenRA.Game/OpenRA.Game.csproj @@ -243,7 +243,6 @@ - diff --git a/OpenRA.Mods.Cnc/CncLoadScreen.cs b/OpenRA.Mods.Cnc/CncLoadScreen.cs index 7b7b6f50ba..aaea557490 100644 --- a/OpenRA.Mods.Cnc/CncLoadScreen.cs +++ b/OpenRA.Mods.Cnc/CncLoadScreen.cs @@ -36,6 +36,8 @@ namespace OpenRA.Mods.Cnc public override void Init(ModData modData, Dictionary info) { + base.Init(modData, info); + loadInfo = info; // Avoid standard loading mechanisms so we diff --git a/OpenRA.Mods.Common/LoadScreens/BlankLoadScreen.cs b/OpenRA.Mods.Common/LoadScreens/BlankLoadScreen.cs index 421ea380fc..859c214c69 100644 --- a/OpenRA.Mods.Common/LoadScreens/BlankLoadScreen.cs +++ b/OpenRA.Mods.Common/LoadScreens/BlankLoadScreen.cs @@ -12,6 +12,7 @@ using System; using System.Collections.Generic; using System.IO; +using System.Linq; using OpenRA.FileFormats; using OpenRA.Mods.Common.Widgets.Logic; using OpenRA.Widgets; @@ -21,8 +22,12 @@ namespace OpenRA.Mods.Common.LoadScreens public class BlankLoadScreen : ILoadScreen { public LaunchArguments Launch; + ModData modData; - public virtual void Init(ModData m, Dictionary info) { } + public virtual void Init(ModData modData, Dictionary info) + { + this.modData = modData; + } public virtual void Display() { @@ -97,5 +102,13 @@ namespace OpenRA.Mods.Common.LoadScreens Dispose(true); GC.SuppressFinalize(this); } + + public bool RequiredContentIsInstalled() + { + var content = modData.Manifest.Get(); + return content.Packages + .Where(p => p.Value.Required) + .All(p => p.Value.TestFiles.All(f => File.Exists(Platform.ResolvePath(f)))); + } } } \ No newline at end of file diff --git a/OpenRA.Mods.Common/LoadScreens/LogoStripeLoadScreen.cs b/OpenRA.Mods.Common/LoadScreens/LogoStripeLoadScreen.cs index bd26c79e52..5331be52af 100644 --- a/OpenRA.Mods.Common/LoadScreens/LogoStripeLoadScreen.cs +++ b/OpenRA.Mods.Common/LoadScreens/LogoStripeLoadScreen.cs @@ -31,6 +31,8 @@ namespace OpenRA.Mods.Common.LoadScreens public override void Init(ModData modData, Dictionary info) { + base.Init(modData, info); + // Avoid standard loading mechanisms so we // can display the loadscreen as early as possible r = Game.Renderer; diff --git a/OpenRA.Mods.Common/LoadScreens/ModChooserLoadScreen.cs b/OpenRA.Mods.Common/LoadScreens/ModChooserLoadScreen.cs index 99c24ee948..39d0bd7787 100644 --- a/OpenRA.Mods.Common/LoadScreens/ModChooserLoadScreen.cs +++ b/OpenRA.Mods.Common/LoadScreens/ModChooserLoadScreen.cs @@ -11,7 +11,6 @@ using System.Collections.Generic; using System.Drawing; -using System.IO; using OpenRA.Graphics; using OpenRA.Widgets; @@ -58,5 +57,10 @@ namespace OpenRA.Mods.Common.LoadScreens if (sprite != null) sprite.Sheet.Dispose(); } + + public bool RequiredContentIsInstalled() + { + return true; + } } } \ No newline at end of file diff --git a/OpenRA.Game/ModContent.cs b/OpenRA.Mods.Common/ModContent.cs similarity index 100% rename from OpenRA.Game/ModContent.cs rename to OpenRA.Mods.Common/ModContent.cs diff --git a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj index a517a6c0c3..9822fde854 100644 --- a/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj +++ b/OpenRA.Mods.Common/OpenRA.Mods.Common.csproj @@ -778,6 +778,7 @@ +