2018-08-12 08:42:39 +02:00
|
|
|
from arm.logicnode.arm_nodes import *
|
|
|
|
|
2020-09-08 21:16:20 +02:00
|
|
|
class SwitchNode(ArmLogicTreeNode):
|
2020-09-23 22:12:25 +02:00
|
|
|
"""Runs the outputs depending of the value. Example: If 'value' is equal to 'case 1', the output 'case 1' will run."""
|
2018-08-12 08:42:39 +02:00
|
|
|
bl_idname = 'LNSwitchNode'
|
|
|
|
bl_label = 'Switch'
|
2020-09-13 11:27:58 +02:00
|
|
|
arm_version = 1
|
2020-08-30 11:45:07 +02:00
|
|
|
min_inputs = 2
|
2018-08-12 08:42:39 +02:00
|
|
|
min_outputs = 1
|
2020-09-08 21:16:20 +02:00
|
|
|
|
2018-08-12 08:42:39 +02:00
|
|
|
def __init__(self):
|
|
|
|
array_nodes[str(id(self))] = self
|
|
|
|
|
|
|
|
def init(self, context):
|
2020-09-13 11:27:58 +02:00
|
|
|
super(SwitchNode, self).init(context)
|
2020-09-08 21:49:02 +02:00
|
|
|
self.add_input('ArmNodeSocketAction', 'In')
|
|
|
|
self.add_input('NodeSocketShader', 'Value')
|
|
|
|
self.add_output('ArmNodeSocketAction', 'Default')
|
2018-08-12 08:42:39 +02:00
|
|
|
|
|
|
|
def draw_buttons(self, context, layout):
|
|
|
|
row = layout.row(align=True)
|
|
|
|
op = row.operator('arm.node_add_input_output', text='New', icon='PLUS', emboss=True)
|
|
|
|
op.node_index = str(id(self))
|
|
|
|
op.in_socket_type = 'NodeSocketShader'
|
|
|
|
op.out_socket_type = 'ArmNodeSocketAction'
|
|
|
|
op.in_name_format = 'Case {0}'
|
|
|
|
op.out_name_format = 'Case {0}'
|
|
|
|
op.in_index_name_offset = -1
|
|
|
|
op2 = row.operator('arm.node_remove_input_output', text='', icon='X', emboss=True)
|
|
|
|
op2.node_index = str(id(self))
|
|
|
|
|
2020-09-09 20:48:35 +02:00
|
|
|
add_node(SwitchNode, category=PKG_AS_CATEGORY)
|