Browse Source

Project: remember the basepath

master
gradient 8 years ago
parent
commit
6d8094d8dd
2 changed files with 5 additions and 1 deletions
  1. +4
    -1
      src/project.cpp
  2. +1
    -0
      src/project.h

+ 4
- 1
src/project.cpp View File

@ -4,12 +4,15 @@
std::unique_ptr<Project> Project::fromFile(std::string path) { std::unique_ptr<Project> Project::fromFile(std::string path) {
auto manifest = cpptoml::parse_file(path); auto manifest = cpptoml::parse_file(path);
auto basepath = filesystem::path(path).parent_path().make_absolute(); auto basepath = filesystem::path(path).parent_path().make_absolute();
return Project::fromToml(manifest, basepath);
auto project = Project::fromToml(manifest, basepath);
return project;
} }
std::unique_ptr<Project> Project::fromToml(std::shared_ptr<cpptoml::table> manifest, std::unique_ptr<Project> Project::fromToml(std::shared_ptr<cpptoml::table> manifest,
filesystem::path basepath = filesystem::path(".")) { filesystem::path basepath = filesystem::path(".")) {
auto project = Project(); auto project = Project();
project.basepath = basepath;
project.name = manifest->get_qualified_as<std::string>("project.name").value_or(""); project.name = manifest->get_qualified_as<std::string>("project.name").value_or("");
project.shader_bundle = std::move(std::make_shared<ShaderBundle>()); project.shader_bundle = std::move(std::make_shared<ShaderBundle>());


+ 1
- 0
src/project.h View File

@ -35,6 +35,7 @@ public:
std::shared_ptr<Scene> current_scene; std::shared_ptr<Scene> current_scene;
bool scene_loaded = false; bool scene_loaded = false;
std::string name; std::string name;
filesystem::path basepath;
std::shared_ptr<ShaderBundle> shader_bundle; std::shared_ptr<ShaderBundle> shader_bundle;
}; };

Loading…
Cancel
Save