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

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;
}
}

View File

@@ -61,6 +61,7 @@ namespace Nuake
bool ShouldDrawAxis() const { return m_DrawAxis; }
bool ShouldDrawCollision() const { return m_DebugCollisions; }
bool LoadProject(const std::string& projectPath);
private:
std::string GetEntityTypeName(const Entity& entity) const;

View File

@@ -68,10 +68,15 @@ project "Freetype"
filter "configurations:Debug"
files { "freetype/src/base/ftdebug.c" }
runtime "Debug"
symbols "on"
runtime "Debug"
symbols "on"
filter "configurations:Release"
files { "freetype/src/base/ftdebug.c" }
runtime "Release"
optimize "on"
runtime "Release"
optimize "on"
filter "configurations:Dist"
files { "freetype/src/base/ftdebug.c" }
runtime "Release"
optimize "on"

View File

@@ -36,6 +36,11 @@ project 'JoltPhysics'
symbols "on"
filter "configurations:Release"
cppdialect "C++17"
runtime "Release"
optimize "on"
filter "configurations:Dist"
cppdialect "C++17"
runtime "Release"
optimize "on"