diff --git a/Data/Project/default.project b/Data/Project/default.project index e69de29b..9e26dfee 100644 --- a/Data/Project/default.project +++ b/Data/Project/default.project @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/Source/Examples/Editor/TeEditor.cpp b/Source/Examples/Editor/TeEditor.cpp index 2782ce4e..759b45ef 100644 --- a/Source/Examples/Editor/TeEditor.cpp +++ b/Source/Examples/Editor/TeEditor.cpp @@ -892,7 +892,7 @@ namespace te SPtr options = te_shared_ptr_new(); SPtr multiResourceScene = EditorResManager::Instance().LoadAll(path, options, true); - if (multiResourceScene->Entries.size() == 0 || multiResourceScene->Entries[0].Res.IsLoaded()) + if (multiResourceScene->Entries.size() == 0 || !multiResourceScene->Entries[0].Res.IsLoaded()) { TE_DEBUG("Failed to load the your project at the specified path : " + path); return false; diff --git a/Source/Plugins/TeProjectImporter/TeProjectImporter.cpp b/Source/Plugins/TeProjectImporter/TeProjectImporter.cpp index 46d152d4..d9dc15ab 100644 --- a/Source/Plugins/TeProjectImporter/TeProjectImporter.cpp +++ b/Source/Plugins/TeProjectImporter/TeProjectImporter.cpp @@ -1,7 +1,9 @@ #include "TeProjectImporter.h" #include "Project/TeProject.h" #include "Importer/TeProjectImportOptions.h" +#include "Utility/TeDataStream.h" +#include #include namespace te @@ -35,6 +37,43 @@ namespace te { project = Project::CreatePtr(); + nlohmann::json jsonDocument; + FileStream file(filePath); + + if (file.Fail()) + { + TE_ASSERT_ERROR(false, "Cannot open file: " + filePath); + return nullptr; + } + + size_t size = file.Size(); + + if (size > std::numeric_limits::max()) + { + TE_ASSERT_ERROR(false, "File size larger than supported!"); + } + + uint8_t* data = static_cast(te_allocate(static_cast(size) + 1)); + memset(data, 0, size); + file.Read(static_cast((void*)data), static_cast(size)); + data[size] = (uint8_t)'\0'; + + String dataStr((char*)data); + +#if (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND)) && !defined(JSON_NOEXCEPTION) + try + { + jsonDocument = nlohmann::json::parse(dataStr); + } + catch (...) + { + TE_ASSERT_ERROR(false, "Can't read shader file " + filePath); + } +#else + jsonDocument = nlohmann::json::parse(dataStr); +#endif + te_delete(data); + project->SetName(path.filename().generic_string()); project->SetPath(path.generic_string()); } diff --git a/Source/Plugins/TeProjectImporter/TeProjectImporter.h b/Source/Plugins/TeProjectImporter/TeProjectImporter.h index b1981e9f..fe788b65 100644 --- a/Source/Plugins/TeProjectImporter/TeProjectImporter.h +++ b/Source/Plugins/TeProjectImporter/TeProjectImporter.h @@ -3,6 +3,7 @@ #include "TeProjectImporterPrerequisites.h" #include "Importer/TeBaseImporter.h" #include "Importer/TeImporter.h" +#include "Json/json.h" namespace te {