コード例 #1
0
ファイル: __init__.py プロジェクト: AndrewSkat/unrpyc
    def print_label(self, ast):
        # If a Call block preceded us, it printed us as "from"
        if (self.index and isinstance(self.block[self.index - 1], renpy.ast.Call)):
            return
        remaining_blocks = len(self.block) - self.index
        # See if we're the label for a menu, rather than a standalone label.
        if remaining_blocks > 1 and not ast.block and ast.parameters is None:
            next_ast = self.block[self.index + 1]
            if (hasattr(next_ast, 'linenumber') and next_ast.linenumber == ast.linenumber and
                (isinstance(next_ast, renpy.ast.Menu) or (remaining_blocks > 2 and
                isinstance(next_ast, renpy.ast.Say) and
                self.say_belongs_to_menu(next_ast, self.block[self.index + 2])))):
                self.label_inside_menu = ast
                return
        self.indent()

        # It's possible that we're an "init label", not a regular label. There's no way to know
        # if we are until we parse our children, so temporarily redirect all of our output until
        # that's done, so that we can squeeze in an "init " if we are.
        out_file = self.out_file
        self.out_file = StringIO()
        missing_init = self.missing_init
        self.missing_init = False
        try:
            self.write("label %s%s%s:" % (
                ast.name,
                reconstruct_paraminfo(ast.parameters),
                " hide" if hasattr(ast, 'hide') and ast.hide else ""))
            self.print_nodes(ast.block, 1)
        finally:
            if self.missing_init:
                out_file.write("init ")
            self.missing_init = missing_init
            out_file.write(self.out_file.getvalue())
            self.out_file = out_file
コード例 #2
0
    def print_label(self, ast):
        # If a Call block preceded us, it printed us as "from"
        if (self.index and isinstance(self.block[self.index - 1], renpy.ast.Call)):
            return
        remaining_blocks = len(self.block) - self.index
        # See if we're the label for a menu, rather than a standalone label.
        if remaining_blocks > 1 and not ast.block and (not hasattr(ast, 'parameters') or ast.parameters is None):
            next_ast = self.block[self.index + 1]
            if (hasattr(next_ast, 'linenumber') and next_ast.linenumber == ast.linenumber and
                (isinstance(next_ast, renpy.ast.Menu) or (remaining_blocks > 2 and
                isinstance(next_ast, renpy.ast.Say) and
                self.say_belongs_to_menu(next_ast, self.block[self.index + 2])))):
                self.label_inside_menu = ast
                return
        self.indent()

        # It's possible that we're an "init label", not a regular label. There's no way to know
        # if we are until we parse our children, so temporarily redirect all of our output until
        # that's done, so that we can squeeze in an "init " if we are.
        out_file = self.out_file
        self.out_file = StringIO()
        missing_init = self.missing_init
        self.missing_init = False
        try:
            self.write("label %s%s%s:" % (
                ast.name,
                reconstruct_paraminfo(ast.parameters) if hasattr(ast, 'parameters') else '',
                " hide" if hasattr(ast, 'hide') and ast.hide else ""))
            self.print_nodes(ast.block, 1)
        finally:
            if self.missing_init:
                out_file.write("init ")
            self.missing_init = missing_init
            out_file.write(self.out_file.getvalue())
            self.out_file = out_file
コード例 #3
0
ファイル: __init__.py プロジェクト: RazoRTR/unrpyc
    def print_transform(self, ast):
        self.indent()
        self.write("transform %s" % ast.varname)
        if ast.parameters is not None:
            self.write(reconstruct_paraminfo(ast.parameters))

        if hasattr(ast, "atl") and ast.atl is not None:
            self.write(":")
            self.print_atl(ast.atl)
コード例 #4
0
ファイル: __init__.py プロジェクト: titan5555/unrpyc
    def print_transform(self, ast):
        self.indent()
        self.write("transform %s" % ast.varname)
        if ast.parameters is not None:
            self.write(reconstruct_paraminfo(ast.parameters))

        if hasattr(ast, "atl") and ast.atl is not None:
            self.write(":")
            self.print_atl(ast.atl)
コード例 #5
0
ファイル: sl2decompiler.py プロジェクト: madeddy/unrpyc
    def print_screen(self, ast):

        # Print the screen statement and create the block
        self.indent()
        self.write("screen %s" % ast.name)
        # If we have parameters, print them.
        if ast.parameters:
            self.write(reconstruct_paraminfo(ast.parameters))

        # If we're decompiling screencode, print it. Else, insert a pass statement
        self.print_keywords_and_children(ast.keyword,
            ast.children, ast.location[1], tag=ast.tag, atl_transform=getattr(ast, 'atl_transform', None))
コード例 #6
0
ファイル: sl2decompiler.py プロジェクト: boing6000/unrpyc
    def print_screen(self, ast):

        # Print the screen statement and create the block
        self.indent()
        self.write("screen %s" % ast.name)
        # If we have parameters, print them.
        if ast.parameters:
            self.write(reconstruct_paraminfo(ast.parameters))
        # Print any keywords
        if ast.tag:
            self.write(" tag %s" % ast.tag)
        # If we're decompiling screencode, print it. Else, insert a pass statement
        self.print_keywords_and_children(ast.keyword,
            ast.children, ast.location[1])
