Better logger and project launch arg fixed

This commit is contained in:
Antoine Pilote
2024-08-09 19:11:46 -04:00
parent c48441e0db
commit 0930d4d3f4
5 changed files with 49 additions and 12 deletions

View File

@@ -16,7 +16,35 @@ void EditorApplication::OnInit()
m_Window = Engine::GetCurrentWindow();
m_Window->SetSize({ m_Specification.WindowWidth, m_Specification.WindowHeight });
m_Window->SetTitle(m_Specification.Name);
m_Window->SetMonitor(1);
if (!m_LaunchSettings.projectPath.empty())
{
if (FileSystem::FileExists(m_LaunchSettings.projectPath, true))
{
const std::string projectPath = m_LaunchSettings.projectPath;
FileSystem::SetRootDirectory(FileSystem::GetParentPath(projectPath));
auto project = Project::New();
auto projectFileData = FileSystem::ReadFile(projectPath, true);
Logger::Log("Reading file project: " + projectFileData, "window", VERBOSE);
try
{
Logger::Log("Starting deserializing", "window", VERBOSE);
project->Deserialize(json::parse(projectFileData));
project->FullPath = projectPath;
Engine::LoadProject(project);
}
catch (std::exception exception)
{
Logger::Log("Error loading project: " + projectPath, "editor", CRITICAL);
Logger::Log(exception.what());
}
}
}
PushLayer(CreateScope<EditorLayer>());
}