Пример #1
0
/**
 * Reads the attributed object id, comments, and artifacts.
 */
bool Translator::ReadAttributedObject( AttributedObject& aobj, 
		Context& ctxt, const tinyxml2::XMLElement & elem, bool bIdAttributeRequired )
{
	//Grab the ID.
	pcstr szid = elem.Attribute("id");
	if( szid == NULL)
	{
		if( bIdAttributeRequired )
			throw GnssMetadata::TranslationException( "Required id attribute not defined.");
	}
	else
		aobj.Id(szid);

	//Parse the comments.
	const XMLElement* pelem = elem.FirstChildElement("comment");
	for( ;pelem != NULL; pelem = pelem->NextSiblingElement("comment"))
	{
		const char* szFmt = pelem->Attribute("format");
		Comment::CommentFormat fmt = (strcmp(szFmt, "text") == 0)
			? Comment::text : Comment::html;
		Comment comment( pelem->GetText(), fmt);
		aobj.Comments().push_back( comment);
	}

	//Parse the Artifacts.
	pelem = elem.FirstChildElement("artifact");
	for( ;pelem != NULL; pelem = pelem->NextSiblingElement("artifact"))
	{
		AnyUri auri( pelem->GetText());
		aobj.Artifacts().push_back( auri);
	}

	return true;
}
Пример #2
0
void Elevator::decodeXML(tinyxml2::XMLElement & xml)
{
	clearCars();
	Item::decodeXML(xml);
	size.y = xml.IntAttribute("height");
	for (tinyxml2::XMLElement * e = xml.FirstChildElement("unserviced"); e; e = e->NextSiblingElement("unserviced")) {
		unservicedFloors.insert(e->IntAttribute("floor"));
	}
	for (tinyxml2::XMLElement * e = xml.FirstChildElement("car"); e; e = e->NextSiblingElement("car")) {
		Car * car = new Car(this);
		car->decodeXML(*e);
		cars.insert(car);
	}
	updateSprite();
}
Пример #3
0
	void Animation2D::Read(const tinyxml2::XMLElement& el_ )
	{
		Animation::Read(el_);

		const tinyxml2::XMLElement *pElemFrame = el_.FirstChildElement("EventList")->FirstChildElement("Event");

		//float totalTime = 0.0f;

		while (pElemFrame != nullptr)
		{
			SetFrameEvent *pFrameEvent = NEW_AO SetFrameEvent();
			pFrameEvent->Read(const_cast<tinyxml2::XMLElement *>(pElemFrame));
			AddEvent(pFrameEvent);

			pElemFrame = pElemFrame->NextSiblingElement();

			/*unsigned int spriteID;
			pElemFrame->QueryUnsignedAttribute("spriteID", &spriteID);
			float time;
			pElemFrame->QueryFloatAttribute("time", &time);

			std::ostringstream str;
			str << spriteID;

			SetFrameEvent *pFrameEvent = NEW_AO SetFrameEvent();
			pFrameEvent->FrameID(str.str().c_str());
			pFrameEvent->Time(time + totalTime);
			AddEvent(pFrameEvent);

			pElemFrame = pElemFrame->NextSiblingElement();
			totalTime += time;*/
		}
	}
