(self, client, world, clock)
| 297 | world.hud.notification("Press 'H' or '?' for help.", seconds=4.0) |
| 298 | |
| 299 | def parse_events(self, client, world, clock): |
| 300 | if isinstance(self._control, carla.VehicleControl): |
| 301 | current_lights = self._lights |
| 302 | for event in pygame.event.get(): |
| 303 | if event.type == pygame.QUIT: |
| 304 | return True |
| 305 | elif event.type == pygame.KEYUP: |
| 306 | if self._is_quit_shortcut(event.key): |
| 307 | return True |
| 308 | elif event.key == K_BACKSPACE: |
| 309 | if self._autopilot_enabled: |
| 310 | world.player.set_autopilot(False) |
| 311 | world.restart() |
| 312 | world.player.set_autopilot(True) |
| 313 | else: |
| 314 | world.restart() |
| 315 | elif event.key == K_F1: |
| 316 | world.hud.toggle_info() |
| 317 | elif event.key == K_h or (event.key == K_SLASH and pygame.key.get_mods() & KMOD_SHIFT): |
| 318 | world.hud.help.toggle() |
| 319 | elif event.key == K_TAB: |
| 320 | world.camera_manager.toggle_camera() |
| 321 | elif event.key == K_c and pygame.key.get_mods() & KMOD_SHIFT: |
| 322 | world.next_weather(reverse=True) |
| 323 | elif event.key == K_c: |
| 324 | world.next_weather() |
| 325 | elif event.key == K_g: |
| 326 | world.toggle_radar() |
| 327 | elif event.key == K_BACKQUOTE: |
| 328 | world.camera_manager.next_sensor() |
| 329 | elif event.key == K_n: |
| 330 | world.camera_manager.next_sensor() |
| 331 | elif event.key > K_0 and event.key <= K_9: |
| 332 | world.camera_manager.set_sensor(event.key - 1 - K_0) |
| 333 | elif event.key == K_r and not (pygame.key.get_mods() & KMOD_CTRL): |
| 334 | world.camera_manager.toggle_recording() |
| 335 | elif event.key == K_r and (pygame.key.get_mods() & KMOD_CTRL): |
| 336 | if (world.recording_enabled): |
| 337 | client.stop_recorder() |
| 338 | world.recording_enabled = False |
| 339 | world.hud.notification("Recorder is OFF") |
| 340 | else: |
| 341 | client.start_recorder("manual_recording.rec") |
| 342 | world.recording_enabled = True |
| 343 | world.hud.notification("Recorder is ON") |
| 344 | elif event.key == K_p and (pygame.key.get_mods() & KMOD_CTRL): |
| 345 | # stop recorder |
| 346 | client.stop_recorder() |
| 347 | world.recording_enabled = False |
| 348 | # work around to fix camera at start of replaying |
| 349 | current_index = world.camera_manager.index |
| 350 | world.destroy_sensors() |
| 351 | # disable autopilot |
| 352 | self._autopilot_enabled = False |
| 353 | world.player.set_autopilot(self._autopilot_enabled) |
| 354 | world.hud.notification("Replaying file 'manual_recording.rec'") |
| 355 | # replayer |
| 356 | client.replay_file("manual_recording.rec", world.recording_start, 0, 0) |
no test coverage detected