Example #1
0
 BoolPair operator () (int i, int j) { return BoolPair(this,i,j); }
Example #2
0
void Cutscene::loadFromFile(std::string file){
	tinyxml2::XMLDocument doc;
	doc.LoadFile(file.c_str());

	mMusic = doc.FirstChildElement("Cutscene")->Attribute("music");
	tinyxml2::XMLElement* env = doc.FirstChildElement("Cutscene")->FirstChildElement("Enviroment");
	while(env != 0){

		tinyxml2::XMLElement* sce = env->FirstChildElement("Scene");

		std::vector<Scene*> scenes;

		while(sce != 0){
			std::vector<std::pair<sf::Text,float>> texts;
			tinyxml2::XMLElement* elmText = sce->FirstChildElement("Text");

			while(elmText != 0){
				sf::Text text;
				text.setString(elmText->GetText());
				float tx = elmText->FloatAttribute("x");
				float ty = elmText->FloatAttribute("y");
				text.setPosition(tx,ty);
				text.setFont(FontMaster::sFont);
				float duration = elmText->FloatAttribute("duration");
				texts.push_back(std::pair<sf::Text,float>(text,duration));
				elmText = elmText->NextSiblingElement("Text");
			}

			std::string voice = sce->FirstChildElement("Voice")->Attribute("file");

			float duration = sce->FloatAttribute("duration");

			std::vector<std::pair<sf::Sprite*,std::pair<bool,bool>>> sprites;
			tinyxml2::XMLElement* img = sce->FirstChildElement("Image");

			while(img != 0){
				std::string texString = img->Attribute("texture");
				sf::Texture* tex = ResourceManager::getInst().getTexture(texString);
				sf::Sprite* sprite = new sf::Sprite(*tex);
				float sx = img->FloatAttribute("x");
				float sy = img->FloatAttribute("y");
				sprite->setPosition(sx,sy);
				bool fadeIn = img->BoolAttribute("fadeIn");
				bool fadeOut = img->BoolAttribute("fadeOut");

				if(fadeIn){
					sprite->setColor(sf::Color(255,255,255,0));
				}

				sprites.push_back(std::pair<sf::Sprite*,BoolPair>(sprite,BoolPair(fadeIn,fadeOut)));
				img = img->NextSiblingElement("Image");
			}

			Scene* scene = new Scene(sprites,voice,texts,duration);
			scenes.push_back(scene);
			sce = sce->NextSiblingElement();
		}
		

		std::string texString = env->Attribute("texture");
		sf::Texture* tex = ResourceManager::getInst().getTexture(texString);
		sf::Sprite* sprite = new sf::Sprite(*tex);

		mEnviroments.push_back(Enviroment(scenes,sprite));
	
		env = env->NextSiblingElement();
	}
}