disable menu buttons when script errors occur
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user