From dcc473f603d265d824e0c3450121966c08782c5d Mon Sep 17 00:00:00 2001 From: gradient Date: Mon, 29 May 2017 11:47:43 -0500 Subject: [PATCH] Add demo state and config loading --- src/state.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/state.h diff --git a/src/state.h b/src/state.h new file mode 100644 index 0000000..653e225 --- /dev/null +++ b/src/state.h @@ -0,0 +1,34 @@ +#pragma once + +#include +#include +#include +#include "project.h" + +struct Config { + static Config from_file(std::string path) { + auto manifest = cpptoml::parse_file(path); + return Config::from_toml(manifest); + } + static Config from_toml(std::shared_ptr manifest) { + auto config = Config(); + config.stylepath = manifest->get_as("style").value_or(""); + + return config; + } + + std::string stylepath; +}; + +struct DemoState { + DemoState(std::shared_ptr config) + : running(true), current_project(nullptr), + config(config) {} + + int width, height; float ratio; + + std::shared_ptr current_project; + std::shared_ptr config; + + bool running; +}; \ No newline at end of file