more unfailing: fix bug in prev, and use Game.CreateObject() instead of handrolling garbage

This commit is contained in:
Chris Forbes
2010-04-24 23:12:11 +12:00
parent 89b36764c6
commit 6732cd6c34

View File

@@ -44,17 +44,7 @@ namespace OpenRA
static Widget NewWidget(string widgetType)
{
widgetType = widgetType.Split('@')[0];
foreach (var mod in Game.ModAssemblies)
{
var fullTypeName = mod.Second + "." + widgetType + "Widget";
var widget = (Widget)mod.First.CreateInstance(fullTypeName);
if (widget == null) continue;
return widget;
}
throw new InvalidOperationException("Cannot locate widget: {0}".F(widgetType));
return Game.CreateObject<Widget>(widgetType + "Widget");
}
}
}