Преглед изворни кода

Interface Classes set the multi and default value now

note that this is VERY untested and probably doesn't work for Schema
Joseph Brandenburg пре 3 недеља
родитељ
комит
fa05172de2
2 измењених фајлова са 22 додато и 13 уклоњено
  1. 2 1
      socket_definitions.py
  2. 20 12
      utilities.py

+ 2 - 1
socket_definitions.py

@@ -322,7 +322,8 @@ class MantisInterfaceSocketBaseClass():
                         " with an input and an output." ) 
     connected_to : bpy.props.StringProperty(default="", update=interface_socket_update,
             description="The name of the socket this one is connected to." ) 
-
+    # we are just gonna use ONE base class (it's easier)
+    # so generate ALL properties and show only what is needed.
     default_string : bpy.props.StringProperty(default="", update=interface_socket_update,
             description=interface_default_value_description, ) 
     default_float : bpy.props.FloatProperty(default=0.0, update=interface_socket_update,

+ 20 - 12
utilities.py

@@ -271,21 +271,29 @@ def update_interface(interface, name, in_out, sock_type, parent_name):
 def relink_socket_map_add_socket(node, socket_collection, item, in_out=None,):
     from bpy.app import version as bpy_version
     if not in_out: in_out=item.in_out
+    if hasattr(item, 'is_array'):
+        multi = item.is_array
     if node.bl_idname in ['MantisSchemaGroup'] and item.parent and item.parent.name == 'Array':
         multi = True if in_out == 'INPUT' else False
-        # have to work around a bug in 4.5.0 that prevents me from declaring custom socket types
-        # I have arbitrarily chosen to use the NodeSocketGeometry type to signal that this one is affected.
-        if bpy_version == (4, 5, 0) and item.bl_socket_idname == 'NodeSocketGeometry':
-            from .versioning import socket_add_workaround_for_4_5_0_LTS
-            s = socket_add_workaround_for_4_5_0_LTS(item, socket_collection, multi)
-        else:
-            s = socket_collection.new(type=item.bl_socket_idname, name=item.name, identifier=item.identifier,  use_multi_input=multi)
+    # have to work around a bug in 4.5.0 that prevents me from declaring custom socket types
+    # I have arbitrarily chosen to use the NodeSocketGeometry type to signal that this one is affected.
+    if bpy_version == (4, 5, 0) and item.bl_socket_idname == 'NodeSocketGeometry':
+        from .versioning import socket_add_workaround_for_4_5_0_LTS
+        s = socket_add_workaround_for_4_5_0_LTS(item, socket_collection, multi)
     else:
-        if bpy_version == (4, 5, 0) and item.bl_socket_idname == 'NodeSocketGeometry':
-            from .versioning import socket_add_workaround_for_4_5_0_LTS
-            s = socket_add_workaround_for_4_5_0_LTS(item, socket_collection, multi=False,)
-        else:
-            s = socket_collection.new(type=item.bl_socket_idname, name=item.name, identifier=item.identifier)
+        s = socket_collection.new(type=item.bl_socket_idname, name=item.name, identifier=item.identifier,  use_multi_input=multi)
+    if hasattr(s, 'default_value'):
+        from bpy.types import bpy_prop_array
+        from mathutils import Vector
+        default_value = 'REPORT BUG ON GITLAB' # default to bug string
+        val_type = type(s.default_value) # why tf can't I match/case here?
+        if val_type is bool: default_value = item.default_bool
+        if val_type is int: default_value = item.default_int
+        if val_type is float: default_value = item.default_float
+        if val_type is Vector: default_value = item.default_float
+        if val_type is str: default_value = item.default_string
+        if val_type is bpy_prop_array: default_value = item.default_float
+        s.default_value = default_value
     if item.parent.name == 'Array': s.display_shape = 'SQUARE_DOT'
     elif item.parent.name == 'Constant': s.display_shape='CIRCLE_DOT'
     return s