| 512 | self._notifications.set_text('Error: %s' % text, (255, 0, 0)) |
| 513 | |
| 514 | def render(self, display): |
| 515 | if self._show_info: |
| 516 | info_surface = pygame.Surface((220, self.dim[1])) |
| 517 | info_surface.set_alpha(100) |
| 518 | display.blit(info_surface, (0, 0)) |
| 519 | v_offset = 4 |
| 520 | bar_h_offset = 100 |
| 521 | bar_width = 106 |
| 522 | for item in self._info_text: |
| 523 | text_color = (255, 255, 255) |
| 524 | if v_offset + 18 > self.dim[1]: |
| 525 | break |
| 526 | if isinstance(item, list): |
| 527 | if len(item) > 1: |
| 528 | points = [(x + 8, v_offset + 8 + (1.0 - y) * 30) for x, y in enumerate(item)] |
| 529 | pygame.draw.lines(display, (255, 136, 0), False, points, 2) |
| 530 | item = None |
| 531 | v_offset += 18 |
| 532 | elif isinstance(item, tuple): |
| 533 | if isinstance(item[1], bool): |
| 534 | rect = pygame.Rect((bar_h_offset, v_offset + 8), (6, 6)) |
| 535 | pygame.draw.rect(display, (255, 255, 255), rect, 0 if item[1] else 1) |
| 536 | else: |
| 537 | rect_border = pygame.Rect((bar_h_offset, v_offset + 8), (bar_width, 6)) |
| 538 | pygame.draw.rect(display, (255, 255, 255), rect_border, 1) |
| 539 | f = (item[1] - item[2]) / (item[3] - item[2]) |
| 540 | if item[2] < 0.0: |
| 541 | rect = pygame.Rect((bar_h_offset + f * (bar_width - 6), v_offset + 8), (6, 6)) |
| 542 | else: |
| 543 | rect = pygame.Rect((bar_h_offset, v_offset + 8), (f * bar_width, 6)) |
| 544 | pygame.draw.rect(display, (255, 255, 255), rect) |
| 545 | if len(item) == 5: |
| 546 | if item[1] != item[4]: |
| 547 | pygame.draw.rect(display, (255, 0, 0), rect_border, 1) |
| 548 | f = (item[4] - item[2]) / (item[3] - item[2]) |
| 549 | if item[2] < 0.0: |
| 550 | rect = pygame.Rect((bar_h_offset + f * (bar_width - 6), v_offset + 8), (6, 6)) |
| 551 | else: |
| 552 | rect = pygame.Rect((bar_h_offset, v_offset + 8), (f * bar_width, 6)) |
| 553 | pygame.draw.rect(display, (255, 0, 0), rect) |
| 554 | text_color = (255, 0, 0) |
| 555 | item = item[0] |
| 556 | if item: # At this point has to be a str. |
| 557 | surface = self._font_mono.render(item, True, text_color) |
| 558 | display.blit(surface, (8, v_offset)) |
| 559 | v_offset += 18 |
| 560 | self._notifications.render(display) |
| 561 | self.help.render(display) |
| 562 | |
| 563 | |
| 564 | # ============================================================================== |