Beispiel #1
0
    def set_song(self, song):
        c1 = [255, 255, 255]
        self._bpmdisplay.set_song(song)
        self._next_update = -2  # Magic value

        song.render()

        self._title = fontfx.shadow(song.info["title"], FontTheme.font("BannerDisp_title", song.info["title"], 340), c1)
        self._r_t = self._title.get_rect()
        self._r_t.center = [179, 240]
        self._artist = fontfx.shadow(
            song.info["artist"], FontTheme.font("BannerDisp_artist", song.info["artist"], 250), c1
        )

        self._r_a = self._artist.get_rect()
        self._r_a.center = [179, 320]

        if song.info["subtitle"]:
            self._subtitle = fontfx.shadow(
                song.info["subtitle"], FontTheme.font("BannerDisp_subtitle", song.info["subtitle"], 300), c1
            )
            self._r_s = self._subtitle.get_rect()
            self._r_s.center = [179, 270]
        else:
            self._subtitle = None
        self._clip = song.clip
        self._banner = song.banner
        self._r_b = self._banner.get_rect()
        self._r_b.center = [179, 100]
        self._cdtitle = song.cdtitle
        self._r_cd = self._cdtitle.get_rect()
        self._r_cd.center = [290, 180]
Beispiel #2
0
  def __init__(self, screen, line):
    InterfaceWindow.__init__(self, screen, "error-bg.png")
    text = fontfx.shadow("Error!", 60, [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", 32, [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.START, ui.CONFIRM, ui.QUIT]:
      if ev == ui.FULLSCREEN:
        pygame.display.toggle_fullscreen()
        mainconfig["fullscreen"] ^= 1
      pid, ev = ui.ui.wait()
Beispiel #3
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()
Beispiel #4
0
    def set_song(self, song):
        c1 = [255, 255, 255]
        self._bpmdisplay.set_song(song)
        self._next_update = -2  # Magic value

        song.render()

        self._title = fontfx.shadow(
            song.info["title"],
            FontTheme.font('BannerDisp_title', song.info["title"], 340), c1)
        self._r_t = self._title.get_rect()
        self._r_t.center = [179, 240]
        self._artist = fontfx.shadow(
            song.info["artist"],
            FontTheme.font('BannerDisp_artist', song.info["artist"], 250), c1)

        self._r_a = self._artist.get_rect()
        self._r_a.center = [179, 320]

        if song.info["subtitle"]:
            self._subtitle = fontfx.shadow(
                song.info["subtitle"],
                FontTheme.font('BannerDisp_subtitle', song.info["subtitle"],
                               300), c1)
            self._r_s = self._subtitle.get_rect()
            self._r_s.center = [179, 270]
        else:
            self._subtitle = None
        self._clip = song.clip
        self._banner = song.banner
        self._r_b = self._banner.get_rect()
        self._r_b.center = [179, 100]
        self._cdtitle = song.cdtitle
        self._r_cd = self._cdtitle.get_rect()
        self._r_cd.center = [290, 180]
Beispiel #5
0
    def _render(self, pct):
        self.image = pygame.Surface([430, 40], SRCALPHA, 32)
        self.image.fill([0, 0, 0, 0])
        self.rect = self.image.get_rect()
        self.rect.center = self._center

        if pct <= 0:
            self._needs_update = False
            offset = 0
            pct = 1
        elif self._oldindex != self._index:
            offset = (self._font.size(self._possible[self._oldindex])[0] / 2 +
                      self._font.size(self._possible[self._index])[0] / 2 + 30)
            offset = int(pct * offset)
            if self._oldindex > self._index: offset = -offset
        else: offset = 0

        t = fontfx.shadow(self._possible[self._index], FontTheme.Opts_choices,
                          [255, 255, 255])
        r = t.get_rect()
        r.center = [215 + offset, 20]
        self.image.blit(t, r)
        old_r = Rect(r)

        idx = self._index - 1
        while idx >= 0 and r.left > 0:
            t = fontfx.shadow(self._possible[idx], FontTheme.Opts_choices,
                              [255, 255, 255])
            t2 = pygame.Surface(t.get_size())
            t2.blit(t, [0, 0])
            t2.set_colorkey(t2.get_at([0, 0]))
            r2 = t2.get_rect()
            r2.centery = 20
            r2.right = r.left - 30
            t2.set_alpha(int(200 * (r2.centerx / 215.0)))
            self.image.blit(t2, r2)
            idx -= 1
            r = r2

        idx = self._index + 1
        r = old_r
        while idx < len(self._possible) and r.right < 430:
            t = fontfx.shadow(self._possible[idx], FontTheme.Opts_choices,
                              [255, 255, 255])
            t2 = pygame.Surface(t.get_size())
            t2.blit(t, [0, 0])
            t2.set_colorkey(t2.get_at([0, 0]))
            r2 = t2.get_rect()
            r2.centery = 20
            r2.left = r.right + 30
            t2.set_alpha(int(200 * ((430 - r2.centerx) / 215.0)))
            self.image.blit(t2, r2)
            idx += 1
            r = r2
Beispiel #6
0
  def _render(self, pct):
    self.image = pygame.Surface([430, 40], SRCALPHA, 32)
    self.image.fill([0, 0, 0, 0])
    self.rect = self.image.get_rect()
    self.rect.center = self._center

    if pct <= 0:
      self._needs_update = False
      offset = 0
      pct = 1
    elif self._oldindex != self._index:
      offset = (self._font.size(self._possible[self._oldindex])[0]/2 +
                self._font.size(self._possible[self._index])[0]/2 + 30)
      offset = int(pct * offset)
      if self._oldindex > self._index: offset = -offset
    else: offset = 0

    t = fontfx.shadow(self._possible[self._index],
                      FontTheme.Opts_choices, [255, 255, 255])
    r = t.get_rect()
    r.center = [215 + offset, 20]
    self.image.blit(t, r)
    old_r = Rect(r)
    
    idx = self._index - 1
    while idx >= 0 and r.left > 0:
      t = fontfx.shadow(self._possible[idx],
                        FontTheme.Opts_choices, [255, 255, 255])
      t2 = pygame.Surface(t.get_size())
      t2.blit(t, [0, 0])
      t2.set_colorkey(t2.get_at([0, 0]))
      r2 = t2.get_rect()
      r2.centery = 20
      r2.right = r.left - 30
      t2.set_alpha(int(200 * (r2.centerx / 215.0)))
      self.image.blit(t2, r2)
      idx -= 1
      r = r2

    idx = self._index + 1
    r = old_r
    while idx < len(self._possible) and r.right < 430:
      t = fontfx.shadow(self._possible[idx],
                        FontTheme.Opts_choices, [255, 255, 255])
      t2 = pygame.Surface(t.get_size())
      t2.blit(t, [0, 0])
      t2.set_colorkey(t2.get_at([0, 0]))
      r2 = t2.get_rect()
      r2.centery = 20
      r2.left = r.right + 30
      t2.set_alpha(int(200 * ((430 - r2.centerx) / 215.0)))
      self.image.blit(t2, r2)
      idx += 1
      r = r2
Beispiel #7
0
 def _render(self):
   if self._bpm:
     w = 100
     h = self._font.get_linesize() * 2 - self._font.get_descent()
     self.image = pygame.Surface([w, h], SRCALPHA, 32)
     self.image.fill([0, 0, 0, 0])
     t1 = fontfx.shadow("BPM:", self._font, [255, 255, 255])
     t2 = fontfx.shadow("%d" % int(self._bpm), self._font, self._color)
     r1 = t1.get_rect()
     r1.midtop = [50, 0]
     r2 = t2.get_rect()
     r2.midtop = [50, self._font.get_linesize()]
     self.image.blit(t1, r1)
     self.image.blit(t2, r2)
   else: self.image = pygame.Surface([0, 0])
   self.rect = self.image.get_rect()
   self.rect.center = self._center
Beispiel #8
0
 def _render(self):
   if self._bpm:
     w = 100
     h = self._font.get_linesize() * 2 - self._font.get_descent()
     self.image = pygame.Surface([w, h], SRCALPHA, 32)
     self.image.fill([0, 0, 0, 0])
     t1 = fontfx.shadow("BPM:", self._font, [255, 255, 255])
     t2 = fontfx.shadow("%d" % int(self._bpm), self._font, self._color)
     r1 = t1.get_rect()
     r1.midtop = [50, 0]
     r2 = t2.get_rect()
     r2.midtop = [50, self._font.get_linesize()]
     self.image.blit(t1, r1)
     self.image.blit(t2, r2)
   else: self.image = pygame.Surface([0, 0])
   self.rect = self.image.get_rect()
   self.rect.center = self._center
Beispiel #9
0
 def __init__(self, pos, title, count, size, delay):
     pygame.sprite.Sprite.__init__(self)
     self._start = pygame.time.get_ticks() + delay
     self._count = count
     self._pos = pos
     self._curcount = 0
     self._size = size
     self._title = fontfx.shadow(title, FontTheme.GrScr_text, colors.WHITE)
     self._render()
Beispiel #10
0
 def __init__(self, pos, title, count, size, delay):
   pygame.sprite.Sprite.__init__(self)
   self._start = pygame.time.get_ticks() + delay
   self._count = count
   self._pos = pos
   self._curcount = 0
   self._size = size
   self._title = fontfx.shadow(title, FontTheme.GrScr_text, colors.WHITE)
   self._render()
Beispiel #11
0
    def set_items(self, items):
        c2 = [c / 8 for c in self._color]
        self._items = []

        for i in items:
            txt = fontfx.render_outer(i, self._w - 7, self._font)
            img = fontfx.shadow(txt, self._font, self._color)
            self._items.append(img)
        self._idx = self._oldidx = 0 - self._count / 2  # Reset index to 0.
        self._needs_update = True
Beispiel #12
0
    def set(self, diff, color, feet, grade):
        f = FontTheme.diffbox
        self.image = make_box(color)

        # diff has to be translated: _( ) (BEGINNER, etc.)
        t1 = fontfx.shadow(_(diff), f, [255, 255, 255])
        r1 = t1.get_rect()
        r1.center = [self.image.get_width() / 2, 14]

        t2 = fontfx.shadow("x%d - %s" % (feet, grade), f, [255, 255, 255])
        r2 = t2.get_rect()
        r2.center = [self.image.get_width() / 2, 34]

        self.image.blit(t1, r1)
        self.image.blit(t2, r2)

        self.rect = self.image.get_rect()
        self.rect.topleft = self._topleft
        self.image.set_alpha(140)
Beispiel #13
0
    def set_items(self, items):
        c2 = [c / 8 for c in self._color]
        self._items = []

        for i in items:
            txt = fontfx.render_outer(i, self._w - 7, self._font)
            img = fontfx.shadow(txt, self._font, self._color)
            self._items.append(img)
        self._idx = self._oldidx = 0 - self._count / 2  # Reset index to 0.
        self._needs_update = True
Beispiel #14
0
    def set(self, diff, color, feet, grade):
        f = FontTheme.diffbox
        self.image = make_box(color)

        #diff has to be translated: _( ) (BEGINNER, etc.)
        t1 = fontfx.shadow(_(diff), f, [255, 255, 255])
        r1 = t1.get_rect()
        r1.center = [self.image.get_width() / 2, 14]

        t2 = fontfx.shadow("x%d - %s" % (feet, grade), f, [255, 255, 255])
        r2 = t2.get_rect()
        r2.center = [self.image.get_width() / 2, 34]

        self.image.blit(t1, r1)
        self.image.blit(t2, r2)

        self.rect = self.image.get_rect()
        self.rect.topleft = self._topleft
        self.image.set_alpha(140)
Beispiel #15
0
 def _render(self):
     self.image = pygame.Surface(self._size, SRCALPHA, 32)
     self.image.fill([0, 0, 0, 0])
     rt = self._title.get_rect()
     rt.midleft = [0, self._size[1] / 2]
     self.image.blit(self._title, rt)
     s = "%d / %d" % (self._curgood, self._curtotal)
     cnt = fontfx.shadow(s, FontTheme.GrScr_text, colors.WHITE)
     rc = cnt.get_rect()
     rc.midright = [self._size[0] - 1, self._size[1] / 2]
     self.image.blit(cnt, rc)
     self.rect = self.image.get_rect()
     self.rect.topleft = self._pos
Beispiel #16
0
 def _render(self):
   self.image = pygame.Surface(self._size, SRCALPHA, 32)
   self.image.fill([0, 0, 0, 0])
   rt = self._title.get_rect()
   rt.midleft = [0, self._size[1] / 2]
   self.image.blit(self._title, rt)
   s = "%d / %d" % (self._curgood, self._curtotal)
   cnt = fontfx.shadow(s, FontTheme.GrScr_text, colors.WHITE)
   rc = cnt.get_rect()
   rc.midright = [self._size[0] - 1, self._size[1] / 2]
   self.image.blit(cnt, rc)
   self.rect = self.image.get_rect()
   self.rect.topleft = self._pos
Beispiel #17
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
Beispiel #18
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
Beispiel #19
0
  def update(self, time):
    if time > self._end:
      if time - self._last_update > 100:
        self.image = self._image.convert()
        if self._i < 4: self._idir = 4
        elif self._i > 250: self._idir = -4
        self._i += self._idir
        c = [self._i, 192, 192]
        txt = fontfx.shadow(_("Press Escape/Confirm/Start"), FontTheme.GrScr_tocontinue, c)
        txt_r = txt.get_rect()
        txt_r.center = [123, 70]
        self.image.blit(txt, txt_r)
        self.rect = self.image.get_rect()
        self.rect.center = self._center
        self._last_update = time

    else:
      alp = int(256 * (1 - ((self._end - time) / 3000.0)))
      self.image.set_alpha(alp)
Beispiel #20
0
 def _render(self):
     font = FontTheme.font(self._purpose, self._text, self._size[0])
     img = fontfx.shadow(self._text, font, [255, 255, 255])
     self.image = img
     self.rect = self.image.get_rect()
     self.rect.midleft = self._midleft
Beispiel #21
0
 def _render(self):
     font = FontTheme.font(self._purpose, self._text, self._size[0])
     img = fontfx.shadow(self._text, font, [255, 255, 255])
     self.image = img
     self.rect = self.image.get_rect()
     self.rect.midleft = self._midleft