Browse Source

Add demo state and config loading

master
gradient 8 years ago
parent
commit
dcc473f603
1 changed files with 34 additions and 0 deletions
  1. +34
    -0
      src/state.h

+ 34
- 0
src/state.h View File

@ -0,0 +1,34 @@
#pragma once
#include <string>
#include <memory>
#include <cpptoml.h>
#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<cpptoml::table> manifest) {
auto config = Config();
config.stylepath = manifest->get_as<std::string>("style").value_or("");
return config;
}
std::string stylepath;
};
struct DemoState {
DemoState(std::shared_ptr<Config> config)
: running(true), current_project(nullptr),
config(config) {}
int width, height; float ratio;
std::shared_ptr<Project> current_project;
std::shared_ptr<Config> config;
bool running;
};

Loading…
Cancel
Save