Exemplo n.º 1
0
    def __build_lines(self, font):
        box_width = self.width - 2 * cfg.border_width
        self.lines = build_lines(self.text, box_width, font)

        box_width = self.width - 3 * cfg.border_width
        self.choice_lines = []
        for choice in self.choices:
            choice_line = build_lines(choice, box_width, font)
            self.choice_lines.extend(choice_line)
Exemplo n.º 2
0
    def __build_lines(self, font):
        box_width = self.width - 2 * cfg.border_width
        self.lines = build_lines(self.text,
                                 box_width,
                                 font)

        box_width = self.width - 3 * cfg.border_width
        self.choice_lines = []
        for choice in self.choices:
            choice_line = build_lines(choice,
                                      box_width,
                                      font)
            self.choice_lines.extend(choice_line)
Exemplo n.º 3
0
    def __init__(self, text, block_movement=True):
        self.text = text
        self.block_movement = block_movement

        # Split into lines
        theme = menu_config.theme
        font = theme.get_font(cfg.font_size)
        box_width = g_cfg.screen_width - 4 * cfg.border_width
        lines = build_lines(self.text, box_width, font)

        # Calculate box size
        self.box_height = (sum([line[1] for line in lines]) +
                           (len(lines) - 1) * cfg.line_spacing +
                           4 * cfg.border_width)
        assert self.box_height < g_cfg.screen_height,\
               'Too much text for one box.'

        Menu.__init__(self, g_cfg.screen_width - 2 * cfg.border_width,
                            self.box_height - 2 * cfg.border_width,
                            cfg.border_width,
                            g_cfg.screen_height - self.box_height\
                            + cfg.border_width,
                            bg=TRANSPARENT,
                            blocking=block_movement)

        panel = Panel(self.width, self.height)
        self.add_widget(panel, (0, 0))

        # Draw message
        y_acc = 0
        for line in lines:
            label = Label(line[2])
            panel.add_widget(label,
                             (cfg.border_width, cfg.border_width + y_acc))
            y_acc += line[0] + cfg.line_spacing
Exemplo n.º 4
0
    def __init__(self, text, block_movement=True):
        self.text = text
        self.block_movement = block_movement

        Menu.__init__(self,
                      g_cfg.screen_width - 2 * cfg.border_width,
                      g_cfg.screen_height / 2 - 2 * cfg.border_width,
                      cfg.border_width,
                      g_cfg.screen_height / 2 + cfg.border_width,
                      bg=TRANSPARENT,
                      blocking=block_movement)

        panel = Panel(self.width, self.height)
        self.add_widget(panel, (0, 0))

        font = self.theme.get_font(cfg.font_size)
        box_width = g_cfg.screen_width - 4 * cfg.border_width
        lines = build_lines(self.text, box_width, font)

        # Draw message
        y_acc = 0
        for line in lines:
            label = Label(line[2])
            panel.add_widget(label,
                             (cfg.border_width, cfg.border_width + y_acc))
            y_acc += line[1] + cfg.line_spacing
Exemplo n.º 5
0
    def __init__(self, text, block_movement=True):
        self.text = text
        self.block_movement = block_movement
        self.current_panel = None

        Menu.__init__(self,
                      g_cfg.screen_width - 2 * cfg.border_width,
                      g_cfg.screen_height / 2 - 2 * cfg.border_width,
                      cfg.border_width,
                      g_cfg.screen_height / 2 + cfg.border_width,
                      bg=TRANSPARENT,
                      blocking=block_movement)

        # Split into lines
        font = self.theme.get_font(cfg.font_size)
        box_width = g_cfg.screen_width - 4 * cfg.border_width
        lines = build_lines(self.text, box_width, font)

        # Split into boxes
        box_height = g_cfg.screen_height / 2 - 4 * cfg.border_width
        self.boxes = split_boxes(lines, box_height, cfg.line_spacing)
        self.panels = []

        # Draw panels
        for box in self.boxes:
            panel = Panel(self.width, self.height)
            y_acc = 0
            for line in box:
                label = Label(line[2])
                panel.add_widget(label,
                                 (cfg.border_width, cfg.border_width + y_acc))
                y_acc += line[1] + cfg.line_spacing
            self.panels.append(panel)

        self.advance_panel()
