Ejemplo n.º 1
0
    def render(self):
        if self.banner: return
        font = fontfx.WrapFont(FontTheme.Crs_song_title, 320)
        small_font = fontfx.WrapFont(FontTheme.Crs_song_subtitle, 250)
        ls = font.get_linesize()
        y = ls * 3
        for name, subtitle, diff in self._songs:
            y += font.lines(name, indent="    ") * ls
            y += font.lines(subtitle, indent="    ") * (ls / 4)

        self.image = pygame.Surface([340, y], SRCALPHA, 32)
        self.image.fill([0, 0, 0, 0])

        y_off = 0
        for name, subtitle, diff in self._songs:
            t3 = None
            t1 = font.render(name, color=colors.WHITE, indent="    ")
            if subtitle:
                t3 = small_font.render(subtitle,
                                       color=[190, 190, 190],
                                       indent="    ")

            if isinstance(diff, list): d = diff[0]
            else: d = diff

            t2 = fontfx.shadow(d[0], FontTheme.Crs_song_title,
                               DIFF_COLORS.get(d, colors.WHITE))

            r1 = t1.get_rect()
            r2 = t2.get_rect()
            r1.top = r2.top = y_off
            r1.left = 0
            r2.right = 340
            y_off += t1.get_height()
            self.image.blit(t1, r1)
            self.image.blit(t2, r2)

            if t3:
                r3 = t3.get_rect()
                r3.left = 30
                ls = small_font.get_linesize()
                r3.top = y_off - 3 * ls / 4
                y_off += ls / 4
                self.image.blit(t3, r3)

        if self.banner_fn and os.path.exists(self.banner_fn):
            self.banner, self.clip = load_banner(self.banner_fn, False)
        else:
            self.banner = CourseDisplay.no_banner
Ejemplo n.º 2
0
    def __init__(self, screen, line):
        InterfaceWindow.__init__(self, screen, "error-bg.png")
        text = fontfx.shadow("Error!",
                             FontTheme.error_message, [255, 255, 255],
                             offset=2)
        text_rect = text.get_rect()
        text_rect.center = [320, 50]
        screen.blit(text, text_rect)

        # FIXME: Remove this when I'm sure that nothing uses the old calling
        # method. (Pre-1.0)
        if isinstance(line, list): lines = " ".join(line)

        font = fontfx.WrapFont(FontTheme.error_message, 440)
        b = font.render(line, shdw=True, centered=True)
        r = b.get_rect()
        r.center = [320, 240]
        screen.blit(b, r)

        text = fontfx.shadow("Press Enter/Start/Escape",
                             FontTheme.error_message, [160, 160, 160])
        textpos = text.get_rect()
        textpos.center = [320, 440]
        screen.blit(text, textpos)

        pygame.display.update()
        ui.ui.clear()

        pid, ev = (0, ui.PASS)
        while ev not in [ui.OPTIONS, ui.CONFIRM, ui.CANCEL]:
            if ev == ui.FULLSCREEN:
                pygame.display.toggle_fullscreen()
                mainconfig["fullscreen"] ^= 1
            pid, ev = ui.ui.wait()
Ejemplo n.º 3
0
 def __init__(self, font, width, topleft, str=" ", centered=False):
     pygame.sprite.Sprite.__init__(self)
     self._text = str
     self._centered = centered
     self._needs_update = False
     self._font = fontfx.WrapFont(font, width)
     self._topleft = topleft
     self._render()