From f1b9b31f07d8cfedce54b7c520acf61b72e50ac0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Thu, 6 Aug 2015 09:15:58 +0200 Subject: [PATCH 1/3] remove duplicated line --- OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameMenuLogic.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameMenuLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameMenuLogic.cs index 678af1bf57..be00ff9354 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameMenuLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/IngameMenuLogic.cs @@ -108,7 +108,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic hideMenu = true; ConfirmationDialogs.PromptConfirmAction("Surrender", "Are you sure you want to surrender?", onSurrender, showMenu); }; - surrenderButton.IsDisabled = () => world.LocalPlayer == null || world.LocalPlayer.WinState != WinState.Undefined; var saveMapButton = menu.Get("SAVE_MAP"); saveMapButton.IsVisible = () => world.Type == WorldType.Editor; 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 2/3] 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; From 7a466890e53048ad0eeee1dc69deb33cebb0eefb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Thu, 6 Aug 2015 09:17:09 +0200 Subject: [PATCH 3/3] hide tabs when script errors occur --- OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoLogic.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoLogic.cs index 08eae9e622..f8e15c84ac 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Ingame/GameInfoLogic.cs @@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic numTabs++; var objectivesTabButton = widget.Get(string.Concat("BUTTON", numTabs.ToString())); objectivesTabButton.GetText = () => "Objectives"; - objectivesTabButton.IsVisible = () => lp != null && numTabs > 1; + objectivesTabButton.IsVisible = () => lp != null && numTabs > 1 && !hasError; objectivesTabButton.OnClick = () => activePanel = IngameInfoPanel.Objectives; objectivesTabButton.IsHighlighted = () => activePanel == IngameInfoPanel.Objectives; @@ -59,7 +59,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic numTabs++; var mapTabButton = widget.Get(string.Concat("BUTTON", numTabs.ToString())); mapTabButton.Text = "Briefing"; - mapTabButton.IsVisible = () => numTabs > 1; + mapTabButton.IsVisible = () => numTabs > 1 && !hasError; mapTabButton.OnClick = () => activePanel = IngameInfoPanel.Map; mapTabButton.IsHighlighted = () => activePanel == IngameInfoPanel.Map; @@ -78,7 +78,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic numTabs++; var debugTabButton = widget.Get(string.Concat("BUTTON", numTabs.ToString())); debugTabButton.Text = "Debug"; - debugTabButton.IsVisible = () => lp != null && world.LobbyInfo.GlobalSettings.AllowCheats && numTabs > 1; + debugTabButton.IsVisible = () => lp != null && world.LobbyInfo.GlobalSettings.AllowCheats && numTabs > 1 && !hasError; debugTabButton.IsDisabled = () => world.IsGameOver; debugTabButton.OnClick = () => activePanel = IngameInfoPanel.Debug; debugTabButton.IsHighlighted = () => activePanel == IngameInfoPanel.Debug;