-
Notifications
You must be signed in to change notification settings - Fork 315
/
LN_array_boolean.py
50 lines (39 loc) · 1.82 KB
/
LN_array_boolean.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
from arm.logicnode.arm_nodes import *
class BooleanArrayNode(ArmLogicVariableNodeMixin, ArmLogicTreeNode):
"""Stores an array of boolean elements as a variable."""
bl_idname = 'LNArrayBooleanNode'
bl_label = 'Array Boolean'
arm_version = 3
arm_section = 'variable'
min_inputs = 0
def __init__(self):
super(BooleanArrayNode, self).__init__()
self.register_id()
def arm_init(self, context):
self.add_output('ArmNodeSocketArray', 'Array', is_var=True)
self.add_output('ArmIntSocket', 'Length')
def draw_content(self, context, layout):
row = layout.row(align=True)
op = row.operator('arm.node_add_input', text='New', icon='PLUS', emboss=True)
op.node_index = self.get_id_str()
op.socket_type = 'ArmBoolSocket'
column = row.column(align=True)
op = column.operator('arm.node_remove_input', text='', icon='X', emboss=True)
op.node_index = self.get_id_str()
if len(self.inputs) == self.min_inputs:
column.enabled = False
def draw_label(self) -> str:
if len(self.inputs) == self.min_inputs:
return super().draw_label()
return f'{super().draw_label()} [{len(self.inputs)}]'
def synchronize_from_master(self, master_node: ArmLogicVariableNodeMixin):
self.inputs.clear()
for i in range(len(master_node.inputs)):
inp = self.add_input('ArmBoolSocket', master_node.inputs[i].name)
inp.hide = self.arm_logic_id != ''
inp.enabled = self.arm_logic_id == ''
inp.default_value_raw = master_node.inputs[i].get_default_value()
def get_replacement_node(self, node_tree: bpy.types.NodeTree):
if self.arm_version not in (0, 2):
raise LookupError()
return NodeReplacement.Identity(self)