Make Mod Content button optional.
This commit is contained in:
@@ -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 = () =>
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user