示例#1
0
template<> XmlNode NodeCreator<Text>::createNodeFromObject(const Text& t) {
	XmlNode n("text");
	n.addChild(XmlNode("id", boost::lexical_cast<std::string>(t.getId())));
	XmlNode textMap("textMap");
	for(std::map<const boost::uuids::uuid, const std::string>::const_iterator i = t.getTextMap().begin(); i != t.getTextMap().end(); i++) {
		XmlNode entry("entry");
		entry.addChild(XmlNode("id", boost::lexical_cast<std::string>(i->first)));
		entry.addChild(XmlNode("value", boost::lexical_cast<std::string>(i->second)));
		textMap.addChild(entry);
	}
	n.addChild(textMap);
	return n;
}
示例#2
0
std::unique_ptr<Options> OptionsParser::parse()
{
	// Path to the options file.
	std::string fullPath(OptionsParser::PATH + OptionsParser::FILENAME);

	// Read in all the key-value pairs from the options file.
	KvpTextMap textMap(fullPath);
	
	// Graphics.
	int screenWidth = textMap.getInteger(OptionsParser::SCREEN_WIDTH_KEY);
	int screenHeight = textMap.getInteger(OptionsParser::SCREEN_HEIGHT_KEY);
	bool fullscreen = textMap.getBoolean(OptionsParser::FULLSCREEN_KEY);
	double resolutionScale = textMap.getDouble(OptionsParser::RESOLUTION_SCALE_KEY);
	double verticalFOV = textMap.getDouble(OptionsParser::VERTICAL_FOV_KEY);
	double letterboxAspect = textMap.getDouble(OptionsParser::LETTERBOX_ASPECT_KEY);
	double cursorScale = textMap.getDouble(OptionsParser::CURSOR_SCALE_KEY);

	// Input.
	double hSensitivity = textMap.getDouble(OptionsParser::H_SENSITIVITY_KEY);
	double vSensitivity = textMap.getDouble(OptionsParser::V_SENSITIVITY_KEY);

    // Sound.
    double musicVolume = textMap.getDouble(OptionsParser::MUSIC_VOLUME_KEY);
    double soundVolume = textMap.getDouble(OptionsParser::SOUND_VOLUME_KEY);
	std::string soundfont = textMap.getString(OptionsParser::SOUNDFONT_KEY);
    int soundChannels = textMap.getInteger(OptionsParser::SOUND_CHANNELS_KEY);

	// Miscellaneous.
	std::string arenaPath = textMap.getString(OptionsParser::ARENA_PATH_KEY);
	bool skipIntro = textMap.getBoolean(OptionsParser::SKIP_INTRO_KEY);
	
	return std::unique_ptr<Options>(new Options(std::move(arenaPath),
		screenWidth, screenHeight, fullscreen, resolutionScale, verticalFOV,
		letterboxAspect, cursorScale, hSensitivity, vSensitivity, std::move(soundfont), 
		musicVolume, soundVolume, soundChannels, skipIntro));
}