Пример #4
0
bool ChannelFavoritesSerializer::GetFavoritesResponseXmlDataDeserializer::VisitEnter(const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* attribute)
{
    if (strcmp(element.Name(), "favorite") == 0)
    {
        std::string id = Util::GetXmlFirstChildElementText(&element, "id");
        std::string name = Util::GetXmlFirstChildElementText(&element, "name");

        //channels
        ChannelFavorite::favorite_channel_list_t channels;
        const tinyxml2::XMLElement* channels_element = element.FirstChildElement("channels");
        if (channels_element != NULL)
        {
            const tinyxml2::XMLElement* channel_element = channels_element->FirstChildElement();
            while (channel_element != NULL)
            {
                if (strcmp(channel_element->Name(), "channel") == 0)
                {
                    if (channel_element->GetText() != NULL)
                        channels.push_back(channel_element->GetText());
                }
                channel_element = channel_element->NextSiblingElement();
            }

        }

        ChannelFavorite cf(id, name, channels);

        m_favoritesList.favorites_.push_back(cf);

        return false;
    }

    return true;
}
Пример #5
0
inline bool getValue(const tinyxml2::XMLElement& elt, Microseconds& microseconds) {
    uint64_t count;
    auto pChildElement = elt.FirstChildElement("Microseconds");
    if(pChildElement && getValue(*pChildElement, count)) {
        microseconds = Microseconds { count };
        return true;
    }
    return false;
}
Пример #6
0
inline bool getValue(const tinyxml2::XMLElement& elt, std::unordered_map<std::string, T>& values) {
    values.clear();
    for(auto pChildElement = elt.FirstChildElement(); pChildElement; pChildElement = pChildElement->NextSiblingElement()) {
        if(!getValue(*pChildElement, values[pChildElement->Name()])) {
            return false;
        }
    }
    return true;
}
Пример #7
0
void Box2D::Read(const tinyxml2::XMLElement& pEl_)
{
	//TODO


	const tinyxml2::XMLElement* pLocation_ = pEl_.FirstChildElement("Location");
	pLocation_->QueryFloatAttribute("x", &m_Center.x);
	pLocation_->QueryFloatAttribute("y", &m_Center.y);
	m_Center /= 100.0f; // TODO : to remove only for testing purpose
	//m_Center.x = -m_Center.x;
}
Пример #8
0
	void Animation::Read(const tinyxml2::XMLElement& el_)
	{
		IAssetable::Read(el_);

		const tinyxml2::XMLElement *pElemFrame = el_.FirstChildElement("EventList")->FirstChildElement("Event");

		while (pElemFrame != nullptr)
		{
			//get type event
			//EventFactory.Read()
			// 
			pElemFrame = pElemFrame->NextSiblingElement();
		}
	}
Пример #9
0
bool	CStacksmithXMLPrinter::CompactMode( const tinyxml2::XMLElement& elem )
{
	if( strcmp(elem.Name(),"text") == 0 || strcmp(elem.Name(),"script") == 0 || strcmp(elem.Name(),"td") == 0
		|| strcmp(elem.Name(),"body") == 0 )	// For htmlText property.
		return true;
	const tinyxml2::XMLElement*	firstElem = elem.FirstChildElement();
	const tinyxml2::XMLNode*	firstChild = elem.FirstChild();
	if( firstChild && firstElem && firstChild == elem.LastChild() && firstElem == firstChild	// Exactly one child, and it's an element?
		&& firstElem->FirstChild() == NULL )	// And this element has no children? I.e. is self-closing?
	{
		return true;
	}
	
	return false;
}
Пример #10
0
DirectionalLight loadDirectionalLight(
        const Scene& scene,
        const tinyxml2::XMLElement& elt) {
    auto pExitantPower = elt.FirstChildElement("ExitantPower");
    if(pExitantPower) {
        Vec3f wi(0, 1, 0);
        getChildAttribute(elt, "IncidentDirection", wi);
        Vec3f exitantPower = zero<Vec3f>();
        getChildAttribute(elt, "ExitantPower", exitantPower);

        return DirectionalLight(wi, exitantPower, scene);
    }

    return { normalize(loadVector(elt)), loadColor(elt) };
}
Пример #11
0
	void Sprite::Read( const tinyxml2::XMLElement& el_ )
	{
		Clear();
		IAssetable::Read(el_);

		const tinyxml2::XMLElement *pElem, *pChild;

		m_AssetFileName = el_.FirstChildElement("AssetFileName")->GetText();
		//m_Name = el_->Attribute("name");
		//m_Name = el_->Attribute("id");
		SetName(el_.Attribute("id")); // TODO : ID is not the name

		m_pTexture2D = Texture::loadTexture(m_AssetFileName.c_str());

		pElem = el_.FirstChildElement("PositionInTexture");
		int x, y, w, h;
		pElem->QueryIntAttribute("x", &x);
		pElem->QueryIntAttribute("y", &y);
		pElem->QueryIntAttribute("width", &w);
		pElem->QueryIntAttribute("height", &h);
		m_PositionInTexture.Set(x, y, w, h);

		pElem = el_.FirstChildElement("HotSpot");
		pElem->QueryIntAttribute("x", &m_Origin.x);
		pElem->QueryIntAttribute("y", &m_Origin.y);

		pElem = el_.FirstChildElement("CollisionList");
		pChild = pElem->FirstChildElement("Shape");

		while (pChild != nullptr)
		{
			IShape *pShape = IShape::LoadShape(*pChild);
			m_CollisionShapes.push_back(pShape);
			pChild = pChild->NextSiblingElement();
		}
	}
