From 277d5dde39c09e1955381c32c97a1cbd731ebdc4 Mon Sep 17 00:00:00 2001 From: 1k8 Date: Tue, 6 Aug 2024 10:21:42 -0400 Subject: [PATCH] Update arm_sockets.py Upgrading and testing on Blender 4.3 --- blender/arm/logicnode/arm_sockets.py | 64 +++++++++++++++++++--------- 1 file changed, 44 insertions(+), 20 deletions(-) diff --git a/blender/arm/logicnode/arm_sockets.py b/blender/arm/logicnode/arm_sockets.py index 4604d11fb7..3c1d0014da 100644 --- a/blender/arm/logicnode/arm_sockets.py +++ b/blender/arm/logicnode/arm_sockets.py @@ -595,27 +595,51 @@ def draw_socket_layout_split(socket: bpy.types.NodeSocket, layout: bpy.types.UIL layout.prop(socket, prop_name, text='') -def _make_socket_interface(interface_name: str, bl_idname: str) -> Type[bpy.types.NodeSocketInterface]: - """Create a socket interface class that is used by Blender for node - groups. We currently don't use real node groups, but without these - classes Blender will (incorrectly) draw the socket borders in light grey. - """ - def draw(self, context, layout): - pass +if bpy.app.version < (4, 1, 0): + def _make_socket_interface(interface_name: str, bl_idname: str) -> Type[bpy.types.NodeSocketInterface]: + """Create a socket interface class that is used by Blender for node + groups. We currently don't use real node groups, but without these + classes Blender will (incorrectly) draw the socket borders in light grey. + """ + def draw(self, context, layout): + pass + + def draw_color(self, context): + # This would be used if we were using "real" node groups + return 0, 0, 0, 1 + + cls = type( + interface_name, + (bpy.types.NodeSocketInterface, ), { + 'bl_socket_idname': bl_idname, + 'draw': draw, + 'draw_color': draw_color, + } + ) + return cls +else: + def _make_socket_interface(interface_name: str, bl_idname: str) -> Type[bpy.types.NodeTreeInterfaceSocket]: + """Create a socket interface class that is used by Blender for node + groups. We currently don't use real node groups, but without these + classes Blender will (incorrectly) draw the socket borders in light grey. + """ + def draw(self, context, layout): + pass + + def draw_color(self, context): + # This would be used if we were using "real" node groups + return 0, 0, 0, 1 + + cls = type( + interface_name, + (bpy.types.NodeTreeInterfaceSocket, ), { + 'bl_socket_idname': bl_idname, + 'draw': draw, + 'draw_color': draw_color, + } + ) + return cls - def draw_color(self, context): - # This would be used if we were using "real" node groups - return 0, 0, 0, 1 - - cls = type( - interface_name, - (bpy.types.NodeSocketInterface, ), { - 'bl_socket_idname': bl_idname, - 'draw': draw, - 'draw_color': draw_color, - } - ) - return cls ArmActionSocketInterface = _make_socket_interface('ArmActionSocketInterface', 'ArmNodeSocketAction')