| 10 | #include "Nuake/Modules/ModuleDB.h" |
| 11 | |
| 12 | void EditorApplication::OnInit() |
| 13 | { |
| 14 | using namespace Nuake; |
| 15 | Engine::Init(); |
| 16 | |
| 17 | // Register bakers, these can convert files into nuake resources |
| 18 | if (m_LaunchSettings.generateBindings) |
| 19 | { |
| 20 | ModuleDB::Get().GenerateModuleAPI(); |
| 21 | |
| 22 | Logger::Log("Generated Bindings"); |
| 23 | m_Window->Close(); |
| 24 | return; |
| 25 | } |
| 26 | |
| 27 | m_Window = Engine::GetCurrentWindow(); |
| 28 | m_Window->SetSize({ m_Specification.WindowWidth, m_Specification.WindowHeight }); |
| 29 | m_Window->SetTitle(m_Specification.Name); |
| 30 | //m_Window->SetMonitor(1); |
| 31 | |
| 32 | if (!m_LaunchSettings.projectPath.empty()) |
| 33 | { |
| 34 | if (FileSystem::FileExists(m_LaunchSettings.projectPath, true)) |
| 35 | { |
| 36 | const std::string projectPath = m_LaunchSettings.projectPath; |
| 37 | |
| 38 | FileSystem::SetRootDirectory(FileSystem::GetParentPath(projectPath)); |
| 39 | |
| 40 | auto project = Project::New(); |
| 41 | auto projectFileData = FileSystem::ReadFile(projectPath, true); |
| 42 | Logger::Log("Reading file project: " + projectFileData, "window", VERBOSE); |
| 43 | try |
| 44 | { |
| 45 | Logger::Log("Starting deserializing", "window", VERBOSE); |
| 46 | project->Deserialize(json::parse(projectFileData)); |
| 47 | project->FullPath = projectPath; |
| 48 | |
| 49 | Engine::LoadProject(project); |
| 50 | } |
| 51 | catch (std::exception exception) |
| 52 | { |
| 53 | Logger::Log("Error loading project: " + projectPath, "editor", CRITICAL); |
| 54 | Logger::Log(exception.what()); |
| 55 | } |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | m_Window->SetOnWindowFocusedCallback([&](Window& window, bool focused) |
| 60 | { |
| 61 | if (!focused) |
| 62 | { |
| 63 | return; |
| 64 | } |
| 65 | |
| 66 | for (auto& layer : m_LayerStack) |
| 67 | { |
| 68 | layer->OnWindowFocused(); |
| 69 | } |
nothing calls this directly
no test coverage detected