Пример #12
0
inline bool getValue(const tinyxml2::XMLElement& elt, std::vector<T>& values) {
    values.clear();
    auto i = 0u;
    auto pChildElement = elt.FirstChildElement("v0");
    while(pChildElement) {
        T value;
        if(!getValue(*pChildElement, value)) {
            return false;
        }
        values.emplace_back(value);
        ++i;
        pChildElement = pChildElement->NextSiblingElement((std::string("v") + toString(i)).c_str());
    }
    return true;
}
Пример #13
0
void Polygon::Read(const tinyxml2::XMLElement& pEl_)
{
	const tinyxml2::XMLElement* pPointList_ = pEl_.FirstChildElement("PointList");
	const tinyxml2::XMLElement *pPoint;

	pPoint = pPointList_->FirstChildElement("Point");
	m_PointList.clear();

	while (pPoint != nullptr)
	{
		Vector2F point;
		pPoint->QueryFloatAttribute("x", &point.x);
		pPoint->QueryFloatAttribute("y", &point.y);
		m_PointList.push_back(point);
		pPoint = pPoint->NextSiblingElement();
	}
}
Пример #14
0
EnvironmentLight loadEnvironmentLight(
        const Scene& scene,
        const tinyxml2::XMLElement& elt) {
    auto pBuildFromDirection = elt.FirstChildElement("BuildFromDirection");
    if(pBuildFromDirection) {
        Vec3f wi(0, 1, 0);
        getChildAttribute(*pBuildFromDirection, "IncidentDirection", wi);
        Vec3f exitantPower = zero<Vec3f>();
        getChildAttribute(*pBuildFromDirection, "ExitantPower", exitantPower);
        Vec2u resolution = Vec2u(1, 1);
        getChildAttribute(*pBuildFromDirection, "Resolution", resolution);

        return EnvironmentLight(resolution, wi, exitantPower, scene);
    }

    throw std::runtime_error("Unable to load EnvironmentLight");
}
aggregate_view_info
view_info_builder::build(const tinyxml2::XMLElement &element,
                         const mfast::group_field_instruction *inst) {
  const char *name = get_optional_attr(element, "name", nullptr);

  if (name == nullptr)
    BOOST_THROW_EXCEPTION(
        fast_static_error("A view must has a name attribute"));

  this->visit(inst, nullptr);
  aggregate_view_info result;
  result.max_depth_ = 0;
  std::size_t sz = std::strlen(name) + 1;
  result.name_ = reinterpret_cast<const char *>(
      std::memcpy(new (alloc_) char[sz], name, sz));

  // result.name_ = std::strcpy(new (alloc_) char[std::strlen(name) + 1],
  //                            name);

  std::deque<field_view_info> fields;

  const tinyxml2::XMLElement *child = element.FirstChildElement();
  while (child != nullptr) {
    if (std::strcmp(child->Name(), "field") == 0) {
      const tinyxml2::XMLElement *grandchild = child->FirstChildElement();
      while (grandchild != nullptr) {
        build_field_view(*grandchild, result.max_depth_, fields);
        grandchild = grandchild->NextSiblingElement();
      }

      fields.back().prop &= ~field_view_info::CONTINUE_BIT;
    }
    child = child->NextSiblingElement();
  }
  field_view_info terminator = {0, nullptr};
  fields.push_back(terminator);

  auto data = new (alloc_) field_view_info[fields.size()];
  std::copy(fields.begin(), fields.end(), data);
  result.data_ = mfast::array_view<const field_view_info>(data, fields.size());
  result.instruction_ = inst;
  return result;
}
Пример #16
0
		void XML::ParseTinyXmlElement(const tinyxml2::XMLElement& element)
		{
			//Parse this
			const char* text = element.GetText();
			if(text)
				m_data = text;

			//Parse attributes
			for(const tinyxml2::XMLAttribute* attribute = element.FirstAttribute(); attribute; attribute = attribute->Next())
			{
				m_attributes.insert(std::make_pair(string::ToLower(attribute->Name()), std::string(attribute->Value())));
			}

			//Parse children
			for(const tinyxml2::XMLElement* childElement = element.FirstChildElement(); childElement; childElement = childElement->NextSiblingElement())
			{
				XML* childNode = AddChild(childElement->Name());
				childNode->ParseTinyXmlElement(*childElement);
			}
		}
