コード例 #1
0
 def print_type(self, ast):
     self.indent()
     if len(ast.keys[0]) == 1:
         self.write('type "%s"' % string_escape(''.join(ast.keys)))
     else:
         self.write('type %s' % ast.keys[0])
     if ast.pattern is not None:
         self.write(' pattern "%s"' % string_escape(ast.pattern))
     if hasattr(ast, 'position') and ast.position is not None:
         self.write(' pos %s' % ast.position)
コード例 #2
0
 def print_type(self, ast):
     self.indent()
     if len(ast.keys[0]) == 1:
         self.write('type "%s"' % string_escape("".join(ast.keys)))
     else:
         self.write("type %s" % ast.keys[0])
     if ast.pattern is not None:
         self.write(' pattern "%s"' % string_escape(ast.pattern))
     if hasattr(ast, "position") and ast.position is not None:
         self.write(" pos %s" % ast.position)
コード例 #3
0
ファイル: __init__.py プロジェクト: galaxysd/unrpyc
    def print_menu(self, ast):
        self.indent()
        self.write("menu")
        if self.label_inside_menu is not None:
            self.write(" %s" % self.label_inside_menu.name)
            self.label_inside_menu = None
        self.write(":")
        with self.increase_indent():
            if self.say_inside_menu is not None:
                self.print_say(self.say_inside_menu, inmenu=True)
                self.say_inside_menu = None

            if ast.with_ is not None:
                self.indent()
                self.write("with %s" % ast.with_)

            if ast.set is not None:
                self.indent()
                self.write("set %s" % ast.set)

            for label, condition, block in ast.items:
                if self.translator:
                    label = self.translator.strings.get(label, label)

                if isinstance(condition, unicode):
                    self.advance_to_line(condition.linenumber)
                self.indent()
                self.write('"%s"' % string_escape(label))

                if block is not None:
                    if isinstance(condition, unicode):
                        self.write(" if %s" % condition)
                    self.write(":")
                    self.print_nodes(block, 1)
コード例 #4
0
ファイル: __init__.py プロジェクト: daytwentynine/unrpyc
 def print_say(self, ast):
     self.indent()
     if ast.who is not None:
         self.write("%s " % ast.who)
     self.write('"%s"' % string_escape(ast.what))
     if ast.with_ is not None:
         self.write(" with %s" % ast.with_)
コード例 #5
0
ファイル: __init__.py プロジェクト: daytwentynine/unrpyc
    def print_menu(self, ast):
        self.indent()
        self.write("menu:")
        self.indent_level += 1

        if ast.with_ is not None:
            self.indent()
            self.write("with %s" % ast.with_)

        if ast.set is not None:
            self.indent()
            self.write("set %s" % ast.set)

        for label, condition, block in ast.items:
            self.indent()
            self.write('"%s"' % string_escape(label))

            if block is not None:
                if condition != 'True':
                    self.write(" if %s" % condition)

                self.write(":")

                self.print_nodes(block, 1)

        self.indent_level -= 1
コード例 #6
0
ファイル: __init__.py プロジェクト: AndrewSkat/unrpyc
    def print_menu(self, ast):
        self.indent()
        self.write("menu")
        if self.label_inside_menu is not None:
            self.write(" %s" % self.label_inside_menu.name)
            self.label_inside_menu = None
        self.write(":")
        with self.increase_indent():
            if self.say_inside_menu is not None:
                self.print_say(self.say_inside_menu, inmenu=True)
                self.say_inside_menu = None

            if ast.with_ is not None:
                self.indent()
                self.write("with %s" % ast.with_)

            if ast.set is not None:
                self.indent()
                self.write("set %s" % ast.set)

            for label, condition, block in ast.items:
                if self.translator:
                    label = self.translator.strings.get(label, label)

                if isinstance(condition, unicode):
                    self.advance_to_line(condition.linenumber)
                self.indent()
                self.write('"%s"' % string_escape(label))

                if block is not None:
                    if isinstance(condition, unicode):
                        self.write(" if %s" % condition)
                    self.write(":")
                    self.print_nodes(block, 1)
コード例 #7
0
ファイル: __init__.py プロジェクト: AndrewSkat/unrpyc
    def print_translatestring(self, ast):
        self.require_init()
        # Was the last node a translatestrings node?
        if not(self.index and
               isinstance(self.block[self.index - 1], renpy.ast.TranslateString) and
               self.block[self.index - 1].language == ast.language):
            self.indent()
            self.write("translate %s strings:" % ast.language or "None")

        # TranslateString's linenumber refers to the line with "old", not to the
        # line with "translate %s strings:"
        self.advance_to_line(ast.linenumber)
        with self.increase_indent():
            self.indent()
            self.write('old "%s"' % string_escape(ast.old))
            self.indent()
            self.write('new "%s"' % string_escape(ast.new))
コード例 #8
0
ファイル: __init__.py プロジェクト: galaxysd/unrpyc
    def print_translatestring(self, ast):
        self.require_init()
        # Was the last node a translatestrings node?
        if not (self.index and isinstance(self.block[self.index - 1],
                                          renpy.ast.TranslateString)
                and self.block[self.index - 1].language == ast.language):
            self.indent()
            self.write("translate %s strings:" % ast.language or "None")

        # TranslateString's linenumber refers to the line with "old", not to the
        # line with "translate %s strings:"
        self.advance_to_line(ast.linenumber)
        with self.increase_indent():
            self.indent()
            self.write('old "%s"' % string_escape(ast.old))
            self.indent()
            self.write('new "%s"' % string_escape(ast.new))
