def __writeSongTitle(self, file, row): """ Renders the song title and artist onscreen, beginning at the specified row. """ winWidth, winHeight = manager.displaySize winCenter = winWidth / 2 # Word-wrap the title for line in manager.WordWrapText(file.Title, self.titleFont, winWidth): line = line.strip() text = self.titleFont.render(line, True, (255, 255, 255)) rect = text.get_rect() rect = rect.move(winCenter - rect.centerx, row) manager.display.blit(text, rect) row += self.titleHeight # Now word-wrap the artist if file.Artist: row += 10 for line in manager.WordWrapText(file.Artist, self.subtitleFont, winWidth): line = line.strip() text = self.subtitleFont.render(line, True, (255, 255, 255)) rect = text.get_rect() rect = rect.move(winCenter - rect.centerx, row) manager.display.blit(text, rect) row += self.subtitleHeight return row
def errorPopupCallback(self, errorString, wait=True): print(errorString) manager.InitPlayer(self) manager.OpenDisplay() manager.display.fill((0, 0, 0)) # Center the error message onscreen. winWidth, winHeight = manager.displaySize winCenter = winWidth / 2 lines = manager.WordWrapText(errorString, self.subtitleFont, winWidth - X_BORDER * 2) row = (winHeight - len(lines) * self.subtitleHeight) / 2 for line in lines: line = line.strip() text = self.subtitleFont.render(line, True, (255, 255, 255)) rect = text.get_rect() rect = rect.move(winCenter - rect.centerx, row) manager.display.blit(text, rect) row += self.subtitleHeight pygame.display.flip() self.screenDirty = True if not wait: return # Now wait a certain amount of time--say 5 seconds. waitUntil = pygame.time.get_ticks() + 5000 # But also, wait a quarter second to give the user a chance to # react and stop hitting buttons. pygame.time.wait(250) # Discard any events that occurred in that quarter second. for event in pygame.event.get(): pass # Now start listening for events. The first key or button # event gets us out of here. buttonPressed = False while not buttonPressed and pygame.time.get_ticks() < waitUntil: for event in pygame.event.get(): if event.type == pygame.KEYDOWN or \ (env == ENV_GP2X and event.type == pygame.JOYBUTTONDOWN): buttonPressed = True break
def showProgressCallback(self, label, progress): """ This is called by the MiniBusyCancelDialog to show progress as we're scanning the database. """ manager.InitPlayer(self) manager.OpenDisplay() manager.display.fill((0, 0, 0)) # Center the error message onscreen. winWidth, winHeight = manager.displaySize winCenter = winWidth / 2 lines = manager.WordWrapText(label, self.subtitleFont, winWidth - X_BORDER * 2) row = winHeight / 2 - 2 * self.subtitleHeight for line in lines: line = line.strip() text = self.subtitleFont.render(line, True, (255, 255, 255)) rect = text.get_rect() rect = rect.move(winCenter - rect.centerx, row) manager.display.blit(text, rect) row += self.subtitleHeight # Now draw the progress bar. width = winWidth / 2 height = self.subtitleHeight top = winHeight / 2 left = winWidth / 2 - width / 2 rect = pygame.Rect(left, top, width, height) manager.display.fill((255, 255, 255), rect) fill = int((width - 2) * progress + 0.5) rect = pygame.Rect(left + 1 + fill, top + 1, width - 2 - fill, height - 2) manager.display.fill((0, 0, 0), rect) pygame.display.flip() self.screenDirty = True