int parseDoc()
{
	XMLNode * root = doc.FirstChild();
	if(root == nullptr)
	{
		return XML_ERROR_FILE_READ_ERROR;
	}
	XMLElement * tuixml = root->FirstChildElement("tuixml");
	if(tuixml == nullptr)
	{
		return XML_ERROR_PARSING_ELEMENT;
	}
	XMLElement * temp = tuixml->FirstChildElement();
	layers.push_back(layer);
	createElementLayers(temp);
}
Пример #2
0
	/**
	*	@brief This is the default constructor for the XMLLoader. This sets up the root
	*	node and initalises the tinyxml2::XMLElement to start on the first save slot 
	*/
	XMLLoader(){
		string path = "Assets/save_data";
		string ext = ".sav";
		ext = ".xml";
		string result = path + ext;

		//xmlDoc.LoadFile(result.c_str());

		//Why does this load the old save_data all the time
		if(xmlDoc.LoadFile(result.c_str()) == tinyxml2::XML_ERROR_FILE_NOT_FOUND)
			GenerateSaveFile();
		
		tinyxml2::XMLNode *pRoot = xmlDoc.FirstChild();
		//cout << string_to_int(s) << endl;
		
		saveGame = pRoot->FirstChildElement("SaveGame");
		if (saveGame == nullptr) throw tinyxml2::XML_ERROR_FILE_READ_ERROR;

		
		loadSaveSlots();
		/*
		tinyxml2::XMLElement * slot = saveGame->FirstChildElement("SaveSlot1");
		if (slot == nullptr) throw tinyxml2::XML_ERROR_FILE_READ_ERROR;

		tinyxml2::XMLElement * level = slot->FirstChildElement("Levels");
		if (level == nullptr) throw tinyxml2::XML_ERROR_FILE_READ_ERROR;

		tinyxml2::XMLElement * level_bool = level->FirstChildElement("LVL3");
		if (level_bool == nullptr) throw tinyxml2::XML_ERROR_FILE_READ_ERROR;
		string l_data = level_bool->GetText();
		cout << string_to_int(l_data) << endl;
		*/
		/*
		loadSaveSlots();
		*/
		/*
		const string image_ext = texture->Attribute("EXT");
		const string file_name = image_name + '.' + image_ext;*/
	}