Exemplo n.º 6
0
    def __init__(self, text, block_movement=True):
        self.text = text
        self.block_movement = block_movement

        Menu.__init__(self, g_cfg.screen_width - 2 * cfg.border_width,
                            g_cfg.screen_height / 2 - 2 * cfg.border_width,
                            cfg.border_width,
                            g_cfg.screen_height / 2 + cfg.border_width,
                            bg=TRANSPARENT,
                            blocking=block_movement)

        panel = Panel(self.width, self.height)
        self.add_widget(panel, (0, 0))

        font = self.theme.get_font(cfg.font_size)
        box_width = g_cfg.screen_width - 4 * cfg.border_width
        lines = build_lines(self.text,
                            box_width,
                            font)

        # Draw message
        y_acc = 0
        for line in lines:
            label = Label(line[2])
            panel.add_widget(label,
                             (cfg.border_width,
                              cfg.border_width + y_acc))
            y_acc += line[1] + cfg.line_spacing
Exemplo n.º 7
0
    def __draw_multi_line(self, font):
        lines = build_lines(self.text, self.max_width, font)
        total_height = sum([e[0] for e in lines])
        s = pygame.Surface((self.max_width, total_height), SRCALPHA, 32)
        y = 0
        for w, h, line in lines:
            line_surface = font.render(line,
                                       self.theme.get_font_anti_alias(),
                                       self.color)
            if self.align == LEFT:
                x = 0
            elif self.align == RIGHT:
                x = self.max_width - w
            elif self.align == CENTER:
                x = (self.max_width - w) / 2

            s.blit(line_surface, (x, y))
            y += h
        self.image = Image(s)
Exemplo n.º 8
0
    def __init__(self, text, block_movement=True):
        self.text = text
        self.block_movement = block_movement

        # Split into lines
        theme = menu_config.theme
        font = theme.get_font(cfg.font_size)
        box_width = g_cfg.screen_width - 4 * cfg.border_width
        lines = build_lines(self.text,
                            box_width,
                            font)

        # Calculate box size
        self.box_height = (sum([line[1] for line in lines])
                           + (len(lines) - 1) * cfg.line_spacing
                           + 4 * cfg.border_width)
        assert self.box_height < g_cfg.screen_height,\
               'Too much text for one box.'

        Menu.__init__(self, g_cfg.screen_width - 2 * cfg.border_width,
                            self.box_height - 2 * cfg.border_width,
                            cfg.border_width,
                            g_cfg.screen_height - self.box_height\
                            + cfg.border_width,
                            bg=TRANSPARENT,
                            blocking=block_movement)

        panel = Panel(self.width, self.height)
        self.add_widget(panel, (0, 0))

        # Draw message
        y_acc = 0
        for line in lines:
            label = Label(line[2])
            panel.add_widget(label,
                             (cfg.border_width,
                              cfg.border_width + y_acc))
            y_acc += line[0] + cfg.line_spacing
Exemplo n.º 9
0
    def __init__(self, text, block_movement=True):
        self.text = text
        self.block_movement = block_movement
        self.current_panel = None

        Menu.__init__(self, g_cfg.screen_width - 2 * cfg.border_width,
                            g_cfg.screen_height / 2 - 2 * cfg.border_width,
                            cfg.border_width,
                            g_cfg.screen_height / 2 + cfg.border_width,
                            bg=TRANSPARENT,
                            blocking=block_movement)

        # Split into lines
        font = self.theme.get_font(cfg.font_size)
        box_width = g_cfg.screen_width - 4 * cfg.border_width
        lines = build_lines(self.text,
                            box_width,
                            font)

        # Split into boxes
        box_height = g_cfg.screen_height / 2 - 4 * cfg.border_width
        self.boxes = split_boxes(lines, box_height, cfg.line_spacing)
        self.panels = []

        # Draw panels
        for box in self.boxes:
            panel = Panel(self.width, self.height)
            y_acc = 0
            for line in box:
                label = Label(line[2])
                panel.add_widget(label,
                                 (cfg.border_width,
                                  cfg.border_width + y_acc))
                y_acc += line[1] + cfg.line_spacing
            self.panels.append(panel)

        self.advance_panel()