浏览代码

Cleanup: Socket Type menu is now much more managable

Added a class property to the NodeSocket types to mark them as valid interface types or not.
This also lays some groundwork for more cleanup to happen soon.
This doesn't seem to have any harmful effects on group nodes, since the
interface type CAN be set to any socket bl_idname, and it won't clutter
the console or print errors - but the user cannot manually set those
types (which is good).

also added a type annotation since I need to start doing that
Joseph Brandenburg 7 月之前
父节点
当前提交
714ff789c1
共有 2 个文件被更改,包括 145 次插入116 次删除
  1. 11 10
      base_definitions.py
  2. 134 106
      socket_definitions.py

+ 11 - 10
base_definitions.py

@@ -25,6 +25,13 @@ def error_popup_draw(self, context):
 
 
 mantis_root = ".".join(__name__.split('.')[:-1]) # absolute HACK
 mantis_root = ".".join(__name__.split('.')[:-1]) # absolute HACK
 
 
+
+# https://docs.blender.org/api/master/bpy.types.NodeTree.html#bpy.types.NodeTree.valid_socket_type
+# thank you, Sverchok
+def valid_interface_types(cls : NodeTree, socket_idname : str):
+    from .socket_definitions import tell_valid_bl_idnames
+    return socket_idname in tell_valid_bl_idnames()
+
 class MantisTree(NodeTree):
 class MantisTree(NodeTree):
     '''A custom node tree type that will show up in the editor type list'''
     '''A custom node tree type that will show up in the editor type list'''
     bl_idname = 'MantisTree'
     bl_idname = 'MantisTree'
@@ -47,11 +54,8 @@ class MantisTree(NodeTree):
 
 
     if (bpy.app.version < (4, 4, 0)):  # in 4.4 this leads to a crash
     if (bpy.app.version < (4, 4, 0)):  # in 4.4 this leads to a crash
         @classmethod
         @classmethod
-        def valid_socket_type(cls : NodeTree, socket_type: str):
-            # https://docs.blender.org/api/master/bpy.types.NodeTree.html#bpy.types.NodeTree.valid_socket_type
-            from .socket_definitions import Tell_bl_idnames
-            return socket_type in Tell_bl_idnames()
-            # thank you, Sverchok
+        def valid_socket_type(cls : NodeTree, socket_idname: str):
+            return valid_interface_types(cls, socket_idname)
             
             
     def update_tree(self, context = None):
     def update_tree(self, context = None):
         if self.is_exporting:
         if self.is_exporting:
@@ -126,11 +130,8 @@ class SchemaTree(NodeTree):
 
 
     if (bpy.app.version < (4, 4, 0)):  # in 4.4 this leads to a crash
     if (bpy.app.version < (4, 4, 0)):  # in 4.4 this leads to a crash
         @classmethod
         @classmethod
-        def valid_socket_type(cls, socket_type: str):
-            # https://docs.blender.org/api/master/bpy.types.NodeTree.html#bpy.types.NodeTree.valid_socket_type
-            from .socket_definitions import Tell_bl_idnames
-            return socket_type in Tell_bl_idnames()
-            # thank you, Sverchok
+        def valid_socket_type(cls : NodeTree, socket_idname: str):
+            return valid_interface_types(cls, socket_idname)
             
             
 
 
 
 

文件差异内容过多而无法显示
+ 134 - 106
socket_definitions.py


部分文件因为文件数量过多而无法显示