update forge
This commit is contained in:
@@ -36,19 +36,61 @@ internal static class StatescriptResolverRegistry
|
||||
/// <returns>A list of compatible resolver editor factories.</returns>
|
||||
public static List<Func<NodeEditorProperty>> GetCompatibleFactories(Type expectedType)
|
||||
{
|
||||
var result = new List<Func<NodeEditorProperty>>();
|
||||
return [.. _factories.Where(factory => IsCompatibleFactory(factory, expectedType))];
|
||||
}
|
||||
|
||||
foreach (Func<NodeEditorProperty> factory in _factories)
|
||||
public static int GetDefaultFactoryIndex(List<Func<NodeEditorProperty>> factories, bool isArray)
|
||||
{
|
||||
for (int i = 0; i < factories.Count; i++)
|
||||
{
|
||||
using NodeEditorProperty temp = factory();
|
||||
|
||||
if (temp.IsCompatibleWith(expectedType))
|
||||
if (isArray)
|
||||
{
|
||||
result.Add(factory);
|
||||
if (GetResolverTypeId(factories[i]) == "ArrayVariable")
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
else if (GetResolverTypeId(factories[i]) == "Variant")
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static string GetDisplayName(Func<NodeEditorProperty> factory)
|
||||
{
|
||||
return UseTemporaryEditor(factory, static editor => editor.DisplayName);
|
||||
}
|
||||
|
||||
public static string GetResolverTypeId(Func<NodeEditorProperty> factory)
|
||||
{
|
||||
return UseTemporaryEditor(factory, static editor => editor.ResolverTypeId);
|
||||
}
|
||||
|
||||
public static bool IsCompatibleFactory(Func<NodeEditorProperty> factory, Type expectedType)
|
||||
{
|
||||
return UseTemporaryEditor(factory, editor => editor.IsCompatibleWith(expectedType));
|
||||
}
|
||||
|
||||
private static TResult UseTemporaryEditor<TResult>(
|
||||
Func<NodeEditorProperty> factory,
|
||||
Func<NodeEditorProperty, TResult> selector)
|
||||
{
|
||||
NodeEditorProperty editor = factory();
|
||||
|
||||
try
|
||||
{
|
||||
return selector(editor);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (global::Godot.GodotObject.IsInstanceValid(editor))
|
||||
{
|
||||
editor.Free();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user