Beispiel #1
0
def menu_to_str(renpy, node, res):
    nexts = []
    menu_items = []
    display_texts = []
    for item in node.items:
        (text, cond, lnext) = item
        if lnext:
            next = real_next(renpy, lnext[0])

            res['nodes'][id(item)] = {
                'class_name':
                'MenuItem',
                'arguments':
                [text,
                 replace_bools(cond), [str(id(next))] if next else []]
            }
            nexts.append(next)
            menu_items.append(item)
        else:
            display_texts.append(text)

    id_menu_items = [str(id(menu_item)) for menu_item in menu_items]
    res['nodes'][id(node)] = {
        'class_name': 'Menu',
        'arguments': ['\n'.join(display_texts), id_menu_items]
    }
    return nexts
Beispiel #2
0
def if_to_str(renpy, node, res):
    else_found = False
    for if_block in node.entries:
        if if_block[0] == 'True':
            else_found = True
    if not else_found:
        node.entries.append(('true', [node.next]))

    nexts_of_blocks = []
    nexts_of_if = []
    for if_block in node.entries:
        (cond, block) = if_block
        id_if_block = id(if_block)

        next_of_block = real_next(renpy, block[0])

        res['nodes'][id_if_block] = {
            'class_name':
            'IfBlock',
            'arguments': [
                replace_bools(cond),
                [str(id(next_of_block))] if next_of_block else []
            ]
        }

        nexts_of_blocks.append(next_of_block)
        nexts_of_if.append(str(id_if_block))

    res['nodes'][id(node)] = {
        'class_name': 'If',
        'arguments': [nexts_of_if],
    }

    return nexts_of_blocks
Beispiel #3
0
def python_to_str(GAME_BASE_DIR, renpy, node, res):
    next = real_next(renpy, node.next)
    id_nexts = [str(id(next))] if next else []

    match = re.search(VIDEO, node.code.source)

    if match != None and len(match.groups()) == 1:  # it's a video
        file = match.group(1)[1:-1]
        vid_name = remove_invalid_chars(file)
        load_media(GAME_BASE_DIR, res, 'videos', vid_name, file)
        res['nodes'][id(node)] = {
            'class_name': 'Video',
            'arguments': [vid_name, [str(id(next))] if next else []]
        }
    else:
        match = re.search(PLAY, node.code.source)

        if match != None and len(match.groups()) == 1:  # it's a sound play
            args = [arg.strip() for arg in match.group(1).split(',')]
            loop = find_map(get_loop, args[1:])
            play_to_str(GAME_BASE_DIR, node, id_nexts, res, args[0][1:-1],
                        'sound', loop)

        else:
            res['nodes'][id(node)] = {
                'class_name': 'PyExpr',
                'arguments': [replace_bools(node.code.source), id_nexts]
            }

    return [next]
def python_to_str(renpy_nodes, renpy_ast, node, acc):
    next = real_next(renpy_nodes, renpy_ast, node.next)

    match = re.search(VIDEO, node.code.source)

    if match != None and len(match.groups()) == 1: # it's a video
        file = match.group(1)[1:-1]
        vid_name = remove_invalid_chars(file)
        acc['videos'][vid_name] = file
        acc['nodes'][id(node)] = {
            'class_name': 'Video',
            'arguments': [
                vid_name,
                [str(id(next))] if next else []
            ]
        }
    else:
        acc['nodes'][id(node)] = {
            'class_name': 'PyExpr',
            'arguments': [
                replace_bools(node.code.source),
                [str(id(next))] if next else []
            ]
        }
    return [next]