From f1148e310eadb2b466aa3846eaebd4dd635ae1ac Mon Sep 17 00:00:00 2001 From: spacek531 Date: Mon, 27 Jan 2025 00:25:22 -0800 Subject: [PATCH] Build image repository from object images (#23640) --- distribution/changelog.txt | 1 + src/openrct2/CommandLineSprite.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index f8a5bc9d8a..9aa6345896 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -5,6 +5,7 @@ - Improved: [#20683] Allow Giga Coaster cable lift to start after block brake section. - Improved: [#23328] The costume list in the staff window is now ordered alphabetically. - Improved: [#23540] The file browser now optionally shows a file size column. +- Improved: [#23640] Building sprite repository with command line can use images array of JSON parkobj. - Change: [#23328] All RCT2 entertainer costumes are now available in legacy parks. - Fix: [#1479] Incorrect values provided by the in game console “get location” command. - Fix: [#21794] Lay-down coaster cars reverse on first frames of downwards corkscrew. diff --git a/src/openrct2/CommandLineSprite.cpp b/src/openrct2/CommandLineSprite.cpp index 12346ae9b3..42a97cc7b4 100644 --- a/src/openrct2/CommandLineSprite.cpp +++ b/src/openrct2/CommandLineSprite.cpp @@ -537,6 +537,9 @@ int32_t CommandLineForSprite(const char** argv, int32_t argc) return -1; } + if (jsonSprites.is_object() && !jsonSprites["images"].is_null()) + jsonSprites = jsonSprites["images"]; + if (!jsonSprites.is_array()) { fprintf(stderr, "Error: expected array\n"); @@ -555,6 +558,8 @@ int32_t CommandLineForSprite(const char** argv, int32_t argc) json_t sprite_description; + uint32_t numSuccessful = 0; + // Note: jsonSprite is deliberately left non-const: json_t behaviour changes when const for (auto& [jsonKey, jsonSprite] : jsonSprites.items()) { @@ -588,6 +593,8 @@ int32_t CommandLineForSprite(const char** argv, int32_t argc) if (!silent) fprintf(stdout, "Added: %s\n", imagePath.c_str()); + + numSuccessful++; } if (!spriteFile.Save(spriteFilePath)) @@ -596,7 +603,7 @@ int32_t CommandLineForSprite(const char** argv, int32_t argc) return -1; } - fprintf(stdout, "Finished\n"); + fprintf(stdout, "Finished building graphics repository with %u images\n", numSuccessful); return 1; }