Пример #1
0
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;
}
Пример #2
0
bool Config::deleteGameConfig(const std::string& pGameId)
{
	std::string fullIniFilePath = getGameConfigFile(pGameId);

	File::Delete(fullIniFilePath);
	return true;
}
Пример #3
0
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;
}
Пример #4
0
bool Config::hasGameConfig(const std::string &pGameId)
{
	std::string fullIniFilePath = getGameConfigFile(pGameId);

	IniFile existsCheck;
	bool exists = existsCheck.Load(fullIniFilePath);
	return exists;
}
Пример #5
0
bool Config::createGameConfig(const std::string &pGameId) {
	std::string fullIniFilePath = getGameConfigFile(pGameId);

	if (hasGameConfig(pGameId)) {
		return false;
	}

	File::CreateEmptyFile(fullIniFilePath);

	return true;
}
Пример #6
0
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;
}
Пример #7
0
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;
}
Пример #8
0
bool Config::hasGameConfig(const std::string &pGameId)
{
	std::string fullIniFilePath = getGameConfigFile(pGameId);
	return File::Exists(fullIniFilePath);
}