more unfailing: fix bug in prev, and use Game.CreateObject() instead of handrolling garbage
This commit is contained in:
@@ -44,17 +44,7 @@ namespace OpenRA
|
|||||||
static Widget NewWidget(string widgetType)
|
static Widget NewWidget(string widgetType)
|
||||||
{
|
{
|
||||||
widgetType = widgetType.Split('@')[0];
|
widgetType = widgetType.Split('@')[0];
|
||||||
|
return Game.CreateObject<Widget>(widgetType + "Widget");
|
||||||
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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user