bool Config::loadGameConfig(const std::string &pGameId) { std::string iniFileNameFull = getGameConfigFile(pGameId); if (!hasGameConfig(pGameId)) { INFO_LOG(LOADER, "Failed to read %s. No game-specific settings found, using global defaults.", iniFileNameFull.c_str()); return false; } changeGameSpecific(pGameId); IniFile iniFile; iniFile.Load(iniFileNameFull); for (size_t i = 0; i < ARRAY_SIZE(sections); ++i) { IniFile::Section *section = iniFile.GetOrCreateSection(sections[i].section); for (auto setting = sections[i].settings; setting->HasMore(); ++setting) { if (setting->perGame_){ setting->Get(section); } } } KeyMap::LoadFromIni(iniFile); return true; }
bool Config::deleteGameConfig(const std::string& pGameId) { std::string fullIniFilePath = getGameConfigFile(pGameId); File::Delete(fullIniFilePath); return true; }
bool Config::saveGameConfig(const std::string &pGameId) { if (pGameId.empty()) { return false; } std::string fullIniFilePath = getGameConfigFile(pGameId); IniFile iniFile; for (size_t i = 0; i < ARRAY_SIZE(sections); ++i) { IniFile::Section *section = iniFile.GetOrCreateSection(sections[i].section); for (auto setting = sections[i].settings; setting->HasMore(); ++setting) { if (setting->perGame_){ setting->Set(section); } } } KeyMap::SaveToIni(iniFile); iniFile.Save(fullIniFilePath); return true; }
bool Config::hasGameConfig(const std::string &pGameId) { std::string fullIniFilePath = getGameConfigFile(pGameId); IniFile existsCheck; bool exists = existsCheck.Load(fullIniFilePath); return exists; }
bool Config::createGameConfig(const std::string &pGameId) { std::string fullIniFilePath = getGameConfigFile(pGameId); if (hasGameConfig(pGameId)) { return false; } File::CreateEmptyFile(fullIniFilePath); return true; }
bool Config::saveGameConfig(const std::string &pGameId) { if (pGameId.empty()) { return false; } std::string fullIniFilePath = getGameConfigFile(pGameId); IniFile iniFile; IterateSettings(iniFile, [](IniFile::Section *section, ConfigSetting *setting) { if (setting->perGame_) { setting->Set(section); } }); KeyMap::SaveToIni(iniFile); iniFile.Save(fullIniFilePath); return true; }
bool Config::loadGameConfig(const std::string &pGameId) { std::string iniFileNameFull = getGameConfigFile(pGameId); if (!hasGameConfig(pGameId)) { INFO_LOG(LOADER, "Failed to read %s. No game-specific settings found, using global defaults.", iniFileNameFull.c_str()); return false; } changeGameSpecific(pGameId); IniFile iniFile; iniFile.Load(iniFileNameFull); IterateSettings(iniFile, [](IniFile::Section *section, ConfigSetting *setting) { if (setting->perGame_) { setting->Get(section); } }); KeyMap::LoadFromIni(iniFile); return true; }
bool Config::hasGameConfig(const std::string &pGameId) { std::string fullIniFilePath = getGameConfigFile(pGameId); return File::Exists(fullIniFilePath); }