Merge pull request #8969 from Mailaender/script-error-polish

Fixed the script error UI not shutting down the game properly
This commit is contained in:
abcdefg30
2015-08-06 14:06:37 +02:00
2 changed files with 8 additions and 5 deletions

View File

@@ -39,7 +39,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
numTabs++; numTabs++;
var objectivesTabButton = widget.Get<ButtonWidget>(string.Concat("BUTTON", numTabs.ToString())); var objectivesTabButton = widget.Get<ButtonWidget>(string.Concat("BUTTON", numTabs.ToString()));
objectivesTabButton.GetText = () => "Objectives"; objectivesTabButton.GetText = () => "Objectives";
objectivesTabButton.IsVisible = () => lp != null && numTabs > 1; objectivesTabButton.IsVisible = () => lp != null && numTabs > 1 && !hasError;
objectivesTabButton.OnClick = () => activePanel = IngameInfoPanel.Objectives; objectivesTabButton.OnClick = () => activePanel = IngameInfoPanel.Objectives;
objectivesTabButton.IsHighlighted = () => activePanel == IngameInfoPanel.Objectives; objectivesTabButton.IsHighlighted = () => activePanel == IngameInfoPanel.Objectives;
@@ -59,7 +59,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
numTabs++; numTabs++;
var mapTabButton = widget.Get<ButtonWidget>(string.Concat("BUTTON", numTabs.ToString())); var mapTabButton = widget.Get<ButtonWidget>(string.Concat("BUTTON", numTabs.ToString()));
mapTabButton.Text = "Briefing"; mapTabButton.Text = "Briefing";
mapTabButton.IsVisible = () => numTabs > 1; mapTabButton.IsVisible = () => numTabs > 1 && !hasError;
mapTabButton.OnClick = () => activePanel = IngameInfoPanel.Map; mapTabButton.OnClick = () => activePanel = IngameInfoPanel.Map;
mapTabButton.IsHighlighted = () => activePanel == IngameInfoPanel.Map; mapTabButton.IsHighlighted = () => activePanel == IngameInfoPanel.Map;
@@ -78,7 +78,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
numTabs++; numTabs++;
var debugTabButton = widget.Get<ButtonWidget>(string.Concat("BUTTON", numTabs.ToString())); var debugTabButton = widget.Get<ButtonWidget>(string.Concat("BUTTON", numTabs.ToString()));
debugTabButton.Text = "Debug"; 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.IsDisabled = () => world.IsGameOver;
debugTabButton.OnClick = () => activePanel = IngameInfoPanel.Debug; debugTabButton.OnClick = () => activePanel = IngameInfoPanel.Debug;
debugTabButton.IsHighlighted = () => activePanel == IngameInfoPanel.Debug; debugTabButton.IsHighlighted = () => activePanel == IngameInfoPanel.Debug;

View File

@@ -11,6 +11,7 @@
using System; using System;
using System.Linq; using System.Linq;
using OpenRA.Graphics; using OpenRA.Graphics;
using OpenRA.Mods.Common.Scripting;
using OpenRA.Mods.Common.Traits; using OpenRA.Mods.Common.Traits;
using OpenRA.Traits; using OpenRA.Traits;
using OpenRA.Widgets; using OpenRA.Widgets;
@@ -35,6 +36,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var hideMenu = false; var hideMenu = false;
menu.Get("MENU_BUTTONS").IsVisible = () => !hideMenu; menu.Get("MENU_BUTTONS").IsVisible = () => !hideMenu;
var scriptContext = world.WorldActor.TraitOrDefault<LuaScript>();
var hasError = scriptContext != null && scriptContext.FatalErrorOccurred;
// TODO: Create a mechanism to do things like this cleaner. Also needed for scripted missions // TODO: Create a mechanism to do things like this cleaner. Also needed for scripted missions
Action onQuit = () => Action onQuit = () =>
{ {
@@ -102,13 +106,12 @@ namespace OpenRA.Mods.Common.Widgets.Logic
}; };
var surrenderButton = menu.Get<ButtonWidget>("SURRENDER"); var surrenderButton = menu.Get<ButtonWidget>("SURRENDER");
surrenderButton.IsVisible = () => world.Type == WorldType.Regular; 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 = () => surrenderButton.OnClick = () =>
{ {
hideMenu = true; hideMenu = true;
ConfirmationDialogs.PromptConfirmAction("Surrender", "Are you sure you want to surrender?", onSurrender, showMenu); 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<ButtonWidget>("SAVE_MAP"); var saveMapButton = menu.Get<ButtonWidget>("SAVE_MAP");
saveMapButton.IsVisible = () => world.Type == WorldType.Editor; saveMapButton.IsVisible = () => world.Type == WorldType.Editor;