Prechádzať zdrojové kódy

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 mesiacov pred
rodič
commit
714ff789c1
2 zmenil súbory, kde vykonal 145 pridanie a 116 odobranie
  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)
             
 
 

Rozdielové dáta súboru neboli zobrazené, pretože súbor je príliš veľký
+ 134 - 106
socket_definitions.py


Niektoré súbory nie sú zobrazené, pretože je v týchto rozdielových dátach zmenené mnoho súborov