From d4a0bfe2a5f6f86bf7a9fbd86df286a227408f01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Thu, 6 Aug 2015 09:16:35 +0200 Subject: [PATCH] disable menu buttons when script errors occur --- OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameMenuLogic.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameMenuLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameMenuLogic.cs index be00ff9354..376ad36786 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameMenuLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameMenuLogic.cs @@ -11,6 +11,7 @@ using System; using System.Linq; using OpenRA.Graphics; +using OpenRA.Mods.Common.Scripting; using OpenRA.Mods.Common.Traits; using OpenRA.Traits; using OpenRA.Widgets; @@ -35,6 +36,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic var hideMenu = false; menu.Get("MENU_BUTTONS").IsVisible = () => !hideMenu; + var scriptContext = world.WorldActor.TraitOrDefault(); + var hasError = scriptContext != null && scriptContext.FatalErrorOccurred; + // TODO: Create a mechanism to do things like this cleaner. Also needed for scripted missions Action onQuit = () => { @@ -102,7 +106,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic }; var surrenderButton = menu.Get("SURRENDER"); surrenderButton.IsVisible = () => world.Type == WorldType.Regular; - surrenderButton.IsDisabled = () => (world.LocalPlayer == null || world.LocalPlayer.WinState != WinState.Undefined); + surrenderButton.IsDisabled = () => (world.LocalPlayer == null || world.LocalPlayer.WinState != WinState.Undefined) || hasError; surrenderButton.OnClick = () => { hideMenu = true;