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>("CONTENT_BUTTON").OnClick = () =>
var contentButton = mainMenu.GetOrNull<ButtonWidget>("CONTENT_BUTTON");
if (contentButton != null)
{
var hasContent = modData.Manifest.Contains<ModContent>();
contentButton.Disabled = !hasContent;
contentButton.OnClick = () =>
{
// 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<ModContent>();
Game.InitializeMod(content.ContentInstallerMod, new Arguments(new[] { "Content.Mod=" + modData.Manifest.Id }));
});
};
}
mainMenu.Get<ButtonWidget>("SETTINGS_BUTTON").OnClick = () =>
{