コード例 #1
0
ファイル: User.cpp プロジェクト: CSRedRat/desura-app
void User::parseNewsAndGifts(const XML::gcXMLElement &xmlNode, const char* szChildName, Event<std::vector<UserCore::Misc::NewsItem*> > &onEvent)
{
	if (!xmlNode.IsValid())
		return;

	std::vector<UserCore::Misc::NewsItem*> itemList;

	xmlNode.for_each_child(szChildName, [&itemList](const XML::gcXMLElement &itemElem)
	{
		const std::string szId = itemElem.GetAtt("id");

		gcString szTitle;
		gcString szUrl;

		itemElem.GetChild("title", szTitle);
		itemElem.GetChild("url", szUrl);
			
		if (szId.empty() || szTitle.empty() || szUrl.empty())
			return;

		uint32 id = (uint32)Safe::atoi(szId.c_str());

		UserCore::Misc::NewsItem *temp = new UserCore::Misc::NewsItem(id, 0, szTitle.c_str(), szUrl.c_str());
		itemList.push_back(temp);
	});

	if (itemList.size() > 0)
		onEvent(itemList);

	safe_delete(itemList);
}
コード例 #2
0
void BranchInstallInfo::extractInstallChecks(const XML::gcXMLElement &icsNode, gcRefPtr<WildcardManager> &pWildCard, std::vector<InsCheck> &vInsChecks)
{
	icsNode.for_each_child("installlocation", [&vInsChecks, pWildCard, this](const XML::gcXMLElement &icNode)
	{
		const gcString iCheck = icNode.GetChild("check");
		const gcString iPath = icNode.GetChild("path");

		if (iCheck.empty() || iPath.empty())
			return;

		try
		{
			gcString strCheckRes = pWildCard->constructPath(iCheck.c_str());

			if (isInstalled())
			{
				if (!updateInstallCheck(strCheckRes, iPath))
					return;

				vInsChecks.push_back(InsCheck(strCheckRes.c_str(), m_szPath.c_str()));
			}
			else
			{
				vInsChecks.push_back(InsCheck(strCheckRes.c_str(), iPath.c_str()));
			}
		}
		catch (...)
		{
		}
	});
}
コード例 #3
0
ファイル: Theme.cpp プロジェクト: leayle2a/desura-app
void Theme::LoadSprites(const XML::gcXMLElement &xmlEl)
{
	xmlEl.for_each_child("sprite", [this](const XML::gcXMLElement &xmlChild)
	{
		const std::string name = xmlChild.GetAtt("name");

		if (name.empty())
			return;

		auto sprite = SpriteList::findItem(name.c_str());

		if (!sprite)
		{
			sprite = gcRefPtr<ThemeSpriteInfo>::create(name.c_str());
			addItem(sprite);
		}

		xmlChild.for_each_child("rect", [sprite](const XML::gcXMLElement &xmlRect)
		{
			const std::string rName = xmlRect.GetAtt("name");

			const XML::gcXMLElement pos = xmlRect.FirstChildElement("pos");
			const XML::gcXMLElement size = xmlRect.FirstChildElement("size");

			if (rName.empty() || !pos.IsValid() || !size.IsValid())
				return;

			const std::string x = pos.GetAtt("x");
			const std::string y = pos.GetAtt("y");

			const std::string w = size.GetAtt("w");
			const std::string h = size.GetAtt("h");

			if (x.empty() || y.empty() || w.empty() || h.empty())
				return;

			auto rect = sprite->findItem(rName.c_str());

			if (!rect)
			{
				rect = gcRefPtr<SpriteRect>::create(rName.c_str());
				sprite->addItem(rect);
			}

			rect->x = Safe::atoi(x.c_str());
			rect->y = Safe::atoi(y.c_str());
			rect->w = Safe::atoi(w.c_str());
			rect->h = Safe::atoi(h.c_str());
		});
	});
}
コード例 #4
0
ファイル: UMcf.cpp プロジェクト: Translator5/desura-app
uint8 UMcf::parseXml(const XML::gcXMLElement &xmlElement)
{
    if (!xmlElement.IsValid())
        return UMCF_ERR_XML_NOPRIMENODE;

    xmlElement.for_each_child("file", [this](const XML::gcXMLElement &xmlChild)
    {
        auto temp = std::make_shared<UMcfFile>();

        if (temp->loadXmlData(xmlChild) == UMCF_OK)
            m_pFileList.push_back(temp);
    });

    return UMCF_OK;
}
コード例 #5
0
uint8 WildcardManager::parseXML(const XML::gcXMLElement &xmlElement)
{
	if (!xmlElement.IsValid())
		return WCM_ERR_BADXML;

	xmlElement.for_each_child("wcard", [this](const XML::gcXMLElement &xmlChild)
	{
		const std::string name = xmlChild.GetAtt("name");
		const std::string type = xmlChild.GetAtt("type");
		const std::string string = xmlChild.GetText();
			
		if (!name.empty() && !type.empty() && !string.empty())
		{
			addItem(new WildcardInfo(name, string, type));
		}
	});

	return WCM_OK;
}
コード例 #6
0
ファイル: Theme.cpp プロジェクト: leayle2a/desura-app
void Theme::LoadImages(const UTIL::FS::Path& path, const XML::gcXMLElement &xmlEl)
{
	xmlEl.for_each_child("image", [this, &path](const XML::gcXMLElement &xmlChild)
	{
		const std::string name = xmlChild.GetAtt("name");
		const std::string val = xmlChild.GetText();

		if (name.empty() || val.empty())
			return;

		std::string outVal = UTIL::STRING::sanitizeFileName(val);
		auto img = ImageList::findItem(name.c_str());

		if (!img)
		{
			img = gcRefPtr<ThemeImageInfo>::create(name.c_str());
			addItem(img);
		}

		gcString fullPath("{0}{2}images{2}app{2}{1}", path.getFolderPath(), outVal, DIRS_STR);
		img->path = fullPath;
	});
}
コード例 #7
0
ファイル: Theme.cpp プロジェクト: leayle2a/desura-app
void Theme::LoadControls(const XML::gcXMLElement &xmlEl)
{
	xmlEl.for_each_child("control", [this](const XML::gcXMLElement &xmlChild)
	{
		const std::string name = xmlChild.GetAtt("name");

		if (name.empty())
			return;

		auto control = ControlList::findItem(name.c_str());

		if (!control)
		{
			control = gcRefPtr<ThemeControlInfo>::create(name.c_str());
			addItem(control);
		}

		xmlChild.for_each_child("color", [control](const XML::gcXMLElement &xmlCol)
		{
			const std::string id = xmlCol.GetAtt("id");
			const std::string val = xmlCol.GetText();

			if (id.empty() || val.empty())
				return;

			auto col = control->findItem(id.c_str());

			if (!col)
			{
				col = gcRefPtr<ThemeColorInfo>::create(id.c_str());
				control->add(col);
			}

			col->color = Color(val.c_str());
		});
	});
}
コード例 #8
0
ファイル: Theme.cpp プロジェクト: leayle2a/desura-app
void Theme::LoadWeb(const UTIL::FS::Path& path, const XML::gcXMLElement &xmlEl)
{
	gcString urlPath(path.getFolderPath());

	for (size_t x=0; x<urlPath.size(); x++)
	{
		if (urlPath[x] == '\\')
			urlPath[x] = '/';
	}

	xmlEl.for_each_child("page", [this, urlPath](const XML::gcXMLElement &xmlChild)
	{
		const std::string name = xmlChild.GetAtt("name");
		const std::string val = xmlChild.GetText();

		if (name.empty() || val.empty())
			return;

		std::string outVal = UTIL::STRING::sanitizeFileName(val);

#ifdef WIN32
		gcString fullPath("file:///{0}/html/{1}", urlPath, outVal);
#else
		gcString fullPath("file://{0}/html/{1}", urlPath, outVal);
#endif

		auto web = WebList::findItem(name.c_str());

		if (!web)
		{
			web = gcRefPtr<ThemeWebInfo>::create(name.c_str());
			addItem(web);
		}

		web->path = fullPath;
	});
}