43 lines
1.1 KiB
C++
43 lines
1.1 KiB
C++
#include "config.h"
|
|
|
|
using namespace std;
|
|
|
|
Config::Config(string filename)
|
|
{
|
|
fstream configFile;
|
|
configFile.open(filename, ios::in);
|
|
|
|
if (!configFile)
|
|
{
|
|
cout << "Config file is not exit\n";
|
|
if (this->genDefConf())
|
|
return;
|
|
else
|
|
cout << "Config file was generated\n";
|
|
}
|
|
|
|
configFile >> this->jsonConfig;
|
|
|
|
if(this->jsonConfig["window"]["size"].type() == Json::intValue
|
|
and this->jsonConfig["window"]["size"].asInt() == -1)
|
|
|
|
{
|
|
this->sdlOption = SDL_WINDOW_FULLSCREEN_DESKTOP;
|
|
}
|
|
else if(this->jsonConfig["window"]["size"].type() == Json::arrayValue
|
|
and this->jsonConfig["window"]["size"].size() == 2
|
|
and this->jsonConfig["window"]["size"][0].type() == Json::intValue
|
|
and this->jsonConfig["window"]["size"][1].type() == Json::intValue)
|
|
|
|
{
|
|
this->width = max(this->jsonConfig["window"]["size"][0].asInt(),100);
|
|
this->height = max(this->jsonConfig["window"]["size"][1].asInt(),100);
|
|
}
|
|
else
|
|
cout << "Not correct config file.\n";
|
|
}
|
|
|
|
int Config::genDefConf()
|
|
{
|
|
return 0;
|
|
} |