コード例 #9
0
 def print_drag(self, ast):
     self.indent()
     self.write('drag %s' % ast.points)
     if ast.button != 1:
         self.write(' button %d' % ast.button)
     if ast.pattern is not None:
         self.write(' pattern "%s"' % string_escape(ast.pattern))
     if ast.steps != 10:
         self.write(' steps %d' % ast.steps)
コード例 #10
0
 def print_drag(self, ast):
     self.indent()
     self.write("drag %s" % ast.points)
     if ast.button != 1:
         self.write(" button %d" % ast.button)
     if ast.pattern is not None:
         self.write(' pattern "%s"' % string_escape(ast.pattern))
     if ast.steps != 10:
         self.write(" steps %d" % ast.steps)
コード例 #11
0
 def print_click(self, ast):
     self.indent()
     if ast.pattern is not None:
         self.write('"%s"' % string_escape(ast.pattern))
     else:
         self.write('click')
     if hasattr(ast, 'button') and ast.button != 1:
         self.write(' button %d' % ast.button)
     if hasattr(ast, 'position') and ast.position is not None:
         self.write(' pos %s' % ast.position)
     if hasattr(ast, 'always') and ast.always:
         self.write(' always')
コード例 #12
0
 def print_click(self, ast):
     self.indent()
     if ast.pattern is not None:
         self.write('"%s"' % string_escape(ast.pattern))
     else:
         self.write("click")
     if hasattr(ast, "button") and ast.button != 1:
         self.write(" button %d" % ast.button)
     if hasattr(ast, "position") and ast.position is not None:
         self.write(" pos %s" % ast.position)
     if hasattr(ast, "always") and ast.always:
         self.write(" always")
コード例 #13
0
ファイル: __init__.py プロジェクト: Gouvernathor/unrpyc
    def print_menu_item(self, label, condition, block, arguments):
        self.indent()
        self.write('"%s"' % string_escape(label))

        if arguments is not None:
            self.write(reconstruct_arginfo(arguments))

        if block is not None:
            if isinstance(condition, unicode):
                self.write(" if %s" % condition)
            self.write(":")
            self.print_nodes(block, 1)
コード例 #14
0
ファイル: __init__.py プロジェクト: megeek/unrpyc
    def print_menu(self, ast):
        self.indent()
        self.write("menu")
        if self.label_inside_menu is not None:
            self.write(" %s" % self.label_inside_menu.name)
            self.label_inside_menu = None

        if hasattr(ast, "arguments") and ast.arguments is not None:
            self.write(reconstruct_arginfo(ast.arguments))

        self.write(":")

        with self.increase_indent():
            if self.say_inside_menu is not None:
                self.print_say(self.say_inside_menu, inmenu=True)
                self.say_inside_menu = None

            if ast.with_ is not None:
                self.indent()
                self.write("with %s" % ast.with_)

            if ast.set is not None:
                self.indent()
                self.write("set %s" % ast.set)

            if hasattr(ast, "item_arguments"):
                item_arguments = ast.item_arguments
            else:
                item_arguments = [None] * len(ast.items)

            for (label, condition,
                 block), arguments in zip(ast.items, item_arguments):
                if self.translator:
                    label = self.translator.strings.get(label, label)

                if isinstance(condition, unicode):
                    self.advance_to_line(condition.linenumber)
                self.indent()
                self.write('"%s"' % string_escape(label))

                if arguments is not None:
                    self.write(reconstruct_arginfo(arguments))

                if block is not None:
                    if isinstance(condition, unicode):
                        self.write(" if %s" % condition)
                    self.write(":")
                    self.print_nodes(block, 1)
コード例 #15
0
ファイル: __init__.py プロジェクト: KasaiDot/unrpyc
 def print_say(self, ast, inmenu=False):
     if (not inmenu and self.index + 1 < len(self.block) and
         self.say_belongs_to_menu(ast, self.block[self.index + 1])):
         self.say_inside_menu = ast
         return
     self.indent()
     if ast.who is not None:
         self.write("%s " % ast.who)
     if hasattr(ast, 'attributes') and ast.attributes is not None:
         for i in ast.attributes:
             self.write("%s " % i)
     self.write('"%s"' % string_escape(ast.what))
     if not ast.interact and not inmenu:
         self.write(" nointeract")
     if ast.with_ is not None:
         self.write(" with %s" % ast.with_)
コード例 #16
0
ファイル: __init__.py プロジェクト: titan5555/unrpyc
 def print_say(self, ast, inmenu=False):
     if (not inmenu and self.index + 1 < len(self.block)
             and self.say_belongs_to_menu(ast, self.block[self.index + 1])):
         self.say_inside_menu = ast
         return
     self.indent()
     if ast.who is not None:
         self.write("%s " % ast.who)
     if hasattr(ast, 'attributes') and ast.attributes is not None:
         for i in ast.attributes:
             self.write("%s " % i)
     self.write('"%s"' % string_escape(ast.what))
     if not ast.interact and not inmenu:
         self.write(" nointeract")
     if ast.with_ is not None:
         self.write(" with %s" % ast.with_)
コード例 #17
0
 def print_move(self, ast):
     self.indent()
     self.write('move %s' % ast.position)
     if ast.pattern is not None:
         self.write(' pattern "%s"' % string_escape(ast.pattern))
コード例 #18
0
 def print_move(self, ast):
     self.indent()
     self.write("move %s" % ast.position)
     if ast.pattern is not None:
         self.write(' pattern "%s"' % string_escape(ast.pattern))