Пример #17
0
size_t Translator::ReadFirstElement( const char* pszelem, 
		const tinyxml2::XMLElement& container, 
		bool bRequired,  size_t iDefault)
{
	const XMLElement* pchild = container.FirstChildElement(pszelem);
	if( pchild == NULL)
	{
		if( !bRequired)
			return iDefault;
		else
		{
			char buff[256];
			sprintf( "Cannot find required unsigned integer element %s in container %s", pszelem, container.Name());
			throw TranslationException(buff);
		}
	}
	else
	{
		return atol( pchild->GetText());
	}
}
Пример #18
0
bool Translator::ReadFirstElement( const char* pszelem, 
	const tinyxml2::XMLElement& container,  
	bool bRequired, bool bDefault)
{
	const XMLElement* pchild = container.FirstChildElement(pszelem);
	if( pchild == NULL)
	{
		if( !bRequired)
			return bDefault;
		else
		{
			char buff[256];
			sprintf( "Cannot find required boolean element %s in container %s", pszelem, container.Name());
			throw TranslationException(buff);
		}
	}
	else
	{
		return (strcmp( pchild->GetText(),"false")==0);
	}
}
Пример #19
0
void 
GameObject::LoadItems( tinyxml2::XMLElement & items )
{
  XMLElement * item = items.FirstChildElement("Item");
  while ( item ){


    GameObject *pItem = new GameObject();
    try {
      pItem->Load(*item);
      GetItems().push_back(pItem);
    } 
    catch ( std::exception & ex )
    {
      g_Error << "Could not load item" << ex.what();
      delete pItem;
    }    

    item = item->NextSiblingElement("Item");

  }
}
Пример #20
0
	/**
	*	@brief Cycles through the XMLElement saveGame and reads in each of the required fields
	*	into the approprate holder in the SaveSlot for access later. This process is looped to 
	*	read through each of the three save slots.
	*	@see SaveSlot
	*/
	void loadSaveSlots(){
		string name = "SaveSlot";

		for (int i = 0; i < 3; i++){
			string slot_name = name + std::to_string(i + 1);
			//saveGame->FirstChildElement(slot_name);
			tinyxml2::XMLElement * slot = saveGame->FirstChildElement(slot_name.c_str());
			if (slot == nullptr) throw tinyxml2::XML_ERROR_FILE_READ_ERROR;

			tinyxml2::XMLElement * timeElement = slot->FirstChildElement("TimePlayed");
			if (timeElement == nullptr) throw tinyxml2::XML_ERROR_FILE_READ_ERROR;
			int time = string_to_int(timeElement->GetText());

			tinyxml2::XMLElement * goldElement = slot->FirstChildElement("CurrentGold");
			if (goldElement == nullptr) throw tinyxml2::XML_ERROR_FILE_READ_ERROR;
			int gold = string_to_int(goldElement->GetText());

			map<string, bool> map;
			tinyxml2::XMLElement * levelElement = slot->FirstChildElement("Levels");
			if (levelElement == nullptr) throw tinyxml2::XML_ERROR_FILE_READ_ERROR;
			//============================================================================================
			int levels_unlocked = 0;
			tinyxml2::XMLElement * ele = levelElement->FirstChildElement("LVL1");
			int text = string_to_int(ele->GetText());
			if (text == 0)	levels_unlocked++;
			map["LVL1"] = text;

			ele = levelElement->FirstChildElement("LVL2");
			text = string_to_int(ele->GetText());
			if (text == 0)	levels_unlocked++;
			map["LVL2"] = text;

			ele = levelElement->FirstChildElement("LVL3");
			text = string_to_int(ele->GetText());
			if (text == 0)	levels_unlocked++;
			map["LVL3"] = text;

			ele = levelElement->FirstChildElement("LVL4");
			text = string_to_int(ele->GetText());
			if (text == 0)	levels_unlocked++;
			map["LVL4"] = text;

			ele = levelElement->FirstChildElement("LVL5");
			text = string_to_int(ele->GetText());
			if (text == 0)	levels_unlocked++;
			map["LVL5"] = text;

			ele = levelElement->FirstChildElement("LVL6");
			text = string_to_int(ele->GetText());
			if (text == 0)	levels_unlocked++;
			map["LVL6"] = text;

			ele = levelElement->FirstChildElement("LVL7");
			text = string_to_int(ele->GetText());
			if (text == 0)	levels_unlocked++;
			map["LVL7"] = text;
			//============================================================================================
			
			std::map<string, bool> m_achievements;
			tinyxml2::XMLElement * achElement = slot->FirstChildElement("Achievements");
			if (achElement == nullptr) throw tinyxml2::XML_ERROR_FILE_READ_ERROR;
			//============================================================================================
			
			int ach_unlocked = 0;
			string name = "ACH";
			for (int i = 0; i < 21; i++) {
				string tag = name + std::to_string(i + 1);
				tinyxml2::XMLElement * ele = achElement->FirstChildElement(tag.c_str());
				int text = string_to_int(ele->GetText());
				if (text == 0)	ach_unlocked++;
				m_achievements[tag] = text;
			}
			//============================================================================================

			std::map<string, int> m_stats;
			tinyxml2::XMLElement * statElement = slot->FirstChildElement("Statistics");
			if (statElement == nullptr) throw tinyxml2::XML_ERROR_FILE_READ_ERROR;
			//============================================================================================
			string title = "STAT";
			for (int i = 0; i < 10; i++) {
				string tag = title + std::to_string(i + 1);
				tinyxml2::XMLElement * ele = statElement->FirstChildElement(tag.c_str());

				int text = string_to_int(ele->GetText());
				m_stats[tag] = text;
			}

			saved_data.push_back(new SaveSlot(i + 1, time, gold, map, levels_unlocked, m_achievements, ach_unlocked , m_stats));
		}
	}
