Support loading images from zip

This commit is contained in:
Ted John committed 2018-05-13 12:04:45 +01:00
1 parent 0f0bb021d6
commit 4e86d18dad
4 files changed
+135 -43

No files matched your search

+21 -22
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);