瀏覽代碼

Compatibility improvements for 5.0

Joseph Brandenburg 3 月之前
父節點
當前提交
17c6920b48
共有 4 個文件被更改,包括 9 次插入4 次删除
  1. 1 1
      base_definitions.py
  2. 3 0
      drivers.py
  3. 3 1
      socket_definitions.py
  4. 2 2
      utilities.py

+ 1 - 1
base_definitions.py

@@ -262,7 +262,7 @@ class MantisUINode:
             socket.hide= template.hide
             if template.category:
                 # a custom property for the UI functions to use.
-                socket['category'] = template.category
+                socket.category = template.category
             if template.default_value is not None:
                 socket.default_value = template.default_value
                 # this can throw a TypeError - it is the caller's

+ 3 - 0
drivers.py

@@ -48,6 +48,7 @@ class MantisDriver(dict):
     pass
 
 def CreateDrivers(drivers):
+    from bpy.app import version
     def brackets(s):
         return "[\""+s+"\"]"
     from bpy.types import Object, Key
@@ -65,6 +66,8 @@ def CreateDrivers(drivers):
             fc.modifiers.remove(fc.modifiers[0])
         except IndexError: #haven't seen this happen, but should handle
             pass # perhaps this has been fixed for 3.0?
+        if version >= (5,0,0): # and now it initializes with keys. p
+            fc.keyframe_points.clear()
         drv.type = driver["type"]
         if (expr := driver.get("expression")) and isinstance(expr, str):
             drv.expression = expr

+ 3 - 1
socket_definitions.py

@@ -27,12 +27,15 @@ if bpy_version == (4,5,0): # THere is a bug that requires the socket type to inh
     from bpy.types import NodeSocketGeometry # so we will just inherit from NodeSocketGeometry
     class MantisSocket(NodeSocketGeometry, NodeSocket): # even though that is kinda silly
         is_valid_interface_type=False
+        category : bpy.props.StringProperty()
         @property # making this a classmethod is apparently not gonna work
         def interface_type(self):
             return NodeSocketGeometry.bl_idname
+        
 else:
     class MantisSocket(NodeSocket):
         is_valid_interface_type=False
+        category : bpy.props.StringProperty()
         @property
         def interface_type(self):
             # this is stupid but it is the fastest way to implement this
@@ -2540,7 +2543,6 @@ class EnumDriverType(MantisSocket):
 # enum for interpolation type
 # eventually gonna make it to the fancy stuff
 
-
 class FloatSocket(MantisSocket):
     """Float Input socket"""
     bl_idname = 'FloatSocket'

+ 2 - 2
utilities.py

@@ -145,8 +145,8 @@ def get_socket_maps(node, force=False):
                     keep_sockets.append(other_socket)
                 map[sock.identifier]= keep_sockets
             elif hasattr(sock, "default_value"):
-                if sock.get("default_value") is not None:
-                    val = sock['default_value']
+                if getattr(sock, "default_value") is not None:
+                    val = getattr(sock, "default_value")
                 elif sock.bl_idname == "EnumCurveSocket" and sock.get("default_value") is None:
                     # HACK I need to add this special case because during file-load,
                     #  this value is None and should not be altered until it is set once.