diff --git a/OpenRA.Game/Scripting/ScriptContext.cs b/OpenRA.Game/Scripting/ScriptContext.cs index a1c8f85d4a..7bd03817b9 100644 --- a/OpenRA.Game/Scripting/ScriptContext.cs +++ b/OpenRA.Game/Scripting/ScriptContext.cs @@ -193,6 +193,13 @@ namespace OpenRA.Scripting Log.Write("lua", stacktrace); FatalErrorOccurred = true; + + World.AddFrameEndTask(w => + { + World.EndGame(); + World.SetPauseState(true); + World.PauseStateLocked = true; + }); } public void RegisterMapActor(string name, Actor a) diff --git a/OpenRA.Mods.RA/Scripting/LuaScript.cs b/OpenRA.Mods.RA/Scripting/LuaScript.cs index 1a23e62235..192001913e 100644 --- a/OpenRA.Mods.RA/Scripting/LuaScript.cs +++ b/OpenRA.Mods.RA/Scripting/LuaScript.cs @@ -50,5 +50,7 @@ namespace OpenRA.Mods.RA.Scripting if (context != null) context.Dispose(); } + + public bool FatalErrorOccurred { get { return context.FatalErrorOccurred; } } } } diff --git a/OpenRA.Mods.RA/Widgets/Logic/Ingame/LeaveMapLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/Ingame/LeaveMapLogic.cs index e6a76f6f95..6236eeb038 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/Ingame/LeaveMapLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/Ingame/LeaveMapLogic.cs @@ -11,6 +11,7 @@ using System; using System.Drawing; using System.Linq; +using OpenRA.Mods.RA.Scripting; using OpenRA.Network; using OpenRA.Traits; using OpenRA.Widgets; @@ -34,9 +35,11 @@ namespace OpenRA.Mods.RA.Widgets var showStats = false; + var scriptContext = world.WorldActor.TraitOrDefault(); var iop = world.WorldActor.TraitsImplementing().FirstOrDefault(); var isMultiplayer = !world.LobbyInfo.IsSinglePlayer && !world.IsReplay; - var hasObjectives = iop != null && iop.PanelName != null && world.LocalPlayer != null; + var hasError = scriptContext != null && scriptContext.FatalErrorOccurred; + var hasObjectives = hasError || (iop != null && iop.PanelName != null && world.LocalPlayer != null); var showTabs = hasObjectives && isMultiplayer; currentTab = hasObjectives ? Tab.Objectives : Tab.Chat; @@ -114,8 +117,9 @@ namespace OpenRA.Mods.RA.Widgets if (hasObjectives) { + var panel = hasError ? "SCRIPT_ERROR_PANEL" : iop.PanelName; var objectivesContainer = dialog.Get("OBJECTIVES_PANEL"); - Game.LoadWidget(world, iop.PanelName, objectivesContainer, new WidgetArgs()); + Game.LoadWidget(world, panel, objectivesContainer, new WidgetArgs()); objectivesContainer.IsVisible = () => currentTab == Tab.Objectives; } diff --git a/mods/cnc/chrome/ingame-infoscripterror.yaml b/mods/cnc/chrome/ingame-infoscripterror.yaml new file mode 100644 index 0000000000..656a2f7c49 --- /dev/null +++ b/mods/cnc/chrome/ingame-infoscripterror.yaml @@ -0,0 +1,27 @@ +Container@SCRIPT_ERROR_PANEL: + Height: PARENT_BOTTOM + Width: PARENT_RIGHT + Children: + Label@DESCA: + X: 15 + Y: 15 + Width: PARENT_RIGHT-30 + Height: 20 + Font: Bold + Align:Center + Text: The map script has encountered a fatal error + Label@DESCB: + X: 15 + Y: 45 + Width: PARENT_RIGHT-30 + Height: 20 + Font: Regular + WordWrap: true + Text: The details of the error have been saved to lua.log in the logs directory. + Label@DESCC: + X: 15 + Y: 65 + Width: PARENT_RIGHT-30 + Height: 20 + Font: Regular + Text: Please send this file to the map author so that they can fix this issue. \ No newline at end of file diff --git a/mods/cnc/chrome/ingame-leavemap.yaml b/mods/cnc/chrome/ingame-leavemap.yaml index 948f8758f7..9484644156 100644 --- a/mods/cnc/chrome/ingame-leavemap.yaml +++ b/mods/cnc/chrome/ingame-leavemap.yaml @@ -116,6 +116,8 @@ Container@LEAVE_MAP_WIDGET: Font: Bold Text: Statistics Container@OBJECTIVES_PANEL: + Width: PARENT_RIGHT + Height: 365 Container@DIALOG_CHAT_PANEL: X: 15 Y: 15 diff --git a/mods/cnc/mod.yaml b/mods/cnc/mod.yaml index 414badb611..c7d0354c08 100644 --- a/mods/cnc/mod.yaml +++ b/mods/cnc/mod.yaml @@ -93,6 +93,7 @@ ChromeLayout: ./mods/cnc/chrome/ingame-debug.yaml ./mods/cnc/chrome/ingame-info.yaml ./mods/cnc/chrome/ingame-infobriefing.yaml + ./mods/cnc/chrome/ingame-infoscripterror.yaml ./mods/cnc/chrome/ingame-infoobjectives.yaml ./mods/cnc/chrome/ingame-infostats.yaml ./mods/cnc/chrome/ingame-leavemap.yaml diff --git a/mods/d2k/mod.yaml b/mods/d2k/mod.yaml index d014c63ede..293fd183e8 100644 --- a/mods/d2k/mod.yaml +++ b/mods/d2k/mod.yaml @@ -64,6 +64,7 @@ ChromeLayout: ./mods/ra/chrome/ingame-fmvplayer.yaml ./mods/d2k/chrome/ingame-menu.yaml ./mods/ra/chrome/ingame-info.yaml + ./mods/ra/chrome/ingame-infoscripterror.yaml ./mods/ra/chrome/ingame-infobriefing.yaml ./mods/ra/chrome/ingame-infoobjectives.yaml ./mods/ra/chrome/ingame-infostats.yaml diff --git a/mods/ra/chrome/ingame-infoscripterror.yaml b/mods/ra/chrome/ingame-infoscripterror.yaml new file mode 100644 index 0000000000..656a2f7c49 --- /dev/null +++ b/mods/ra/chrome/ingame-infoscripterror.yaml @@ -0,0 +1,27 @@ +Container@SCRIPT_ERROR_PANEL: + Height: PARENT_BOTTOM + Width: PARENT_RIGHT + Children: + Label@DESCA: + X: 15 + Y: 15 + Width: PARENT_RIGHT-30 + Height: 20 + Font: Bold + Align:Center + Text: The map script has encountered a fatal error + Label@DESCB: + X: 15 + Y: 45 + Width: PARENT_RIGHT-30 + Height: 20 + Font: Regular + WordWrap: true + Text: The details of the error have been saved to lua.log in the logs directory. + Label@DESCC: + X: 15 + Y: 65 + Width: PARENT_RIGHT-30 + Height: 20 + Font: Regular + Text: Please send this file to the map author so that they can fix this issue. \ No newline at end of file diff --git a/mods/ra/chrome/ingame-leavemap.yaml b/mods/ra/chrome/ingame-leavemap.yaml index c85288b804..10aca4d920 100644 --- a/mods/ra/chrome/ingame-leavemap.yaml +++ b/mods/ra/chrome/ingame-leavemap.yaml @@ -126,6 +126,7 @@ Container@LEAVE_MAP_WIDGET: Text: Leave Container@OBJECTIVES_PANEL: Y: 65 + Width: PARENT_RIGHT Container@DIALOG_CHAT_PANEL: X: 20 Y: 65 diff --git a/mods/ra/mod.yaml b/mods/ra/mod.yaml index b1da6da59d..1231ab89f2 100644 --- a/mods/ra/mod.yaml +++ b/mods/ra/mod.yaml @@ -76,6 +76,7 @@ ChromeLayout: ./mods/ra/chrome/ingame-diplomacy.yaml ./mods/ra/chrome/ingame-fmvplayer.yaml ./mods/ra/chrome/ingame-info.yaml + ./mods/ra/chrome/ingame-infoscripterror.yaml ./mods/ra/chrome/ingame-infobriefing.yaml ./mods/ra/chrome/ingame-infoobjectives.yaml ./mods/ra/chrome/ingame-infostats.yaml diff --git a/mods/ts/mod.yaml b/mods/ts/mod.yaml index f8b385548e..cc905d1d50 100644 --- a/mods/ts/mod.yaml +++ b/mods/ts/mod.yaml @@ -106,6 +106,7 @@ ChromeLayout: ./mods/ra/chrome/ingame-fmvplayer.yaml ./mods/ra/chrome/ingame-menu.yaml ./mods/ra/chrome/ingame-info.yaml + ./mods/ra/chrome/ingame-infoscripterror.yaml ./mods/ra/chrome/ingame-infobriefing.yaml ./mods/ra/chrome/ingame-infoobjectives.yaml ./mods/ra/chrome/ingame-infostats.yaml