当前位置: 首页>>代码示例>>C++>>正文


C++ ConfigReader::getKey方法代码示例

本文整理汇总了C++中ConfigReader::getKey方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigReader::getKey方法的具体用法?C++ ConfigReader::getKey怎么用?C++ ConfigReader::getKey使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConfigReader的用法示例。


在下文中一共展示了ConfigReader::getKey方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: init

bool Config::init(const fs::path & file) {
	
	fs::ifstream ifs;
	ifs.open(file);
	bool loaded = ifs.is_open();
	
	ConfigReader reader;
	
	if(!reader.read(ifs)) {
		LogWarning << "Errors while parsing config file";
	}
	
	// Get locale language
	language = reader.getKey(Section::Language, Key::language, Default::language);
	
	// Get video settings
	string resolution = reader.getKey(Section::Video, Key::resolution, Default::resolution);
	if(resolution == "auto") {
		video.resolution = Vec2i_ZERO;
	} else {
		video.resolution = parseResolution(resolution);
	}
	video.bpp = reader.getKey(Section::Video, Key::bpp, Default::bpp);
	video.fullscreen = reader.getKey(Section::Video, Key::fullscreen, Default::fullscreen);
	video.levelOfDetail = reader.getKey(Section::Video, Key::levelOfDetail, Default::levelOfDetail);
	video.fogDistance = reader.getKey(Section::Video, Key::fogDistance, Default::fogDistance);
	video.showCrosshair = reader.getKey(Section::Video, Key::showCrosshair, Default::showCrosshair);
	video.antialiasing = reader.getKey(Section::Video, Key::antialiasing, Default::antialiasing);
	video.vsync = reader.getKey(Section::Video, Key::vsync, Default::vsync);
	
	// Get window settings
	string windowSize = reader.getKey(Section::Window, Key::windowSize, Default::windowSize);
	window.size = parseResolution(windowSize);
	window.framework = reader.getKey(Section::Window, Key::windowFramework, Default::windowFramework);
	
	// Get audio settings
	audio.volume = reader.getKey(Section::Audio, Key::volume, Default::volume);
	audio.sfxVolume = reader.getKey(Section::Audio, Key::sfxVolume, Default::sfxVolume);
	audio.speechVolume = reader.getKey(Section::Audio, Key::speechVolume, Default::speechVolume);
	audio.ambianceVolume = reader.getKey(Section::Audio, Key::ambianceVolume, Default::ambianceVolume);
	audio.eax = reader.getKey(Section::Audio, Key::eax, Default::eax);
	audio.backend = reader.getKey(Section::Audio, Key::audioBackend, Default::audioBackend);
	
	// Get input settings
	input.invertMouse = reader.getKey(Section::Input, Key::invertMouse, Default::invertMouse);
	input.autoReadyWeapon = reader.getKey(Section::Input, Key::autoReadyWeapon, Default::autoReadyWeapon);
	input.mouseLookToggle = reader.getKey(Section::Input, Key::mouseLookToggle, Default::mouseLookToggle);
	input.mouseSensitivity = reader.getKey(Section::Input, Key::mouseSensitivity, Default::mouseSensitivity);
	input.autoDescription = reader.getKey(Section::Input, Key::autoDescription, Default::autoDescription);
	input.linkMouseLookToUse = reader.getKey(Section::Input, Key::linkMouseLookToUse, Default::linkMouseLookToUse);
	input.backend = reader.getKey(Section::Input, Key::inputBackend, Default::inputBackend);
	
	// Get action key settings
	for(size_t i = 0; i < NUM_ACTION_KEY; i++) {
		actions[i] = reader.getActionKey(Section::Key, (ControlAction)i);
	}
	
	// Get miscellaneous settings
	misc.forceToggle = reader.getKey(Section::Misc, Key::forceToggle, Default::forceToggle);
	misc.migration = (MigrationStatus)reader.getKey(Section::Misc, Key::migration, Default::migration);
	misc.quicksaveSlots = std::max(reader.getKey(Section::Misc, Key::quicksaveSlots, Default::quicksaveSlots), 1);
	misc.debug = reader.getKey(Section::Misc, Key::debugLevels, Default::debugLevels);
	
	return loaded;
}
开发者ID:EstrangedGames,项目名称:ArxLibertatis,代码行数:65,代码来源:Config.cpp


注:本文中的ConfigReader::getKey方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。