1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-16 11:33:03 +01:00

Support loading images from zip

This commit is contained in:
Ted John
2018-05-12 16:11:51 +01:00
parent 0f0bb021d6
commit 4e86d18dad
4 changed files with 135 additions and 43 deletions

View File

@@ -103,34 +103,29 @@ public:
public:
std::tuple<bool, ObjectRepositoryItem> Create(sint32 language, const std::string &path) const override
{
Object * object = nullptr;
auto extension = Path::GetExtension(path);
if (String::Equals(extension, ".json", true))
{
auto object = ObjectFactory::CreateObjectFromJsonFile(_objectRepository, path);
if (object != nullptr)
{
ObjectRepositoryItem item = { 0 };
item.ObjectEntry = *object->GetObjectEntry();
item.Path = String::Duplicate(path);
item.Name = String::Duplicate(object->GetName(language));
object->SetRepositoryItem(&item);
delete object;
return std::make_tuple(true, item);
}
object = ObjectFactory::CreateObjectFromJsonFile(_objectRepository, path);
}
else if (String::Equals(extension, ".parkobj", true))
{
object = ObjectFactory::CreateObjectFromZipFile(_objectRepository, path);
}
else
{
auto object = ObjectFactory::CreateObjectFromLegacyFile(_objectRepository, path.c_str());
if (object != nullptr)
{
ObjectRepositoryItem item = { 0 };
item.ObjectEntry = *object->GetObjectEntry();
item.Path = String::Duplicate(path);
item.Name = String::Duplicate(object->GetName());
object->SetRepositoryItem(&item);
delete object;
return std::make_tuple(true, item);
}
object = ObjectFactory::CreateObjectFromLegacyFile(_objectRepository, path.c_str());
}
if (object != nullptr)
{
ObjectRepositoryItem item = { 0 };
item.ObjectEntry = *object->GetObjectEntry();
item.Path = String::Duplicate(path);
item.Name = String::Duplicate(object->GetName());
object->SetRepositoryItem(&item);
delete object;
return std::make_tuple(true, item);
}
return std::make_tuple(false, ObjectRepositoryItem());
}
@@ -285,6 +280,10 @@ public:
{
return ObjectFactory::CreateObjectFromJsonFile(*this, ori->Path);
}
else if (String::Equals(extension, ".parkobj", true))
{
return ObjectFactory::CreateObjectFromZipFile(*this, ori->Path);
}
else
{
return ObjectFactory::CreateObjectFromLegacyFile(*this, ori->Path);