Initialize mod using its manifest.
This commit is contained in:
committed by
Gustas Kažukauskas
parent
94177848a8
commit
7175e9062d
@@ -428,7 +428,10 @@ namespace OpenRA
|
||||
|
||||
ExternalMods = new ExternalMods();
|
||||
|
||||
if (modID != null && Mods.TryGetValue(modID, out _))
|
||||
if (modID == null)
|
||||
throw new InvalidOperationException("Game.Mod argument missing.");
|
||||
|
||||
if (Mods.TryGetValue(modID, out var manifest))
|
||||
{
|
||||
var launchPath = args.GetValue("Engine.LaunchPath", null);
|
||||
var launchArgs = new List<string>();
|
||||
@@ -444,12 +447,14 @@ namespace OpenRA
|
||||
|
||||
ExternalMods.ClearInvalidRegistrations(ModRegistration.User);
|
||||
}
|
||||
else
|
||||
throw new InvalidOperationException($"Unknown or invalid mod '{modID}'.");
|
||||
|
||||
Console.WriteLine("External mods:");
|
||||
foreach (var mod in ExternalMods)
|
||||
Console.WriteLine($"\t{mod.Key} ({mod.Value.Version})");
|
||||
|
||||
InitializeMod(modID, args);
|
||||
InitializeMod(manifest, args);
|
||||
}
|
||||
|
||||
public static IPlatform CreatePlatform(string platformName)
|
||||
@@ -465,7 +470,7 @@ namespace OpenRA
|
||||
return (IPlatform)platformType.GetConstructor(Type.EmptyTypes).Invoke(null);
|
||||
}
|
||||
|
||||
public static void InitializeMod(string mod, Arguments args)
|
||||
public static void InitializeMod(Manifest manifest, Arguments args)
|
||||
{
|
||||
// Clear static state if we have switched mods
|
||||
LobbyInfoChanged = () => { };
|
||||
@@ -489,17 +494,11 @@ namespace OpenRA
|
||||
|
||||
ModData = null;
|
||||
|
||||
if (mod == null)
|
||||
throw new InvalidOperationException("Game.Mod argument missing.");
|
||||
|
||||
if (!Mods.ContainsKey(mod))
|
||||
throw new InvalidOperationException($"Unknown or invalid mod '{mod}'.");
|
||||
|
||||
Console.WriteLine($"Loading mod: {mod}");
|
||||
Console.WriteLine($"Loading mod: {manifest.Id}");
|
||||
|
||||
Sound.StopVideo();
|
||||
|
||||
ModData = new ModData(Mods[mod], Mods, true);
|
||||
ModData = new ModData(manifest, Mods, true);
|
||||
|
||||
LocalPlayerProfile = new LocalPlayerProfile(Path.Combine(Platform.SupportDir, Settings.Game.AuthProfile), ModData.Manifest.Get<PlayerDatabase>());
|
||||
|
||||
|
||||
@@ -95,8 +95,8 @@ namespace OpenRA.Mods.Common.FileSystem
|
||||
|
||||
bool IFileSystemExternalContent.InstallContentIfRequired(ModData modData)
|
||||
{
|
||||
if (!isContentAvailable)
|
||||
Game.InitializeMod(ContentInstallerMod, new Arguments());
|
||||
if (!isContentAvailable && Game.Mods.TryGetValue(ContentInstallerMod, out var mod))
|
||||
Game.InitializeMod(mod, new Arguments());
|
||||
|
||||
return !isContentAvailable;
|
||||
}
|
||||
@@ -105,7 +105,8 @@ namespace OpenRA.Mods.Common.FileSystem
|
||||
{
|
||||
// Switching mods changes the world state (by disposing it),
|
||||
// so we can't do this inside the input handler.
|
||||
Game.RunAfterTick(() => Game.InitializeMod(ContentInstallerMod, new Arguments()));
|
||||
if (Game.Mods.TryGetValue(ContentInstallerMod, out var mod))
|
||||
Game.RunAfterTick(() => Game.InitializeMod(mod, new Arguments()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,8 +88,8 @@ namespace OpenRA.Mods.Common.LoadScreens
|
||||
|
||||
if (replayMeta != null)
|
||||
{
|
||||
var mod = replayMeta.GameInfo.Mod;
|
||||
if (mod != null && mod != Game.ModData.Manifest.Id && Game.Mods.ContainsKey(mod))
|
||||
var modID = replayMeta.GameInfo.Mod;
|
||||
if (modID != null && modID != Game.ModData.Manifest.Id && Game.Mods.TryGetValue(modID, out var mod))
|
||||
Game.InitializeMod(mod, args);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,11 +23,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
public ModContentLogic(ModData modData)
|
||||
{
|
||||
var content = modData.Manifest.Get<ModContent>();
|
||||
var mod = Game.Mods[content.Mod];
|
||||
if (!IsModInstalled(content))
|
||||
{
|
||||
var widgetArgs = new WidgetArgs
|
||||
{
|
||||
{ "continueLoading", () => Game.RunAfterTick(() => Game.InitializeMod(content.Mod, new Arguments())) },
|
||||
{ "continueLoading", () => Game.RunAfterTick(() => Game.InitializeMod(mod, new Arguments())) },
|
||||
{ "content", content },
|
||||
};
|
||||
|
||||
@@ -37,7 +38,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
var widgetArgs = new WidgetArgs
|
||||
{
|
||||
{ "onCancel", () => Game.RunAfterTick(() => Game.InitializeMod(content.Mod, new Arguments())) },
|
||||
{ "onCancel", () => Game.RunAfterTick(() => Game.InitializeMod(mod, new Arguments())) },
|
||||
{ "content", content },
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user