コード例 #7
0
    def print_screen(self, ast):
        # Here we do the processing of the screen statement, and we
        # switch over to parsing of the python string representation

        # Print the screen statement and create the block
        self.indent()
        self.write("screen %s" % ast.name)
        # If we have parameters, print them.
        if hasattr(ast, "parameters") and ast.parameters:
            self.write(reconstruct_paraminfo(ast.parameters))
        self.write(":")
        self.indent_level += 1

        # Print any keywords
        if ast.tag:
            self.indent()
            self.write("tag %s" % ast.tag)
        if ast.zorder and ast.zorder != '0':
            self.indent()
            self.write("zorder %s" % ast.zorder)
        if ast.modal:
            self.indent()
            self.write("modal %s" % ast.modal)
        if ast.variant and ast.variant != "None":
            self.indent()
            self.write("variant %s" % ast.variant)

        if not self.decompile_python:
            self.indent()
            self.write("pass # Screen code not extracted")
            return

        code = codegen.to_source(ast.code.source, self.indentation)

        if self.decompile_screencode:
            lines = [line for line in code.splitlines() if line.strip() != "ui.close()"]
            self.print_nodes('\n'.join(lines))

        else:
            self.indent()
            self.write("python:")

            self.indent_level += 1
            for line in code.splitlines():
                self.indent()
                self.write(line)
            self.indent_level -= 1

        self.indent_level -= 1
コード例 #8
0
ファイル: __init__.py プロジェクト: LahmatTea/unrpyc
 def print_label(self, ast):
     # If a Call block preceded us, it printed us as "from"
     if (self.index and isinstance(self.block[self.index - 1], renpy.ast.Call)):
         return
     remaining_blocks = len(self.block) - self.index
     # See if we're the label for a menu, rather than a standalone label.
     if remaining_blocks > 1 and not ast.block and ast.parameters is None:
         next_ast = self.block[self.index + 1]
         if isinstance(next_ast, renpy.ast.Menu) or (remaining_blocks > 2 and
             isinstance(next_ast, renpy.ast.Say) and
             self.say_belongs_to_menu(next_ast, self.block[self.index + 2])):
             self.label_inside_menu = ast
             return
     self.indent()
     self.write("label %s%s:" % (ast.name, reconstruct_paraminfo(ast.parameters)))
     self.print_nodes(ast.block, 1)
コード例 #9
0
ファイル: __init__.py プロジェクト: Gouvernathor/unrpyc
    def print_transform(self, ast):
        self.require_init()
        self.indent()

        # If we have an implicit init block with a non-default priority, we need to store the priority here.
        priority = ""
        if isinstance(self.parent, renpy.ast.Init):
            init = self.parent
            if init.priority != self.init_offset and len(init.block) == 1 and not self.should_come_before(init, ast):
                priority = " %d" % (init.priority - self.init_offset)
        self.write("transform%s %s" % (priority, ast.varname))
        if ast.parameters is not None:
            self.write(reconstruct_paraminfo(ast.parameters))

        if hasattr(ast, "atl") and ast.atl is not None:
            self.write(":")
            self.print_atl(ast.atl)
コード例 #10
0
ファイル: __init__.py プロジェクト: AndrewSkat/unrpyc
    def print_transform(self, ast):
        self.require_init()
        self.indent()

        # If we have an implicit init block with a non-default priority, we need to store the priority here.
        priority = ""
        if isinstance(self.parent, renpy.ast.Init):
            init = self.parent
            if init.priority != 0 and len(init.block) == 1 and not self.should_come_before(init, ast):
                priority = " %d" % init.priority
        self.write("transform%s %s" % (priority, ast.varname))
        if ast.parameters is not None:
            self.write(reconstruct_paraminfo(ast.parameters))

        if hasattr(ast, "atl") and ast.atl is not None:
            self.write(":")
            self.print_atl(ast.atl)
コード例 #11
0
ファイル: screendecompiler.py プロジェクト: LahmatTea/unrpyc
    def print_screen(self, ast):
        # Here we do the processing of the screen statement, and we
        # switch over to parsing of the python string representation

        # Print the screen statement and create the block
        self.indent()
        self.write("screen %s" % ast.name)
        # If we have parameters, print them.
        if hasattr(ast, "parameters") and ast.parameters:
            self.write(reconstruct_paraminfo(ast.parameters))

        if ast.tag:
            self.write(" tag %s" % ast.tag)

        keywords = {ast.code.location[1]: WordConcatenator(False)}
        for key in ('modal', 'zorder', 'variant', 'predict'):
            value = getattr(ast, key)
            # Non-Unicode strings are default values rather than user-supplied
            # values, so we don't need to write them out.
            if isinstance(value, unicode):
                if value.linenumber not in keywords:
                    keywords[value.linenumber] = WordConcatenator(False)
                keywords[value.linenumber].append(key)
                keywords[value.linenumber].append(value)
        keywords = sorted([(k, v.join()) for k, v in keywords.items()],
                          key=itemgetter(0))  # so the first one is right
        if self.decompile_python:
            self.print_keywords_and_nodes(keywords, None, True)
            self.indent_level += 1
            self.indent()
            self.write("python:")
            self.indent_level += 1
            # The first line is always "_1 = (_name, 0)", which gets included
            # even if the python: block is the only thing in the screen. Don't
            # include ours, since if we do, it'll be included twice when
            # recompiled.
            for line in self.to_source(ast.code.source).splitlines()[1:]:
                self.indent()
                self.write(line)
            self.indent_level -= 2
        else:
            self.print_keywords_and_nodes(keywords, ast.code.source.body,
                                          False)
