| 575 | self._notifications.set_text('Error: %s' % text, (255, 0, 0)) |
| 576 | |
| 577 | def render(self, display): |
| 578 | if self._show_info: |
| 579 | info_surface = pygame.Surface((220, self.dim[1])) |
| 580 | info_surface.set_alpha(100) |
| 581 | display.blit(info_surface, (0, 0)) |
| 582 | v_offset = 4 |
| 583 | bar_h_offset = 100 |
| 584 | bar_width = 106 |
| 585 | for item in self._info_text: |
| 586 | if v_offset + 18 > self.dim[1]: |
| 587 | break |
| 588 | if isinstance(item, list): |
| 589 | if len(item) > 1: |
| 590 | points = [(x + 8, v_offset + 8 + (1.0 - y) * 30) for x, y in enumerate(item)] |
| 591 | pygame.draw.lines(display, (255, 136, 0), False, points, 2) |
| 592 | item = None |
| 593 | v_offset += 18 |
| 594 | elif isinstance(item, tuple): |
| 595 | if isinstance(item[1], bool): |
| 596 | rect = pygame.Rect((bar_h_offset, v_offset + 8), (6, 6)) |
| 597 | pygame.draw.rect(display, (255, 255, 255), rect, 0 if item[1] else 1) |
| 598 | else: |
| 599 | rect_border = pygame.Rect((bar_h_offset, v_offset + 8), (bar_width, 6)) |
| 600 | pygame.draw.rect(display, (255, 255, 255), rect_border, 1) |
| 601 | f = (item[1] - item[2]) / (item[3] - item[2]) |
| 602 | if item[2] < 0.0: |
| 603 | rect = pygame.Rect((bar_h_offset + f * (bar_width - 6), v_offset + 8), (6, 6)) |
| 604 | else: |
| 605 | rect = pygame.Rect((bar_h_offset, v_offset + 8), (f * bar_width, 6)) |
| 606 | pygame.draw.rect(display, (255, 255, 255), rect) |
| 607 | item = item[0] |
| 608 | if item: # At this point has to be a str. |
| 609 | surface = self._font_mono.render(item, True, (255, 255, 255)) |
| 610 | display.blit(surface, (8, v_offset)) |
| 611 | v_offset += 18 |
| 612 | self._notifications.render(display) |
| 613 | self.help.render(display) |
| 614 | |
| 615 | |
| 616 | # ============================================================================== |