| 342 | return vehicle_id_surface |
| 343 | |
| 344 | def render(self, display): |
| 345 | if self.show_info: |
| 346 | info_surface = pygame.Surface((240, self.dim[1])) |
| 347 | info_surface.set_alpha(100) |
| 348 | display.blit(info_surface, (0, 0)) |
| 349 | v_offset = 4 |
| 350 | bar_h_offset = 100 |
| 351 | bar_width = 106 |
| 352 | i = 0 |
| 353 | for module_name, module_info in self._info_text.items(): |
| 354 | if not module_info: |
| 355 | continue |
| 356 | surface = self._header_font.render(module_name, True, COLOR_ALUMINIUM_0).convert_alpha() |
| 357 | display.blit(surface, (8 + bar_width / 2, 18 * i + v_offset)) |
| 358 | v_offset += 12 |
| 359 | i += 1 |
| 360 | for item in module_info: |
| 361 | if v_offset + 18 > self.dim[1]: |
| 362 | break |
| 363 | if isinstance(item, list): |
| 364 | if len(item) > 1: |
| 365 | points = [(x + 8, v_offset + 8 + (1.0 - y) * 30) for x, y in enumerate(item)] |
| 366 | pygame.draw.lines(display, (255, 136, 0), False, points, 2) |
| 367 | item = None |
| 368 | elif isinstance(item, tuple): |
| 369 | if isinstance(item[1], bool): |
| 370 | rect = pygame.Rect((bar_h_offset, v_offset + 8), (6, 6)) |
| 371 | pygame.draw.rect(display, COLOR_ALUMINIUM_0, rect, 0 if item[1] else 1) |
| 372 | else: |
| 373 | rect_border = pygame.Rect((bar_h_offset, v_offset + 8), (bar_width, 6)) |
| 374 | pygame.draw.rect(display, COLOR_ALUMINIUM_0, rect_border, 1) |
| 375 | f = (item[1] - item[2]) / (item[3] - item[2]) |
| 376 | if item[2] < 0.0: |
| 377 | rect = pygame.Rect((bar_h_offset + f * (bar_width - 6), v_offset + 8), (6, 6)) |
| 378 | else: |
| 379 | rect = pygame.Rect((bar_h_offset, v_offset + 8), (f * bar_width, 6)) |
| 380 | pygame.draw.rect(display, COLOR_ALUMINIUM_0, rect) |
| 381 | item = item[0] |
| 382 | if item: # At this point has to be a str. |
| 383 | surface = self._font_mono.render(item, True, COLOR_ALUMINIUM_0).convert_alpha() |
| 384 | display.blit(surface, (8, 18 * i + v_offset)) |
| 385 | v_offset += 18 |
| 386 | v_offset += 24 |
| 387 | self._notifications.render(display) |
| 388 | self.help.render(display) |
| 389 | |
| 390 | |
| 391 | # ============================================================================== |