Replace sandbox wrapper scripts.

This commit is contained in:
Matthias Mailänder
2023-05-08 21:04:45 +02:00
committed by abcdefg30
parent e8dd85419f
commit 445b736885
15 changed files with 188 additions and 763 deletions

View File

@@ -35,7 +35,7 @@ namespace OpenRA.Mods.Common.Activities
}
catch (Exception ex)
{
context.FatalError(ex.Message);
context.FatalError(ex);
}
Dispose();

View File

@@ -172,7 +172,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (LuaException e)
{
Context.FatalError(e.Message);
Context.FatalError(e);
}
};
}

View File

@@ -45,7 +45,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception e)
{
Context.FatalError(e.Message);
Context.FatalError(e);
}
}
@@ -104,7 +104,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception e)
{
Context.FatalError(e.Message);
Context.FatalError(e);
}
}
@@ -133,7 +133,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception e)
{
Context.FatalError(e.Message);
Context.FatalError(e);
}
}
@@ -228,7 +228,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception e)
{
Context.FatalError(e.Message);
Context.FatalError(e);
}
}
@@ -243,7 +243,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception e)
{
Context.FatalError(e.Message);
Context.FatalError(e);
}
}
@@ -282,7 +282,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception e)
{
Context.FatalError(e.Message);
Context.FatalError(e);
}
}
@@ -310,7 +310,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception e)
{
Context.FatalError(e.Message);
Context.FatalError(e);
}
}
@@ -339,7 +339,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception e)
{
Context.FatalError(e.Message);
Context.FatalError(e);
}
}
@@ -366,7 +366,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception e)
{
Context.FatalError(e.Message);
Context.FatalError(e);
}
}
@@ -399,7 +399,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception e)
{
Context.FatalError(e.Message);
Context.FatalError(e);
}
}
@@ -426,7 +426,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception e)
{
Context.FatalError(e.Message);
Context.FatalError(e);
}
}

View File

@@ -29,7 +29,7 @@ namespace OpenRA.Mods.Common.Scripting
public class LuaScript : ITick, IWorldLoaded, INotifyActorDisposing
{
readonly LuaScriptInfo info;
ScriptContext context;
public ScriptContext Context;
bool disposed;
public LuaScript(LuaScriptInfo info)
@@ -40,13 +40,13 @@ namespace OpenRA.Mods.Common.Scripting
void IWorldLoaded.WorldLoaded(World world, WorldRenderer worldRenderer)
{
var scripts = info.Scripts ?? Enumerable.Empty<string>();
context = new ScriptContext(world, worldRenderer, scripts);
context.WorldLoaded();
Context = new ScriptContext(world, worldRenderer, scripts);
Context.WorldLoaded();
}
void ITick.Tick(Actor self)
{
context.Tick();
Context.Tick();
}
void INotifyActorDisposing.Disposing(Actor self)
@@ -54,11 +54,11 @@ namespace OpenRA.Mods.Common.Scripting
if (disposed)
return;
context?.Dispose();
Context?.Dispose();
disposed = true;
}
public bool FatalErrorOccurred => context.FatalErrorOccurred;
public bool FatalErrorOccurred => Context.FatalErrorOccurred;
}
}

View File

@@ -102,7 +102,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception ex)
{
f.Context.FatalError(ex.Message);
f.Context.FatalError(ex);
return;
}
}
@@ -123,7 +123,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception ex)
{
f.Context.FatalError(ex.Message);
f.Context.FatalError(ex);
return;
}
}
@@ -144,7 +144,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception ex)
{
f.Context.FatalError(ex.Message);
f.Context.FatalError(ex);
return;
}
}
@@ -168,7 +168,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception ex)
{
f.Context.FatalError(ex.Message);
f.Context.FatalError(ex);
return;
}
}
@@ -191,7 +191,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception ex)
{
f.Context.FatalError(ex.Message);
f.Context.FatalError(ex);
return;
}
}
@@ -211,7 +211,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception ex)
{
f.Context.FatalError(ex.Message);
f.Context.FatalError(ex);
return;
}
}
@@ -232,7 +232,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception ex)
{
f.Context.FatalError(ex.Message);
f.Context.FatalError(ex);
return;
}
}
@@ -253,7 +253,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception ex)
{
f.Context.FatalError(ex.Message);
f.Context.FatalError(ex);
return;
}
}
@@ -274,7 +274,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception ex)
{
f.Context.FatalError(ex.Message);
f.Context.FatalError(ex);
return;
}
}
@@ -296,7 +296,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception ex)
{
f.Context.FatalError(ex.Message);
f.Context.FatalError(ex);
return;
}
}
@@ -319,7 +319,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception ex)
{
f.Context.FatalError(ex.Message);
f.Context.FatalError(ex);
return;
}
}
@@ -338,7 +338,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception ex)
{
f.Context.FatalError(ex.Message);
f.Context.FatalError(ex);
return;
}
}
@@ -361,7 +361,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception ex)
{
f.Context.FatalError(ex.Message);
f.Context.FatalError(ex);
return;
}
}
@@ -385,7 +385,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception ex)
{
f.Context.FatalError(ex.Message);
f.Context.FatalError(ex);
return;
}
}
@@ -408,7 +408,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception ex)
{
f.Context.FatalError(ex.Message);
f.Context.FatalError(ex);
return;
}
}
@@ -431,7 +431,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception ex)
{
f.Context.FatalError(ex.Message);
f.Context.FatalError(ex);
return;
}
}
@@ -446,7 +446,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception ex)
{
f.Context.FatalError(ex.Message);
f.Context.FatalError(ex);
return;
}
}
@@ -467,7 +467,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception ex)
{
f.Context.FatalError(ex.Message);
f.Context.FatalError(ex);
return;
}
}
@@ -488,7 +488,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception ex)
{
f.Context.FatalError(ex.Message);
f.Context.FatalError(ex);
return;
}
}
@@ -507,7 +507,7 @@ namespace OpenRA.Mods.Common.Scripting
}
catch (Exception ex)
{
f.Context.FatalError(ex.Message);
f.Context.FatalError(ex);
return;
}
}

View File

@@ -0,0 +1,37 @@
#region Copyright & License Information
/*
* Copyright (c) The OpenRA Developers and Contributors
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using OpenRA.Mods.Common.Scripting;
using OpenRA.Widgets;
namespace OpenRA.Mods.Common.Widgets.Logic
{
class ScriptErrorLogic : ChromeLogic
{
[ObjectCreator.UseCtor]
public ScriptErrorLogic(Widget widget, World world)
{
var panel = widget.Get<ScrollPanelWidget>("SCRIPT_ERROR_MESSAGE_PANEL");
var label = widget.Get<LabelWidget>("SCRIPT_ERROR_MESSAGE");
var font = Game.Renderer.Fonts[label.Font];
var luaScript = world.WorldActor.TraitOrDefault<LuaScript>();
if (luaScript != null)
{
var text = WidgetUtils.WrapText(luaScript.Context.ErrorMessage, label.Bounds.Width, font);
label.Text = text;
label.Bounds.Height = font.Measure(text).Y;
panel.ScrollToTop();
panel.Layout.AdjustChildren();
}
}
}
}