コード例 #1
0
def request_tree_code_writer_start(dummy):
    global _tree_code_writer_started
    _tree_code_writer_started = False
    generator = ops.tree_code_generator.TreeCodeGenerator()
    if getattr(bpy.context.scene.logic_node_settings, 'use_generate_on_open', False):
        utils.debug('Writing trees on file open...')
        bpy.ops.bge_netlogic.generate_logicnetwork_all()
        utils.debug('FINISHED')
コード例 #2
0
    def execute(self, context):
        utils.debug('Packing Group...')
        nodes_to_group = []
        tree = context.space_data.edit_tree

        if tree is None:
            utils.error('Could not pack group! Aborting...')
            return {'FINISHED'}
        for node in tree.nodes:
            if node.select:
                nodes_to_group.append(node)
        if len(nodes_to_group) > 0:
            name = bpy.context.scene.nl_group_name.name
            if self.group_make(name, nodes_to_group):
                bge_netlogic._update_all_logic_tree_code()
        return {'FINISHED'}
コード例 #3
0
    def execute(self, context):
        utils.debug('Adding template...')
        tree = context.space_data.edit_tree
        content = json.load(open(self.get_template_path()))['nodes']

        if tree is None:
            utils.error('Cannot add template! Aborting...')
            return {'FINISHED'}
        for node in tree.nodes:
            node.select = False

        nodes = []
        for c in content:
            self.add_node(
                c['x'],
                c['y'],
                c['label'],
                c['node_type'],
                nodes,
                values=c['values']
            )
        i = 0
        for c in content:
            self.link_node(nodes[i], c['links'], nodes)
            i += 1

        for node in nodes:
            node.select = True
            if node.label == 'Speed':
                continue
            node.hide = True
            for socket in node.inputs:
                if not socket.is_linked:
                    socket.hide = True
            for socket in node.outputs:
                if not socket.is_linked:
                    socket.hide = True

        bpy.ops.transform.translate()
        utils.success('Added 4 Key Template.')
        return {'FINISHED'}
コード例 #4
0
def unregister():
    utils.debug('Removing Game Start Compile handler...')
    filter(lambda a: a is not _generate_on_game_start,
           bpy.app.handlers.game_pre)
    # print("Unregister node category [{}]".format("NETLOGIC_NODES"))
    nodeitems_utils.unregister_node_categories("NETLOGIC_NODES")
    for cls in reversed(_registered_classes):
        # print("Unregister node class [{}]".format(cls.__name__))
        bpy.utils.unregister_class(cls)
    user_node_categories = set()
    for pair in _loaded_nodes:
        cat = pair[0]
        cls = pair[1]
        user_node_categories.add(cat)
        try:
            node_id = cls.__name__
            if hasattr(bpy.types, node_id):
                # print("Unregister user node [{}]".format(node_id))
                bpy.utils.unregister_class(getattr(bpy.types, node_id))
        except RuntimeError as ex:
            print("Custom node {} not unloaded [{}]".format(cls.__name__, ex))
    for pair in _loaded_sockets:
        cat = pair[0]
        cls = pair[1]
        user_node_categories.add(cat)
        try:
            node_id = cls.__name__
            if hasattr(bpy.types, node_id):
                # print("Unregister user socket [{}]".format(node_id))
                bpy.utils.unregister_class(getattr(bpy.types, node_id))
        except RuntimeError as ex:
            print("Custom socket {} not unloaded [{}]".format(
                cls.__name__, ex))
    for cat in user_node_categories:
        # print("Unregister user node category [{}]".format(cat))
        try:
            nodeitems_utils.unregister_node_categories(cat)
        except RuntimeError as ex:
            print("Custom category {} not unloaded [{}]".format(cat, ex))