Пример #21
0
bool GetPlaybackObjectResponseSerializer::PlaybackItemXmlDataDeserializer::VisitEnter(const tinyxml2::XMLElement& element, const tinyxml2::XMLAttribute* attribute)
{
  if (strcmp(element.Name(), "recorded_tv") == 0 ||
      strcmp(element.Name(), "video") == 0) 
  {
    PlaybackItem* item;
    std::string objectId = Util::GetXmlFirstChildElementText(&element, "object_id");
    std::string parentId = Util::GetXmlFirstChildElementText(&element, "parent_id");
    std::string playbackUrl = Util::GetXmlFirstChildElementText(&element, "url");
    std::string thumbnailUrl = Util::GetXmlFirstChildElementText(&element, "thumbnail");    

    if (strcmp(element.Name(), "recorded_tv") == 0) 
    {     
      tinyxml2::XMLElement* vElement = (tinyxml2::XMLElement*)element.FirstChildElement("video_info");
      RecordedTvItemMetadata* metadata = new RecordedTvItemMetadata();
      ItemMetadataSerializer::Deserialize((XmlObjectSerializer<Response>&)m_parent, *vElement, *metadata);
      RecordedTvItem* recordedTvitem = new RecordedTvItem(objectId, parentId, playbackUrl, thumbnailUrl, metadata);

      if (m_parent.HasChildElement(element, "channel_name")) 
      {
        recordedTvitem->ChannelName = Util::GetXmlFirstChildElementText(&element, "channel_name");
      }

      if (m_parent.HasChildElement(element, "channel_number")) 
      {
        recordedTvitem->ChannelNumber = Util::GetXmlFirstChildElementTextAsInt(&element, "channel_number");
      }
      
      if (m_parent.HasChildElement(element, "channel_subnumber")) 
      {
        recordedTvitem->ChannelSubNumber = Util::GetXmlFirstChildElementTextAsInt(&element, "channel_subnumber");
      }

      if (m_parent.HasChildElement(element, "state")) 
      {
        recordedTvitem->State = (RecordedTvItem::DVBLinkRecordedTvItemState)Util::GetXmlFirstChildElementTextAsInt(&element, "state");
      }

      if (m_parent.HasChildElement(element, "schedule_id"))
      {
          recordedTvitem->ScheduleId = Util::GetXmlFirstChildElementText(&element, "schedule_id");
      }

      if (m_parent.HasChildElement(element, "schedule_name"))
      {
          recordedTvitem->ScheduleName = Util::GetXmlFirstChildElementText(&element, "schedule_name");
      }

      if (m_parent.HasChildElement(element, "schedule_series"))
      {
          recordedTvitem->SeriesSchedule = true;
      }

      item = (PlaybackItem*)recordedTvitem;
    }
    else if (strcmp(element.Name(), "video") == 0) 
    {     
      tinyxml2::XMLElement* vElement = (tinyxml2::XMLElement*)element.FirstChildElement("video_info");
      VideoItemMetadata* metadata = new VideoItemMetadata();
      ItemMetadataSerializer::Deserialize((XmlObjectSerializer<Response>&)m_parent, *vElement, *metadata);
      VideoItem* videoItem = new VideoItem(objectId, parentId, playbackUrl, thumbnailUrl, metadata);
      item = (PlaybackItem*)videoItem;
    }

    if (item) 
    {
      if (m_parent.HasChildElement(element, "can_be_deleted")) 
      {
        item->CanBeDeleted = Util::GetXmlFirstChildElementTextAsBoolean(&element, "can_be_deleted");
      }

      if (m_parent.HasChildElement(element, "size")) 
      {
        item->Size = Util::GetXmlFirstChildElementTextAsLong(&element, "size");
      }

      if (m_parent.HasChildElement(element, "creation_time")) 
      {
        item->CreationTime = Util::GetXmlFirstChildElementTextAsLong(&element, "creation_time");
      }

      m_playbackItemList.push_back(item);
    }
  
    return false;
  }

  return true;
}
Пример #22
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    canUpdate=false;
    QSettings settings;
    QString dir=QFileDialog::getExistingDirectory(NULL,"Folder containing region directory",settings.value("mapfolder").toString());
    if(dir.isEmpty())
        abort();
    if(!QString(TMPDATA).endsWith("/"))
        abort();
    if(!dir.endsWith("/"))
        dir+="/";
    settings.setValue("mapfolder",dir);
    QDir().mkpath(TMPDATA);

    QDir dir2("/tmp/map-metadata/");
    dir2.setFilter(QDir::Files | QDir::Dirs | QDir::Hidden | QDir::NoSymLinks | QDir::NoDotAndDotDot);
    QFileInfoList list = dir2.entryInfoList();
    if(!QDir("/tmp/map-metadata/").exists() || list.size()==0)
    {
        process.setArguments(QStringList() << "/home/user/Desktop/CatchChallenger/datapack-pkmn/map/main/gen4/map/");
        process.setProgram("/home/user/Desktop/CatchChallenger/tools/build-map2png-Desktop-Debug/map2png");
        process.setWorkingDirectory("/tmp/map-metadata/");
        process.start();
        process.waitForFinished(999999999);
        std::cerr << process.errorString().toStdString() << std::endl;
        std::cout << process.readAll().toStdString() << std::endl;
        if(process.exitCode()!=0)
            std::cerr << "Process exit code: " << process.exitCode() << std::endl;
    }

    QString path=QCoreApplication::applicationDirPath()+"/changes.db";
    QFile destinationFile(path);
    if(!destinationFile.exists())
    {
        if(QFile::copy(":/changes.db",path))
        {
            if(!destinationFile.setPermissions(destinationFile.permissions() | QFileDevice::WriteOwner | QFileDevice::WriteUser))
                std::cerr << "Unable to set db permissions" << std::endl;
        }
        else
            std::cerr << "Unable to copy the :/changes.db" << std::endl;
    }
    m_db = QSqlDatabase::addDatabase("QSQLITE");
    m_db.setDatabaseName(path);

    if (!m_db.open())
    {
        qDebug() << "Error: connection with database fail";
        abort();
    }

    QHash<QString,MapContent> db_finishedFile;
    QHash<QString,MapContent> db_not_finishedFile;
    QSqlQuery query;
    if(!query.exec("SELECT file, region, zone, subzone, name, type, finished FROM maps"))
    {
        qDebug() << query.lastError().text();
        abort();
    }
    while(query.next())
    {
        QString file = query.value(0).toString();
        MapContent mapContent;
        mapContent.region=query.value(1).toString();
        mapContent.zone=query.value(2).toString();
        mapContent.subzone=query.value(3).toString();
        mapContent.name=query.value(4).toString();
        mapContent.type=query.value(5).toString();
        if(mapContent.region.isEmpty())
            abort();
        mapContent.officialzone=query.value(7).toInt()>0;
        if(query.value(6).toInt()>0)
            db_finishedFile[file]=mapContent;
        else
            db_not_finishedFile[file]=mapContent;
    }

    {
        QDirIterator it(dir,QDirIterator::Subdirectories);
        QRegularExpression regex("\\.tmx$");
        QRegularExpression regexRemove("^/");
        while (it.hasNext()) {
            QString element=it.next();
            if(element.contains(regex))
            {
                QString sortPath=element;
                sortPath.remove(0,dir.size());
                sortPath.remove(regexRemove);
                QString pngDest=TMPDATA+sortPath;
                pngDest.replace(".tmx",".png");
                //std::cout << sortPath.toStdString() << " -> " << pngDest.toStdString() << std::endl;

                const QStringList elementList=sortPath.split("/");
                if(elementList.size()>=2 && elementList.size()<=3)
                {
                    QString file = sortPath;
                    if(db_finishedFile.contains(file))
                        finishedFile[file]=db_finishedFile.value(file);
                    else if(db_not_finishedFile.contains(file))
                        not_finishedFile[file]=db_not_finishedFile.value(file);
                    else
                    {
                        MapContent mapContent;
                        mapContent.region=elementList.at(0);
                        if(mapContent.region.isEmpty())
                            abort();
                        mapContent.zone=elementList.at(1);
                        mapContent.zone.replace(".tmx","");
                        if(elementList.size()==3)
                        {
                            mapContent.subzone=elementList.at(2);
                            mapContent.subzone.replace(".tmx","");
                        }
                        mapContent.officialzone=true;
                        //get from xml
                        QDomDocument domDocument;
                        QString xmlpath=element;
                        xmlpath.replace(".tmx",".xml");
                        QFile xmlfile(xmlpath);
                        if (xmlfile.open(QIODevice::ReadOnly))
                        {
                            if (!domDocument.setContent(&xmlfile)) {
                                xmlfile.close();
                                return;
                            }
                            xmlfile.close();

                            const tinyxml2::XMLElement root = domDocument.RootElement();
                            if(root.tagName()=="map")
                            {
                                //load the content
                                const tinyxml2::XMLElement nameItem = root.FirstChildElement("name");
                                if(!nameItem.isNull())
                                    mapContent.name=nameItem.text();

                                if(root.hasAttribute("type"))
                                    mapContent.type=root.attribute("type");
                                if(root.hasAttribute("zone"))
                                {
                                    mapContent.officialzone=true;
                                    mapContent.zone=root.attribute("zone");
                                }
                                else
                                {
                                    if(mapContent.name.startsWith("Route "))
                                    {
                                        mapContent.officialzone=false;
                                        mapContent.zone="route";
                                    }
                                    else
                                        mapContent.officialzone=true;
                                }
                            }
                        }

                        not_finishedFile[file]=mapContent;
                        //insert into database
                        QSqlQuery query;
                        if(!query.prepare("INSERT INTO maps (file, region, zone, subzone, name, type, finished) "
                                      "VALUES (:file, :region, :zone, :subzone, :name, :type, :finished)"))
                        {
                            qDebug() << query.lastError().text();
                            abort();
                        }
                        query.bindValue(":file", file);
                        query.bindValue(":region", mapContent.region);
                        query.bindValue(":zone", mapContent.zone);
                        query.bindValue(":subzone", mapContent.subzone);
                        query.bindValue(":name", mapContent.name);
                        query.bindValue(":type", mapContent.type);
                        query.bindValue(":finished", 0);
                        if(!query.exec())
                        {
                            qDebug() << query.lastError().text();
                            abort();
                        }
                    }
                }
            }
        }
    }
    preload_the_map(dir.toStdString());
    for(auto& n:map_list)
    {
        CatchChallenger::MapServer * map=n.second;
        unsigned int index=0;
        while(index<map->linked_map.size())
        {
            CatchChallenger::CommonMap * const newMap=map->linked_map.at(index);
            if(!vectorcontainsAtLeastOne(newMap->linked_map,static_cast<CatchChallenger::CommonMap *>(map)))
                newMap->linked_map.push_back(map);
            index++;
        }
    }

    displayNewNotFinishedMap();
    updateProgressLabel();
}