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

@@ -112,7 +112,7 @@ int ApplicationMain(int argc, char* argv[])
using namespace Nuake;
// Parse launch arguments
const auto arguments = ParseArguments(argc, argv);
const auto& arguments = ParseArguments(argc, argv);
LaunchSettings launchSettings = ParseLaunchSettings(arguments);
#ifdef NK_DEBUG
@@ -133,29 +133,11 @@ int ApplicationMain(int argc, char* argv[])
// Initialize Editor
Nuake::EditorInterface editor;
editor.BuildFonts();
// Load project in argument
if (!launchSettings.projectPath.empty())
{
FileSystem::SetRootDirectory(FileSystem::GetParentPath(launchSettings.projectPath));
auto project = Project::New();
auto projectFileData = FileSystem::ReadFile(launchSettings.projectPath, true);
try
{
project->Deserialize(json::parse(projectFileData));
project->FullPath = launchSettings.projectPath;
Engine::LoadProject(project);
editor.filesystem->m_CurrentDirectory = Nuake::FileSystem::RootDirectory;
}
catch (std::exception exception)
{
Logger::Log("Error loading project: " + launchSettings.projectPath, "editor", CRITICAL);
Logger::Log(exception.what());
}
editor.LoadProject(launchSettings.projectPath);
}
// Start application main loop