make it crash nicely when you inherit from a bogus actor type
This commit is contained in:
committed by
Chris Forbes
parent
cee021ef17
commit
1af23079eb
@@ -41,7 +41,8 @@ namespace OpenRA
|
||||
MiniYaml parent;
|
||||
allUnits.TryGetValue( inherits.Value, out parent );
|
||||
if (parent == null)
|
||||
return null;
|
||||
throw new InvalidOperationException(
|
||||
"Bogus inheritance -- actor type {0} does not exist".F(inherits.Value));
|
||||
|
||||
return parent;
|
||||
}
|
||||
|
||||
@@ -123,13 +123,18 @@ namespace OpenRA.Widgets
|
||||
|
||||
public void PostInit(Dictionary<string, object> args)
|
||||
{
|
||||
if( Delegate != null )
|
||||
{
|
||||
if (Delegate == null)
|
||||
return;
|
||||
|
||||
args["widget"] = this;
|
||||
Game.modData.ObjectCreator.CreateObject<IWidgetDelegate>(Delegate, args);
|
||||
|
||||
var iwd = Game.modData.ObjectCreator.CreateObject<IWidgetDelegate>(Delegate, args)
|
||||
as IWidgetDelegateEx;
|
||||
if (iwd != null)
|
||||
iwd.Init();
|
||||
|
||||
args.Remove("widget");
|
||||
}
|
||||
}
|
||||
|
||||
public virtual Rectangle EventBounds { get { return RenderBounds; } }
|
||||
public virtual Rectangle GetEventBounds()
|
||||
@@ -339,16 +344,19 @@ namespace OpenRA.Widgets
|
||||
}
|
||||
}
|
||||
|
||||
public class ContainerWidget : Widget {
|
||||
public class ContainerWidget : Widget
|
||||
{
|
||||
public Func<string> GetBackground;
|
||||
public string Background = null;
|
||||
|
||||
public ContainerWidget() : base()
|
||||
public ContainerWidget()
|
||||
: base()
|
||||
{
|
||||
GetBackground = () => Background;
|
||||
}
|
||||
|
||||
public ContainerWidget(ContainerWidget other) : base(other)
|
||||
public ContainerWidget(ContainerWidget other)
|
||||
: base(other)
|
||||
{
|
||||
Background = other.Background;
|
||||
GetBackground = other.GetBackground;
|
||||
@@ -364,5 +372,10 @@ namespace OpenRA.Widgets
|
||||
public override string GetCursor(int2 pos) { return null; }
|
||||
public override Widget Clone() { return new ContainerWidget(this); }
|
||||
}
|
||||
|
||||
public interface IWidgetDelegate { }
|
||||
public interface IWidgetDelegateEx : IWidgetDelegate
|
||||
{
|
||||
void Init();
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,7 @@ using System.Drawing;
|
||||
|
||||
namespace OpenRA.Mods.RA.Widgets.Delegates
|
||||
{
|
||||
public class GameInitDelegate : IWidgetDelegate
|
||||
public class GameInitDelegate : IWidgetDelegateEx
|
||||
{
|
||||
GameInitInfoWidget Info;
|
||||
|
||||
@@ -31,7 +31,10 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
||||
public GameInitDelegate([ObjectCreator.Param] Widget widget)
|
||||
{
|
||||
Info = (widget as GameInitInfoWidget);
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
Game.ConnectionStateChanged += orderManager =>
|
||||
{
|
||||
Widget.CloseWindow();
|
||||
@@ -60,7 +63,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
||||
};
|
||||
|
||||
if (FileSystem.Exists(Info.TestFile))
|
||||
ContinueLoading(widget);
|
||||
ContinueLoading();
|
||||
else
|
||||
{
|
||||
MainMenuButtonsDelegate.DisplayModSelector();
|
||||
@@ -115,7 +118,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
||||
Action onComplete = () =>
|
||||
{
|
||||
if (!error)
|
||||
Game.RunAfterTick(() => ContinueLoading(Info));
|
||||
Game.RunAfterTick(ContinueLoading);
|
||||
};
|
||||
|
||||
if (Info.InstallMode == "ra")
|
||||
@@ -151,19 +154,19 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
||||
var error = false;
|
||||
Action<string> parseOutput = s =>
|
||||
{
|
||||
if (s.Substring(0,5) == "Error")
|
||||
if (s.StartsWith("Error"))
|
||||
{
|
||||
error = true;
|
||||
ShowDownloadError(window, s);
|
||||
}
|
||||
if (s.Substring(0,6) == "Status")
|
||||
if (s.StartsWith("Status"))
|
||||
window.GetWidget<LabelWidget>("STATUS").GetText = () => s.Substring(7).Trim();
|
||||
};
|
||||
|
||||
Action onComplete = () =>
|
||||
{
|
||||
if (!error)
|
||||
Game.RunAfterTick(() => ContinueLoading(Info));
|
||||
Game.RunAfterTick(ContinueLoading);
|
||||
};
|
||||
|
||||
Game.RunAfterTick(() => Game.Utilities.ExtractZipAsync(file, FileSystem.SpecialPackageRoot+Info.PackagePath, parseOutput, onComplete));
|
||||
@@ -185,7 +188,7 @@ namespace OpenRA.Mods.RA.Widgets.Delegates
|
||||
}
|
||||
}
|
||||
|
||||
void ContinueLoading(Widget widget)
|
||||
void ContinueLoading()
|
||||
{
|
||||
Game.LoadShellMap();
|
||||
Widget.RootWidget.RemoveChildren();
|
||||
|
||||
Reference in New Issue
Block a user