Moved project loading logic to editor class

This commit is contained in:
Antoine Pilote
2023-09-21 11:35:00 -04:00
parent 8d323246c0
commit 3be93f7bec
5 changed files with 45 additions and 24 deletions

View File

@@ -61,6 +61,8 @@ namespace Nuake {
filesystem = new FileSystemUI(this);
_WelcomeWindow = new WelcomeWindow(this);
_audioWindow = new AudioWindow();
BuildFonts();
}
void EditorInterface::Init()
@@ -1675,4 +1677,30 @@ namespace Nuake {
return entityTypeName;
}
bool EditorInterface::LoadProject(const std::string& projectPath)
{
FileSystem::SetRootDirectory(FileSystem::GetParentPath(projectPath));
auto project = Project::New();
auto projectFileData = FileSystem::ReadFile(projectPath, true);
try
{
project->Deserialize(json::parse(projectFileData));
project->FullPath = projectPath;
Engine::LoadProject(project);
filesystem->m_CurrentDirectory = Nuake::FileSystem::RootDirectory;
}
catch (std::exception exception)
{
Logger::Log("Error loading project: " + projectPath, "editor", CRITICAL);
Logger::Log(exception.what());
return false;
}
return true;
}
}