소스 검색

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
 
+
+# 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):
     '''A custom node tree type that will show up in the editor type list'''
     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
         @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):
         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
         @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


이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.