End the mission when a script error occurs.
This commit is contained in:
@@ -193,6 +193,13 @@ namespace OpenRA.Scripting
|
|||||||
Log.Write("lua", stacktrace);
|
Log.Write("lua", stacktrace);
|
||||||
|
|
||||||
FatalErrorOccurred = true;
|
FatalErrorOccurred = true;
|
||||||
|
|
||||||
|
World.AddFrameEndTask(w =>
|
||||||
|
{
|
||||||
|
World.EndGame();
|
||||||
|
World.SetPauseState(true);
|
||||||
|
World.PauseStateLocked = true;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RegisterMapActor(string name, Actor a)
|
public void RegisterMapActor(string name, Actor a)
|
||||||
|
|||||||
@@ -50,5 +50,7 @@ namespace OpenRA.Mods.RA.Scripting
|
|||||||
if (context != null)
|
if (context != null)
|
||||||
context.Dispose();
|
context.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool FatalErrorOccurred { get { return context.FatalErrorOccurred; } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using OpenRA.Mods.RA.Scripting;
|
||||||
using OpenRA.Network;
|
using OpenRA.Network;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
using OpenRA.Widgets;
|
using OpenRA.Widgets;
|
||||||
@@ -34,9 +35,11 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
|
|
||||||
var showStats = false;
|
var showStats = false;
|
||||||
|
|
||||||
|
var scriptContext = world.WorldActor.TraitOrDefault<LuaScript>();
|
||||||
var iop = world.WorldActor.TraitsImplementing<IObjectivesPanel>().FirstOrDefault();
|
var iop = world.WorldActor.TraitsImplementing<IObjectivesPanel>().FirstOrDefault();
|
||||||
var isMultiplayer = !world.LobbyInfo.IsSinglePlayer && !world.IsReplay;
|
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;
|
var showTabs = hasObjectives && isMultiplayer;
|
||||||
currentTab = hasObjectives ? Tab.Objectives : Tab.Chat;
|
currentTab = hasObjectives ? Tab.Objectives : Tab.Chat;
|
||||||
|
|
||||||
@@ -114,8 +117,9 @@ namespace OpenRA.Mods.RA.Widgets
|
|||||||
|
|
||||||
if (hasObjectives)
|
if (hasObjectives)
|
||||||
{
|
{
|
||||||
|
var panel = hasError ? "SCRIPT_ERROR_PANEL" : iop.PanelName;
|
||||||
var objectivesContainer = dialog.Get<ContainerWidget>("OBJECTIVES_PANEL");
|
var objectivesContainer = dialog.Get<ContainerWidget>("OBJECTIVES_PANEL");
|
||||||
Game.LoadWidget(world, iop.PanelName, objectivesContainer, new WidgetArgs());
|
Game.LoadWidget(world, panel, objectivesContainer, new WidgetArgs());
|
||||||
objectivesContainer.IsVisible = () => currentTab == Tab.Objectives;
|
objectivesContainer.IsVisible = () => currentTab == Tab.Objectives;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
27
mods/cnc/chrome/ingame-infoscripterror.yaml
Normal file
27
mods/cnc/chrome/ingame-infoscripterror.yaml
Normal file
@@ -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.
|
||||||
@@ -116,6 +116,8 @@ Container@LEAVE_MAP_WIDGET:
|
|||||||
Font: Bold
|
Font: Bold
|
||||||
Text: Statistics
|
Text: Statistics
|
||||||
Container@OBJECTIVES_PANEL:
|
Container@OBJECTIVES_PANEL:
|
||||||
|
Width: PARENT_RIGHT
|
||||||
|
Height: 365
|
||||||
Container@DIALOG_CHAT_PANEL:
|
Container@DIALOG_CHAT_PANEL:
|
||||||
X: 15
|
X: 15
|
||||||
Y: 15
|
Y: 15
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ ChromeLayout:
|
|||||||
./mods/cnc/chrome/ingame-debug.yaml
|
./mods/cnc/chrome/ingame-debug.yaml
|
||||||
./mods/cnc/chrome/ingame-info.yaml
|
./mods/cnc/chrome/ingame-info.yaml
|
||||||
./mods/cnc/chrome/ingame-infobriefing.yaml
|
./mods/cnc/chrome/ingame-infobriefing.yaml
|
||||||
|
./mods/cnc/chrome/ingame-infoscripterror.yaml
|
||||||
./mods/cnc/chrome/ingame-infoobjectives.yaml
|
./mods/cnc/chrome/ingame-infoobjectives.yaml
|
||||||
./mods/cnc/chrome/ingame-infostats.yaml
|
./mods/cnc/chrome/ingame-infostats.yaml
|
||||||
./mods/cnc/chrome/ingame-leavemap.yaml
|
./mods/cnc/chrome/ingame-leavemap.yaml
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ ChromeLayout:
|
|||||||
./mods/ra/chrome/ingame-fmvplayer.yaml
|
./mods/ra/chrome/ingame-fmvplayer.yaml
|
||||||
./mods/d2k/chrome/ingame-menu.yaml
|
./mods/d2k/chrome/ingame-menu.yaml
|
||||||
./mods/ra/chrome/ingame-info.yaml
|
./mods/ra/chrome/ingame-info.yaml
|
||||||
|
./mods/ra/chrome/ingame-infoscripterror.yaml
|
||||||
./mods/ra/chrome/ingame-infobriefing.yaml
|
./mods/ra/chrome/ingame-infobriefing.yaml
|
||||||
./mods/ra/chrome/ingame-infoobjectives.yaml
|
./mods/ra/chrome/ingame-infoobjectives.yaml
|
||||||
./mods/ra/chrome/ingame-infostats.yaml
|
./mods/ra/chrome/ingame-infostats.yaml
|
||||||
|
|||||||
27
mods/ra/chrome/ingame-infoscripterror.yaml
Normal file
27
mods/ra/chrome/ingame-infoscripterror.yaml
Normal file
@@ -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.
|
||||||
@@ -126,6 +126,7 @@ Container@LEAVE_MAP_WIDGET:
|
|||||||
Text: Leave
|
Text: Leave
|
||||||
Container@OBJECTIVES_PANEL:
|
Container@OBJECTIVES_PANEL:
|
||||||
Y: 65
|
Y: 65
|
||||||
|
Width: PARENT_RIGHT
|
||||||
Container@DIALOG_CHAT_PANEL:
|
Container@DIALOG_CHAT_PANEL:
|
||||||
X: 20
|
X: 20
|
||||||
Y: 65
|
Y: 65
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ ChromeLayout:
|
|||||||
./mods/ra/chrome/ingame-diplomacy.yaml
|
./mods/ra/chrome/ingame-diplomacy.yaml
|
||||||
./mods/ra/chrome/ingame-fmvplayer.yaml
|
./mods/ra/chrome/ingame-fmvplayer.yaml
|
||||||
./mods/ra/chrome/ingame-info.yaml
|
./mods/ra/chrome/ingame-info.yaml
|
||||||
|
./mods/ra/chrome/ingame-infoscripterror.yaml
|
||||||
./mods/ra/chrome/ingame-infobriefing.yaml
|
./mods/ra/chrome/ingame-infobriefing.yaml
|
||||||
./mods/ra/chrome/ingame-infoobjectives.yaml
|
./mods/ra/chrome/ingame-infoobjectives.yaml
|
||||||
./mods/ra/chrome/ingame-infostats.yaml
|
./mods/ra/chrome/ingame-infostats.yaml
|
||||||
|
|||||||
@@ -106,6 +106,7 @@ ChromeLayout:
|
|||||||
./mods/ra/chrome/ingame-fmvplayer.yaml
|
./mods/ra/chrome/ingame-fmvplayer.yaml
|
||||||
./mods/ra/chrome/ingame-menu.yaml
|
./mods/ra/chrome/ingame-menu.yaml
|
||||||
./mods/ra/chrome/ingame-info.yaml
|
./mods/ra/chrome/ingame-info.yaml
|
||||||
|
./mods/ra/chrome/ingame-infoscripterror.yaml
|
||||||
./mods/ra/chrome/ingame-infobriefing.yaml
|
./mods/ra/chrome/ingame-infobriefing.yaml
|
||||||
./mods/ra/chrome/ingame-infoobjectives.yaml
|
./mods/ra/chrome/ingame-infoobjectives.yaml
|
||||||
./mods/ra/chrome/ingame-infostats.yaml
|
./mods/ra/chrome/ingame-infostats.yaml
|
||||||
|
|||||||
Reference in New Issue
Block a user