63 lines
1.2 KiB
C++
63 lines
1.2 KiB
C++
#ifndef Configuration_h_
|
|
#define Configuration_h_
|
|
|
|
#include "json/json.hpp"
|
|
|
|
#include "filesystem.hpp"
|
|
#include "Node.hpp"
|
|
|
|
struct Configuration : Node
|
|
{
|
|
nlohmann::json sys_config, game_config, config;
|
|
fs::path config_path;
|
|
int tab_width = 4;
|
|
|
|
Configuration(Node*);
|
|
Configuration(Node*, fs::path);
|
|
void set_defaults();
|
|
void load();
|
|
void load(fs::path path);
|
|
void merge();
|
|
void write();
|
|
void write(fs::path path);
|
|
virtual std::string class_name() const { return "Configuration"; }
|
|
|
|
};
|
|
|
|
namespace glm
|
|
{
|
|
template <typename T>
|
|
void to_json(nlohmann::json& j, const vec<2, T, defaultp>& v)
|
|
{
|
|
j = nlohmann::json{v.x, v.y};
|
|
}
|
|
|
|
template <typename T>
|
|
void from_json(const nlohmann::json& j, vec<2, T, defaultp>& v)
|
|
{
|
|
j.at(0).get_to(v.x);
|
|
j.at(1).get_to(v.y);
|
|
}
|
|
}
|
|
|
|
#if defined(__MINGW32__)
|
|
namespace std::experimental::filesystem
|
|
#else
|
|
namespace std::filesystem
|
|
#endif
|
|
{
|
|
template <typename T>
|
|
void to_json(nlohmann::json& j, const path& p)
|
|
{
|
|
j = nlohmann::json{p};
|
|
}
|
|
|
|
template <typename T>
|
|
void from_json(const nlohmann::json& j, path& p)
|
|
{
|
|
j.at(0).get_to(p);
|
|
}
|
|
}
|
|
|
|
#endif
|