From 78109cfee23043c4448ac32d3388f13d8075c342 Mon Sep 17 00:00:00 2001 From: Onek8 Date: Thu, 3 Apr 2025 09:41:20 +0000 Subject: [PATCH] Update leenkx/blender/lnx/logicnode/custom/LN_leenkx_send_message.py --- .../custom/LN_leenkx_send_message.py | 231 +++++++++--------- 1 file changed, 116 insertions(+), 115 deletions(-) diff --git a/leenkx/blender/lnx/logicnode/custom/LN_leenkx_send_message.py b/leenkx/blender/lnx/logicnode/custom/LN_leenkx_send_message.py index 263a50f..9bce429 100644 --- a/leenkx/blender/lnx/logicnode/custom/LN_leenkx_send_message.py +++ b/leenkx/blender/lnx/logicnode/custom/LN_leenkx_send_message.py @@ -1,116 +1,117 @@ -from lnx.logicnode.lnx_nodes import * - - -class LeenkxSendMessageNode(LnxLogicTreeNode): - """Leenkx Send Message""" - bl_idname = 'LNLeenkxSendMessageNode' - bl_label = 'Leenkx Send Message' - bl_description = 'Send messages to the Leenkx network' - lnx_category = 'Leenkx' - lnx_version = 1 - - @staticmethod - def get_enum_id_value(obj, prop_name, value): - return obj.bl_rna.properties[prop_name].enum_items[value].identifier - - @staticmethod - def get_count_in(type_name): - return { - 'client': 0, - 'host': 1, - 'securehost': 2 - }.get(type_name, 0) - - def get_enum(self): - return self.get('property0', 0) - - def set_enum(self, value): - # Checking the selection of each type - select_current = self.get_enum_id_value(self, 'property0', value) - select_prev = self.property0 - - #Check if type changed - if select_prev != select_current: - - for i in self.inputs: - self.inputs.remove(i) - - # Arguements for type Client - if (self.get_count_in(select_current) == 0): - self.add_input('LnxNodeSocketAction', 'In') - self.add_input('LnxDynamicSocket', 'Connection') - self.add_input('LnxStringSocket', 'API') - self.add_input('LnxDynamicSocket', 'Data') - self.add_input('LnxStringSocket', 'ID') - self.add_input('LnxBoolSocket', 'Send All') - - # Arguements for type Host - if (self.get_count_in(select_current) == 1): - self.add_input('LnxNodeSocketAction', 'In') - self.add_input('LnxDynamicSocket', 'Connection') - self.add_input('LnxStringSocket', 'API') - self.add_input('LnxDynamicSocket', 'Data') - self.add_input('LnxStringSocket', 'ID') - self.add_input('LnxBoolSocket', 'Send All') - - - # Arguements for type Secure Host - if (self.get_count_in(select_current) == 2): - self.add_input('LnxNodeSocketAction', 'In') - self.add_input('LnxDynamicSocket', 'Connection') - self.add_input('LnxStringSocket', 'API') - self.add_input('LnxDynamicSocket', 'Data') - self.add_input('LnxStringSocket', 'ID') - self.add_input('LnxBoolSocket', 'Send All') - - - self['property0'] = value - - - property0: HaxeEnumProperty( - 'property0', - items = [('client', 'Client', 'Network client Event listener'), - ('host', 'Host', 'Network host Event listener'), - ('securehost', 'Secure Host', 'Network secure host Event listener')], - name='', - default='client', - set=set_enum, - get=get_enum) - - - property1: HaxeEnumProperty( - 'property1', - items = [('string', 'String', 'Send a string over the network to one or all of the clients'), - ('vector', 'Vector', 'Send a vector over the network to one or all of the clients'), - ('float', 'Float', 'Send a float over the network to one or all of the clients'), - ('integer', 'Integer', 'Send an integer over the network to one or all of the clients'), - ('boolean', 'Boolean', 'Send a boolean over the network to one or all of the clients'), - ('transform', 'Transform', 'Send a transform over the network to one or all of the clients'), - ('rotation', 'Rotation', 'Send a rotation over the network to one or all of the clients')], - name='', - default='string') - - - def __init__(self): - array_nodes[str(id(self))] = self - - - def lnx_init(self, context): - self.add_input('LnxNodeSocketAction', 'In') - self.add_input('LnxDynamicSocket', 'Connection') - self.add_input('LnxStringSocket', 'API') - self.add_input('LnxDynamicSocket', 'Data') - self.add_input('LnxStringSocket', 'ID') - self.add_input('LnxBoolSocket', 'Send All') - - self.add_output('LnxNodeSocketAction', 'Out') - - - - def draw_buttons(self, context, layout): - layout.prop(self, 'property0') - layout.prop(self, 'property1') - -def register(): - add_category('Leenkx', icon='ORIENTATION_CURSOR') +from lnx.logicnode.lnx_nodes import * + + +class LeenkxSendMessageNode(LnxLogicTreeNode): + """Leenkx Send Message""" + bl_idname = 'LNLeenkxSendMessageNode' + bl_label = 'Leenkx Send Message' + bl_description = 'Send messages to the Leenkx network' + lnx_category = 'Leenkx' + lnx_version = 1 + + @staticmethod + def get_enum_id_value(obj, prop_name, value): + return obj.bl_rna.properties[prop_name].enum_items[value].identifier + + @staticmethod + def get_count_in(type_name): + return { + 'client': 0, + 'host': 1, + 'securehost': 2 + }.get(type_name, 0) + + def get_enum(self): + return self.get('property0', 0) + + def set_enum(self, value): + # Checking the selection of each type + select_current = self.get_enum_id_value(self, 'property0', value) + select_prev = self.property0 + + #Check if type changed + if select_prev != select_current: + + for i in self.inputs: + self.inputs.remove(i) + + # Arguements for type Client + if (self.get_count_in(select_current) == 0): + self.add_input('LnxNodeSocketAction', 'In') + self.add_input('LnxDynamicSocket', 'Connection') + self.add_input('LnxStringSocket', 'API') + self.add_input('LnxDynamicSocket', 'Data') + self.add_input('LnxStringSocket', 'ID') + self.add_input('LnxBoolSocket', 'Send All') + + # Arguements for type Host + if (self.get_count_in(select_current) == 1): + self.add_input('LnxNodeSocketAction', 'In') + self.add_input('LnxDynamicSocket', 'Connection') + self.add_input('LnxStringSocket', 'API') + self.add_input('LnxDynamicSocket', 'Data') + self.add_input('LnxStringSocket', 'ID') + self.add_input('LnxBoolSocket', 'Send All') + + + # Arguements for type Secure Host + if (self.get_count_in(select_current) == 2): + self.add_input('LnxNodeSocketAction', 'In') + self.add_input('LnxDynamicSocket', 'Connection') + self.add_input('LnxStringSocket', 'API') + self.add_input('LnxDynamicSocket', 'Data') + self.add_input('LnxStringSocket', 'ID') + self.add_input('LnxBoolSocket', 'Send All') + + + self['property0'] = value + + + property0: HaxeEnumProperty( + 'property0', + items = [('client', 'Client', 'Network client Event listener'), + ('host', 'Host', 'Network host Event listener'), + ('securehost', 'Secure Host', 'Network secure host Event listener')], + name='', + default='client', + set=set_enum, + get=get_enum) + + + property1: HaxeEnumProperty( + 'property1', + items = [('string', 'String', 'Send a string over the network to one or all of the clients'), + ('vector', 'Vector', 'Send a vector over the network to one or all of the clients'), + ('float', 'Float', 'Send a float over the network to one or all of the clients'), + ('integer', 'Integer', 'Send an integer over the network to one or all of the clients'), + ('boolean', 'Boolean', 'Send a boolean over the network to one or all of the clients'), + ('transform', 'Transform', 'Send a transform over the network to one or all of the clients'), + ('rotation', 'Rotation', 'Send a rotation over the network to one or all of the clients')], + name='', + default='string') + + + def __init__(self, *args, **kwargs): + super(LeenkxSendMessageNode, self).__init__(*args, **kwargs) + array_nodes[str(id(self))] = self + + + def lnx_init(self, context): + self.add_input('LnxNodeSocketAction', 'In') + self.add_input('LnxDynamicSocket', 'Connection') + self.add_input('LnxStringSocket', 'API') + self.add_input('LnxDynamicSocket', 'Data') + self.add_input('LnxStringSocket', 'ID') + self.add_input('LnxBoolSocket', 'Send All') + + self.add_output('LnxNodeSocketAction', 'Out') + + + + def draw_buttons(self, context, layout): + layout.prop(self, 'property0') + layout.prop(self, 'property1') + +def register(): + add_category('Leenkx', icon='ORIENTATION_CURSOR') LeenkxSendMessageNode.on_register() \ No newline at end of file