Hi,
I've updated the json library from 3.1.2 to 3.6.1. Mostly because after upgrading to C++17, clang-7 failed to build and i found an issue which seemed to be fixed in the newer version.
cannot convert from 'const json' to 'SettingsData'
cannot convert from 'initializer list' to 'json'
And i get this error directly from the json library:
Error (active) E0493 no instance of overloaded function "std::swap" matches the specified type Cytopia C:\Projekte\Cytopia\Cytopia\src\ThirdParty\json.hxx 17771
Now, my build fails when writing a json object, read from a file (from_json) back to a struct variable:
std::string settingsFileName = SDL_GetBasePath();
settingsFileName.append(SETTINGS_FILE_NAME);
std::ifstream i(settingsFileName);
if (i.fail())
{
LOG(LOG_ERROR) << "File " << SETTINGS_FILE_NAME << " does not exist! Cannot load settings from INI File!";
// Application should quit here, without settings from the ini file we can't continue
return;
}
// check if json file can be parsed
const json _settingsJSONObject = json::parse(i, nullptr, false);
if (_settingsJSONObject.is_discarded())
{
LOG(LOG_ERROR) << "Error parsing JSON File " << SETTINGS_FILE_NAME;
}
SettingsData data = _settingsJSONObject;
and the from_json function:
// JSON deserializer for Settings struct
void from_json(const json &j, SettingsData &s)
{
s.screenWidth = j["Graphics"]["Resolution"].value("Screen_Width", 800);
s.screenHeight = j["Graphics"]["Resolution"].value("Screen_Height", 600);
s.vSync = j["Graphics"].value("VSYNC", false);
s.fullScreen = j["Graphics"].value("FullScreen", false);
s.fullScreenMode = j["Graphics"].value("FullScreenMode", 0);
s.mapSize = j["Game"].value("MapSize", 64);
s.maxElevationHeight = j["Game"].value("MaxElevationHeight", 32);
s.uiDataJSONFile = j["ConfigFiles"].value("UIDataJSONFile", "resources/data/TileData.json");
s.tileDataJSONFile = j["ConfigFiles"].value("TileDataJSONFile", "resources/data/UIData.json");
s.uiLayoutJSONFile = j["ConfigFiles"].value("UILayoutJSONFile", "resources/data/UILayout.json");
s.playMusic = j["Audio"].value("PlayMusic", true);
s.playSoundEffects = j["Audio"].value("PlaySoundEffects", false);
s.audioChannels = j["Audio"].value("AudioChannels", 2);
s.musicVolume = j["Audio"].value("MusicVolume", static_cast<uint8_t>(50));
s.soundEffectsVolume = j["Audio"].value("SoundEffectsVolume", static_cast<uint8_t>(100));
s.buildMenuPosition = j["User Interface"].value("BuildMenu Position", "BOTTOM");
}
I haven't commited the new json library because it fails to compile, but if you want to take a look at the code, it's this specific branch:
https://github.com/JimmySnails/Cytopia/tree/uiImprovements
and here's one of the files i use it:
https://github.com/JimmySnails/Cytopia/blob/uiImprovements/src/engine/basics/Settings.cxx
I use it the same way throughout my project and all fail the same way..
Can you help me out here, please?
Hi,
I've updated the json library from 3.1.2 to 3.6.1. Mostly because after upgrading to C++17, clang-7 failed to build and i found an issue which seemed to be fixed in the newer version.
cannot convert from 'const json' to 'SettingsData'cannot convert from 'initializer list' to 'json'And i get this error directly from the json library:
Now, my build fails when writing a json object, read from a file (from_json) back to a struct variable:
and the from_json function:
I haven't commited the new json library because it fails to compile, but if you want to take a look at the code, it's this specific branch:
https://github.com/JimmySnails/Cytopia/tree/uiImprovements
and here's one of the files i use it:
https://github.com/JimmySnails/Cytopia/blob/uiImprovements/src/engine/basics/Settings.cxx
I use it the same way throughout my project and all fail the same way..
Can you help me out here, please?