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

Create function to create object from file

This commit is contained in:
Gymnasiast
2025-09-21 00:12:23 +02:00
parent db5f56f4aa
commit 161a8359fc
3 changed files with 26 additions and 26 deletions

View File

@@ -264,6 +264,28 @@ namespace OpenRCT2::ObjectFactory
}
}
std::unique_ptr<Object> CreateObjectFromFile(IObjectRepository& objectRepository, u8string_view path, bool loadImages)
{
std::unique_ptr<Object> object;
auto extension = Path::GetExtension(path);
if (String::iequals(extension, ".json"))
{
auto pathStr = u8string(path);
object = ObjectFactory::CreateObjectFromJsonFile(objectRepository, pathStr, loadImages);
}
else if (String::iequals(extension, ".parkobj"))
{
object = ObjectFactory::CreateObjectFromZipFile(objectRepository, path, loadImages);
}
else
{
auto pathStr = u8string(path);
object = ObjectFactory::CreateObjectFromLegacyFile(objectRepository, pathStr.c_str(), loadImages);
}
return object;
}
std::unique_ptr<Object> CreateObjectFromLegacyFile(IObjectRepository& objectRepository, const utf8* path, bool loadImages)
{
LOG_VERBOSE("CreateObjectFromLegacyFile(..., \"%s\")", path);