disable menu buttons when script errors occur

This commit is contained in:
Matthias Mailänder
2015-08-06 09:16:35 +02:00
parent f1b9b31f07
commit d4a0bfe2a5

View File

@@ -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<LuaScript>();
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<ButtonWidget>("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;