diff --git a/src/main.cpp b/src/main.cpp index c7e8dbc..d00ac5c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -68,7 +68,7 @@ int main(int argc, char* argv[]) { auto gui = Gui(&state); if (argc == 2) { - auto proj = std::make_shared(Project::fromFile(std::string(argv[1]))); + auto proj = std::make_shared(Project::from_file(std::string(argv[1]))); inotify.watch(proj); state.current_project = std::move(proj); } diff --git a/src/project.cpp b/src/project.cpp index 2cbe430..ea453f1 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -1,19 +1,15 @@ #include "project.h" #include -Project Project::fromFile(std::string path) { - return Project::fromFile(fs::path(path)); -} - -Project Project::fromFile(fs::path path) { +Project Project::from_file(fs::path path) { auto manifest = cpptoml::parse_file(path); auto basepath = fs::absolute(path).parent_path(); - auto project = Project::fromToml(manifest, basepath); + auto project = Project::from_toml(manifest, basepath); return project; } -Project Project::fromToml(std::shared_ptr manifest, +Project Project::from_toml(std::shared_ptr manifest, fs::path basepath = fs::path(".")) { auto project = Project(); project.basepath = basepath; diff --git a/src/project.h b/src/project.h index 6cd1bca..cc0515f 100644 --- a/src/project.h +++ b/src/project.h @@ -24,9 +24,8 @@ class Project { public: Project() = default; - static Project fromFile(std::string path); - static Project fromFile(fs::path path); - static Project fromToml(std::shared_ptr manifest, fs::path basepath); + static Project from_file(fs::path path); + static Project from_toml(std::shared_ptr manifest, fs::path basepath); void load_scene(std::shared_ptr scene); void reload_shaders(); diff --git a/src/state.h b/src/state.h index 653e225..a935845 100644 --- a/src/state.h +++ b/src/state.h @@ -2,11 +2,19 @@ #include #include +#include #include #include "project.h" +namespace fs = std::experimental::filesystem; + struct Config { - static Config from_file(std::string path) { + /*static Config find(std::string filename) { + fs::path searchdir = "."; + + return Config::from_file(path); + }*/ + static Config from_file(fs::path path) { auto manifest = cpptoml::parse_file(path); return Config::from_toml(manifest); } @@ -31,4 +39,4 @@ struct DemoState { std::shared_ptr config; bool running; -}; \ No newline at end of file +};