1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-22 14:24:33 +01:00

Create fallback system for csg1 images

This commit is contained in:
Gymnasiast
2021-11-30 19:20:09 +01:00
parent bb35adc5b8
commit fcd704ed47
10 changed files with 24 additions and 28 deletions

View File

@@ -443,15 +443,23 @@ std::vector<std::pair<std::string, Image>> ImageTable::GetImageSources(IReadObje
return result;
}
void ImageTable::ReadJson(IReadObjectContext* context, json_t& root)
bool ImageTable::ReadJson(IReadObjectContext* context, json_t& root)
{
Guard::Assert(root.is_object(), "ImageTable::ReadJson expects parameter root to be object");
bool usesFallbackSprites = false;
if (context->ShouldLoadImages())
{
// First gather all the required images from inspecting the JSON
std::vector<std::unique_ptr<RequiredImage>> allImages;
auto jsonImages = root["images"];
if (!is_csg_loaded() && root.contains("noCsgImages"))
{
jsonImages = root["noCsgImages"];
usesFallbackSprites = true;
}
auto imageSources = GetImageSources(context, jsonImages);
for (auto& jsonImage : jsonImages)
@@ -506,6 +514,8 @@ void ImageTable::ReadJson(IReadObjectContext* context, json_t& root)
}
}
}
return usesFallbackSprites;
}
void ImageTable::AddImage(const rct_g1_element* g1)