from lnx.logicnode.lnx_nodes import *

class ArrayDisplayNode(LnxLogicTreeNode):
    """Returns the display of the given array."""
    bl_idname = 'LNArrayDisplayNode'
    bl_label = 'Array Display'
    lnx_version = 1
    
    def remove_extra_inputs(self, context):
        while len(self.inputs) > 2:
            self.inputs.remove(self.inputs[-1])
        if self.property0 == 'Item Field':
            self.add_input('LnxStringSocket', 'Item Field')
        if self.property0 == 'Item Property':
            self.add_input('LnxStringSocket', 'Item Property')
    
    property0: HaxeEnumProperty(
    'property0',
    items = [('Item', 'Item', 'Array Item'),
             ('Item Field', 'Item Field', 'Object Item Field, ie: name, uid, visible, parent, length, etc.'),
             ('Item Property', 'Item Property', 'Object Item Property')],
    name='', default='Item', update=remove_extra_inputs)
    
    def lnx_init(self, context):
        self.add_input('LnxNodeSocketArray', 'Array')
        self.add_input('LnxStringSocket', 'Separator')

        self.add_output('LnxStringSocket', 'Items')

    def draw_buttons(self, context, layout):
        layout.prop(self, 'property0')