コード例 #12
0
ファイル: screendecompiler.py プロジェクト: LahmatTea/unrpyc
    def print_screen(self, ast):
        # Here we do the processing of the screen statement, and we
        # switch over to parsing of the python string representation

        # Print the screen statement and create the block
        self.indent()
        self.write("screen %s" % ast.name)
        # If we have parameters, print them.
        if hasattr(ast, "parameters") and ast.parameters:
            self.write(reconstruct_paraminfo(ast.parameters))

        if ast.tag:
            self.write(" tag %s" % ast.tag)

        keywords = {ast.code.location[1]: WordConcatenator(False)}
        for key in ('modal', 'zorder', 'variant', 'predict'):
            value = getattr(ast, key)
            # Non-Unicode strings are default values rather than user-supplied
            # values, so we don't need to write them out.
            if isinstance(value, unicode):
                if value.linenumber not in keywords:
                    keywords[value.linenumber] = WordConcatenator(False)
                keywords[value.linenumber].append(key)
                keywords[value.linenumber].append(value)
        keywords = sorted([(k, v.join()) for k, v in keywords.items()],
                          key=itemgetter(0)) # so the first one is right
        if self.decompile_python:
            self.print_keywords_and_nodes(keywords, None, True)
            self.indent_level += 1
            self.indent()
            self.write("python:")
            self.indent_level += 1
            # The first line is always "_1 = (_name, 0)", which gets included
            # even if the python: block is the only thing in the screen. Don't
            # include ours, since if we do, it'll be included twice when
            # recompiled.
            for line in self.to_source(ast.code.source).splitlines()[1:]:
                self.indent()
                self.write(line)
            self.indent_level -= 2
        else:
            self.print_keywords_and_nodes(keywords, ast.code.source.body, False)
コード例 #13
0
ファイル: __init__.py プロジェクト: LahmatTea/unrpyc
 def print_label(self, ast):
     # If a Call block preceded us, it printed us as "from"
     if (self.index
             and isinstance(self.block[self.index - 1], renpy.ast.Call)):
         return
     remaining_blocks = len(self.block) - self.index
     # See if we're the label for a menu, rather than a standalone label.
     if remaining_blocks > 1 and not ast.block and ast.parameters is None:
         next_ast = self.block[self.index + 1]
         if isinstance(
                 next_ast,
                 renpy.ast.Menu) or (remaining_blocks > 2 and isinstance(
                     next_ast, renpy.ast.Say) and self.say_belongs_to_menu(
                         next_ast, self.block[self.index + 2])):
             self.label_inside_menu = ast
             return
     self.indent()
     self.write("label %s%s:" %
                (ast.name, reconstruct_paraminfo(ast.parameters)))
     self.print_nodes(ast.block, 1)
コード例 #14
0
ファイル: sl2decompiler.py プロジェクト: daytwentynine/unrpyc
    def print_screen(self, ast):

        # Print the screen statement and create the block
        self.indent()
        self.write("screen %s" % ast.name)
        # If we have parameters, print them.
        if ast.parameters:
            self.write(reconstruct_paraminfo(ast.parameters))
        self.write(":")
        self.indent_level += 1

        # Print any keywords
        if ast.tag:
            self.indent()
            self.write("tag %s" % ast.tag)
        if ast.zorder and ast.zorder != '0':
            self.indent()
            self.write("zorder %s" % ast.zorder)
        if ast.modal:
            self.indent()
            self.write("modal %s" % ast.modal)
        if ast.variant and ast.variant != "None":
            self.indent()
            self.write("variant %s" % ast.variant)
        if ast.predict and ast.predict != "None":
            self.indent()
            self.write("predict %s" % ast.predict)

        # If we're decompiling screencode, print it. Else, insert a pass statement
        if self.decompile_screencode:
            self.print_nodes(ast.children)
        else:
            self.indent()
            self.write("pass # Screen code not decompiled")

        self.indent_level -= 1
コード例 #15
0
ファイル: __init__.py プロジェクト: daytwentynine/unrpyc
 def print_label(self, ast):
     self.indent()
     self.write("label %s%s:" % (ast.name, reconstruct_paraminfo(ast.parameters)))
     self.print_nodes(ast.block, 1)