Make Mod Content button optional.

This commit is contained in:
Paul Chote
2024-09-29 13:05:08 +01:00
committed by Gustas
parent eac6d4b617
commit fff41a44ed

View File

@@ -80,16 +80,25 @@ namespace OpenRA.Mods.Common.Widgets.Logic
mainMenu.Get<ButtonWidget>("MULTIPLAYER_BUTTON").OnClick = OpenMultiplayerPanel; mainMenu.Get<ButtonWidget>("MULTIPLAYER_BUTTON").OnClick = OpenMultiplayerPanel;
mainMenu.Get<ButtonWidget>("CONTENT_BUTTON").OnClick = () => var contentButton = mainMenu.GetOrNull<ButtonWidget>("CONTENT_BUTTON");
if (contentButton != null)
{ {
// Switching mods changes the world state (by disposing it), var hasContent = modData.Manifest.Contains<ModContent>();
// so we can't do this inside the input handler. contentButton.Disabled = !hasContent;
Game.RunAfterTick(() => contentButton.OnClick = () =>
{ {
var content = modData.Manifest.Get<ModContent>(); // Switching mods changes the world state (by disposing it),
Game.InitializeMod(content.ContentInstallerMod, new Arguments(new[] { "Content.Mod=" + modData.Manifest.Id })); // so we can't do this inside the input handler.
}); Game.RunAfterTick(() =>
}; {
if (!hasContent)
return;
var content = modData.Manifest.Get<ModContent>();
Game.InitializeMod(content.ContentInstallerMod, new Arguments(new[] { "Content.Mod=" + modData.Manifest.Id }));
});
};
}
mainMenu.Get<ButtonWidget>("SETTINGS_BUTTON").OnClick = () => mainMenu.Get<ButtonWidget>("SETTINGS_BUTTON").OnClick = () =>
{ {