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:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user