From fff41a44ed4682b9d3d581e324a57b564b491a51 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 29 Sep 2024 13:05:08 +0100 Subject: [PATCH] Make Mod Content button optional. --- .../Widgets/Logic/MainMenuLogic.cs | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/OpenRA.Mods.Common/Widgets/Logic/MainMenuLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/MainMenuLogic.cs index 2a23181582..ddc5fa7da5 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/MainMenuLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/MainMenuLogic.cs @@ -80,16 +80,25 @@ namespace OpenRA.Mods.Common.Widgets.Logic mainMenu.Get("MULTIPLAYER_BUTTON").OnClick = OpenMultiplayerPanel; - mainMenu.Get("CONTENT_BUTTON").OnClick = () => + var contentButton = mainMenu.GetOrNull("CONTENT_BUTTON"); + if (contentButton != null) { - // Switching mods changes the world state (by disposing it), - // so we can't do this inside the input handler. - Game.RunAfterTick(() => + var hasContent = modData.Manifest.Contains(); + contentButton.Disabled = !hasContent; + contentButton.OnClick = () => { - var content = modData.Manifest.Get(); - Game.InitializeMod(content.ContentInstallerMod, new Arguments(new[] { "Content.Mod=" + modData.Manifest.Id })); - }); - }; + // Switching mods changes the world state (by disposing it), + // so we can't do this inside the input handler. + Game.RunAfterTick(() => + { + if (!hasContent) + return; + + var content = modData.Manifest.Get(); + Game.InitializeMod(content.ContentInstallerMod, new Arguments(new[] { "Content.Mod=" + modData.Manifest.Id })); + }); + }; + } mainMenu.Get("SETTINGS_BUTTON").OnClick = () => {