 |
Cytopia
0.3
A city building simulation game
|
Go to the documentation of this file.
22 if (localJsonObject.empty() || localJsonObject.is_discarded())
27 if (cachedJsonObject.empty() || cachedJsonObject.is_discarded())
29 settingsData = localJsonObject;
33 int cacheVersion = cachedJsonObject.value(
"SettingsVersion", -1);
34 int localVersion = localJsonObject.value(
"SettingsVersion", -1);
35 if (localVersion <= cacheVersion)
37 settingsData = cachedJsonObject;
41 LOG(
LOG_INFO) <<
"The settings file version has changed. Overwriting local cached settings file with default settings.";
59 const json settingsJsonObject = *
this;
63 LOG(
LOG_ERROR) <<
"CYTOPIA_DATA_DIR_BASE is not set! Please report this issue on github. Falling back to cytopia base dir.";
77 json settingsJSONObject;
82 settingsJSONObject = json::parse(jsonFile,
nullptr,
false);
85 return settingsJSONObject;
93 if (localJsonObject.empty() || localJsonObject.is_discarded())
97 settingsData = localJsonObject;
bool fileExists(const std::string &filePath)
Check if a file (or folder) exists.
void writeStringToFile(const std::string &fileName, const std::string &stringToWrite, bool binaryMode)
Write a string to a file.
void writeFile()
Save settings to file.
ScreenDimension screenHeight
the screen height
int subMenuButtonWidth
The width in pixels of the buttons used in the build sub menues on the UI.
const std::string CYTOPIA_RESOURCES_DIR
json parseSettingsFile(const std::string &fileName) const
std::string readFileAsString(const std::string &fileName, bool binaryMode)
Read contents from a file as string.
ScreenDimension screenWidth
the screen width
std::string getBasePath()
Get base path (where Cytopia is being run)
ScreenDimension currentScreenWidth
the actual screen width (can differ from the one that's set in borderless fullscreen)
int subMenuButtonHeight
The height in pixels of the buttons used in the build sub menues on the UI.
const std::string SETTINGS_FILENAME
void createDirectory(const std::string &dir)
void resetSettingsToDefaults()
Reset settings to defaults from local settings file.
const std::string CYTOPIA_DATA_DIR
ScreenDimension currentScreenHeight
the actual screen height (can differ from the one that's set in borderless fullscreen)
const std::string CYTOPIA_DATA_DIR_BASE
void readFile()
Load settings from file.