| 439 | } |
| 440 | |
| 441 | int32_t CommandLineForScreenshot(const char** argv, int32_t argc, ScreenshotOptions* options) |
| 442 | { |
| 443 | // Don't include options in the count (they have been handled by CommandLine::ParseOptions already) |
| 444 | for (int32_t i = 0; i < argc; i++) |
| 445 | { |
| 446 | if (argv[i][0] == '-') |
| 447 | { |
| 448 | // Setting argc to i works, because options can only be at the end of the command |
| 449 | argc = i; |
| 450 | break; |
| 451 | } |
| 452 | } |
| 453 | |
| 454 | bool giantScreenshot = (argc == 5) && String::iequals(argv[2], "giant"); |
| 455 | if (argc != 4 && argc != 8 && argc != 9 && !giantScreenshot) |
| 456 | { |
| 457 | std::printf("Usage: openrct2 screenshot <file> <output_image> <width> <height> [<x> <y> [<z>] <zoom> <rotation>]\n"); |
| 458 | std::printf("Usage: openrct2 screenshot <file> <output_image> giant <zoom> <rotation>\n"); |
| 459 | return -1; |
| 460 | } |
| 461 | |
| 462 | int32_t exitCode = 1; |
| 463 | RenderTarget rt; |
| 464 | try |
| 465 | { |
| 466 | bool customLocation = false; |
| 467 | bool centreMapX = false; |
| 468 | bool centreMapY = false; |
| 469 | |
| 470 | const char* inputPath = argv[0]; |
| 471 | const char* outputPath = argv[1]; |
| 472 | |
| 473 | gOpenRCT2Headless = true; |
| 474 | auto context = CreateContext(); |
| 475 | if (!context->Initialise()) |
| 476 | { |
| 477 | throw std::runtime_error("Failed to initialize context."); |
| 478 | } |
| 479 | |
| 480 | DrawingEngineInit(); |
| 481 | |
| 482 | if (!context->LoadParkFromFile(inputPath)) |
| 483 | { |
| 484 | throw std::runtime_error("Failed to load park."); |
| 485 | } |
| 486 | |
| 487 | gLegacyScene = LegacyScene::playing; |
| 488 | |
| 489 | Viewport viewport{}; |
| 490 | if (giantScreenshot) |
| 491 | { |
| 492 | auto customZoom = static_cast<int8_t>(std::atoi(argv[3])); |
| 493 | auto zoom = ZoomLevel{ customZoom }; |
| 494 | auto rotation = std::atoi(argv[4]) & 3; |
| 495 | viewport = GetGiantViewport(rotation, zoom); |
| 496 | } |
| 497 | else |
| 498 | { |
no test coverage detected