mirror of
https://github.com/sebastiandine/Card-Collection-Manager-3.git
synced 2026-09-01 21:01:31 +00:00
25 lines
723 B
C++
25 lines
723 B
C++
#include "ccm/domain/Configuration.hpp"
|
|
|
|
namespace ccm {
|
|
|
|
void to_json(nlohmann::json& j, const Configuration& c) {
|
|
j = nlohmann::json{
|
|
{"dataStorage", c.dataStorage},
|
|
{"defaultGame", c.defaultGame},
|
|
{"theme", c.theme},
|
|
};
|
|
}
|
|
|
|
void from_json(const nlohmann::json& j, Configuration& c) {
|
|
j.at("dataStorage").get_to(c.dataStorage);
|
|
j.at("defaultGame").get_to(c.defaultGame);
|
|
// JapanesePokemon was folded into Pokemon (West/Asia region). Coerce so
|
|
// older config.json files keep a valid user-facing default game.
|
|
if (c.defaultGame == Game::JapanesePokemon) {
|
|
c.defaultGame = Game::Pokemon;
|
|
}
|
|
c.theme = j.value("theme", Theme::Light);
|
|
}
|
|
|
|
} // namespace ccm
|