Browse Source

fix a few method names

master
gradient 8 years ago
parent
commit
7a311095c3
4 changed files with 16 additions and 13 deletions
  1. +1
    -1
      src/main.cpp
  2. +3
    -7
      src/project.cpp
  3. +2
    -3
      src/project.h
  4. +10
    -2
      src/state.h

+ 1
- 1
src/main.cpp View File

@ -68,7 +68,7 @@ int main(int argc, char* argv[]) {
auto gui = Gui(&state); auto gui = Gui(&state);
if (argc == 2) { if (argc == 2) {
auto proj = std::make_shared<Project>(Project::fromFile(std::string(argv[1])));
auto proj = std::make_shared<Project>(Project::from_file(std::string(argv[1])));
inotify.watch(proj); inotify.watch(proj);
state.current_project = std::move(proj); state.current_project = std::move(proj);
} }


+ 3
- 7
src/project.cpp View File

@ -1,19 +1,15 @@
#include "project.h" #include "project.h"
#include <iostream> #include <iostream>
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 manifest = cpptoml::parse_file(path);
auto basepath = fs::absolute(path).parent_path(); auto basepath = fs::absolute(path).parent_path();
auto project = Project::fromToml(manifest, basepath);
auto project = Project::from_toml(manifest, basepath);
return project; return project;
} }
Project Project::fromToml(std::shared_ptr<cpptoml::table> manifest,
Project Project::from_toml(std::shared_ptr<cpptoml::table> manifest,
fs::path basepath = fs::path(".")) { fs::path basepath = fs::path(".")) {
auto project = Project(); auto project = Project();
project.basepath = basepath; project.basepath = basepath;


+ 2
- 3
src/project.h View File

@ -24,9 +24,8 @@ class Project {
public: public:
Project() = default; Project() = default;
static Project fromFile(std::string path);
static Project fromFile(fs::path path);
static Project fromToml(std::shared_ptr<cpptoml::table> manifest, fs::path basepath);
static Project from_file(fs::path path);
static Project from_toml(std::shared_ptr<cpptoml::table> manifest, fs::path basepath);
void load_scene(std::shared_ptr<Scene> scene); void load_scene(std::shared_ptr<Scene> scene);
void reload_shaders(); void reload_shaders();


+ 10
- 2
src/state.h View File

@ -2,11 +2,19 @@
#include <string> #include <string>
#include <memory> #include <memory>
#include <experimental/filesystem>
#include <cpptoml.h> #include <cpptoml.h>
#include "project.h" #include "project.h"
namespace fs = std::experimental::filesystem;
struct Config { 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); auto manifest = cpptoml::parse_file(path);
return Config::from_toml(manifest); return Config::from_toml(manifest);
} }
@ -31,4 +39,4 @@ struct DemoState {
std::shared_ptr<Config> config; std::shared_ptr<Config> config;
bool running; bool running;
};
};

Loading…
Cancel
Save