Update leenkx/blender/lnx/logicnode/custom/LN_leenkx_send_message.py

This commit is contained in:
Onek8 2025-04-03 09:41:20 +00:00
parent fa65c02e8a
commit 78109cfee2

View File

@ -1,116 +1,117 @@
from lnx.logicnode.lnx_nodes import * from lnx.logicnode.lnx_nodes import *
class LeenkxSendMessageNode(LnxLogicTreeNode): class LeenkxSendMessageNode(LnxLogicTreeNode):
"""Leenkx Send Message""" """Leenkx Send Message"""
bl_idname = 'LNLeenkxSendMessageNode' bl_idname = 'LNLeenkxSendMessageNode'
bl_label = 'Leenkx Send Message' bl_label = 'Leenkx Send Message'
bl_description = 'Send messages to the Leenkx network' bl_description = 'Send messages to the Leenkx network'
lnx_category = 'Leenkx' lnx_category = 'Leenkx'
lnx_version = 1 lnx_version = 1
@staticmethod @staticmethod
def get_enum_id_value(obj, prop_name, value): def get_enum_id_value(obj, prop_name, value):
return obj.bl_rna.properties[prop_name].enum_items[value].identifier return obj.bl_rna.properties[prop_name].enum_items[value].identifier
@staticmethod @staticmethod
def get_count_in(type_name): def get_count_in(type_name):
return { return {
'client': 0, 'client': 0,
'host': 1, 'host': 1,
'securehost': 2 'securehost': 2
}.get(type_name, 0) }.get(type_name, 0)
def get_enum(self): def get_enum(self):
return self.get('property0', 0) return self.get('property0', 0)
def set_enum(self, value): def set_enum(self, value):
# Checking the selection of each type # Checking the selection of each type
select_current = self.get_enum_id_value(self, 'property0', value) select_current = self.get_enum_id_value(self, 'property0', value)
select_prev = self.property0 select_prev = self.property0
#Check if type changed #Check if type changed
if select_prev != select_current: if select_prev != select_current:
for i in self.inputs: for i in self.inputs:
self.inputs.remove(i) self.inputs.remove(i)
# Arguements for type Client # Arguements for type Client
if (self.get_count_in(select_current) == 0): if (self.get_count_in(select_current) == 0):
self.add_input('LnxNodeSocketAction', 'In') self.add_input('LnxNodeSocketAction', 'In')
self.add_input('LnxDynamicSocket', 'Connection') self.add_input('LnxDynamicSocket', 'Connection')
self.add_input('LnxStringSocket', 'API') self.add_input('LnxStringSocket', 'API')
self.add_input('LnxDynamicSocket', 'Data') self.add_input('LnxDynamicSocket', 'Data')
self.add_input('LnxStringSocket', 'ID') self.add_input('LnxStringSocket', 'ID')
self.add_input('LnxBoolSocket', 'Send All') self.add_input('LnxBoolSocket', 'Send All')
# Arguements for type Host # Arguements for type Host
if (self.get_count_in(select_current) == 1): if (self.get_count_in(select_current) == 1):
self.add_input('LnxNodeSocketAction', 'In') self.add_input('LnxNodeSocketAction', 'In')
self.add_input('LnxDynamicSocket', 'Connection') self.add_input('LnxDynamicSocket', 'Connection')
self.add_input('LnxStringSocket', 'API') self.add_input('LnxStringSocket', 'API')
self.add_input('LnxDynamicSocket', 'Data') self.add_input('LnxDynamicSocket', 'Data')
self.add_input('LnxStringSocket', 'ID') self.add_input('LnxStringSocket', 'ID')
self.add_input('LnxBoolSocket', 'Send All') self.add_input('LnxBoolSocket', 'Send All')
# Arguements for type Secure Host # Arguements for type Secure Host
if (self.get_count_in(select_current) == 2): if (self.get_count_in(select_current) == 2):
self.add_input('LnxNodeSocketAction', 'In') self.add_input('LnxNodeSocketAction', 'In')
self.add_input('LnxDynamicSocket', 'Connection') self.add_input('LnxDynamicSocket', 'Connection')
self.add_input('LnxStringSocket', 'API') self.add_input('LnxStringSocket', 'API')
self.add_input('LnxDynamicSocket', 'Data') self.add_input('LnxDynamicSocket', 'Data')
self.add_input('LnxStringSocket', 'ID') self.add_input('LnxStringSocket', 'ID')
self.add_input('LnxBoolSocket', 'Send All') self.add_input('LnxBoolSocket', 'Send All')
self['property0'] = value self['property0'] = value
property0: HaxeEnumProperty( property0: HaxeEnumProperty(
'property0', 'property0',
items = [('client', 'Client', 'Network client Event listener'), items = [('client', 'Client', 'Network client Event listener'),
('host', 'Host', 'Network host Event listener'), ('host', 'Host', 'Network host Event listener'),
('securehost', 'Secure Host', 'Network secure host Event listener')], ('securehost', 'Secure Host', 'Network secure host Event listener')],
name='', name='',
default='client', default='client',
set=set_enum, set=set_enum,
get=get_enum) get=get_enum)
property1: HaxeEnumProperty( property1: HaxeEnumProperty(
'property1', 'property1',
items = [('string', 'String', 'Send a string over the network to one or all of the clients'), 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'), ('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'), ('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'), ('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'), ('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'), ('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')], ('rotation', 'Rotation', 'Send a rotation over the network to one or all of the clients')],
name='', name='',
default='string') default='string')
def __init__(self): def __init__(self, *args, **kwargs):
array_nodes[str(id(self))] = self super(LeenkxSendMessageNode, self).__init__(*args, **kwargs)
array_nodes[str(id(self))] = self
def lnx_init(self, context):
self.add_input('LnxNodeSocketAction', 'In') def lnx_init(self, context):
self.add_input('LnxDynamicSocket', 'Connection') self.add_input('LnxNodeSocketAction', 'In')
self.add_input('LnxStringSocket', 'API') self.add_input('LnxDynamicSocket', 'Connection')
self.add_input('LnxDynamicSocket', 'Data') self.add_input('LnxStringSocket', 'API')
self.add_input('LnxStringSocket', 'ID') self.add_input('LnxDynamicSocket', 'Data')
self.add_input('LnxBoolSocket', 'Send All') self.add_input('LnxStringSocket', 'ID')
self.add_input('LnxBoolSocket', 'Send All')
self.add_output('LnxNodeSocketAction', 'Out')
self.add_output('LnxNodeSocketAction', 'Out')
def draw_buttons(self, context, layout):
layout.prop(self, 'property0') def draw_buttons(self, context, layout):
layout.prop(self, 'property1') layout.prop(self, 'property0')
layout.prop(self, 'property1')
def register():
add_category('Leenkx', icon='ORIENTATION_CURSOR') def register():
add_category('Leenkx', icon='ORIENTATION_CURSOR')
LeenkxSendMessageNode.on_register() LeenkxSendMessageNode.on_register()