Ejemplo n.º 1
0
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());
		});
	});
}
Ejemplo n.º 2
0
bool User::platformFilter(const XML::gcXMLElement &platform, PlatformType type)
{
	if (!platform.IsValid())
		return true;

	uint32 id = 0;
	platform.GetAtt("id", id);

	if (id == 0)
		return true;

#ifdef WIN32
	return (id != 100);
#elif defined NIX
	if (type == PT_Tool)
		return (id != 110 && id != 120);
#ifdef NIX64
	if (id == 120)
		return false;
#endif
	//linux will have windows and nix
	return (id != 110); //id != 100 && 
#else
	return true;
#endif
}
Ejemplo n.º 3
0
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);
}
void InstalledWizardThread::parseItems1(const XML::gcXMLElement &fNode, gcRefPtr<WildcardManager> &pWildCard, std::map<uint64, XML::gcXMLElement> *vMap)
{
	gcAssert(pWildCard);

	if (!fNode.IsValid())
		return;

	fNode.FirstChildElement("games").for_each_child("game", [&](const XML::gcXMLElement &game)
	{
		if (isStopped())
			return;

		const std::string szId = game.GetAtt("siteareaid");
		DesuraId gameId(szId.c_str(), "games");

		if (!gameId.isOk())
			return;

		XML::gcXMLElement info;

		if (vMap)
			info = (*vMap)[gameId.toInt64()];

		parseGame(gameId, game, pWildCard, info);
	});
}
void InstalledWizardThread::parseMod(DesuraId parId, DesuraId id, const XML::gcXMLElement &mod, gcRefPtr<WildcardManager> &pWildCard, const XML::gcXMLElement &info)
{
	gcString name = mod.GetChild("name");

	if (name == "" && info.IsValid())
		name = info.GetChild("name");

	if (name == "")
		return;

	if (m_bTriggerNewEvent)
		onNewItemEvent(name);

	triggerProgress();

	m_uiDone++;

	UserCore::Misc::InstallInfo temp(id, parId);

	try
	{
		temp.loadXmlData(mod, pWildCard);

		if (m_bTriggerNewEvent)
			onModFound(temp);
	}
	catch (gcException &except)
	{
		Warning("ItemWizard: Error in xml parsing (installed wizard, mods): {0}\n", except);
	}
}
void InstalledWizardThread::parseItemsQuick(const XML::gcXMLElement &fNode)
{
	if (!fNode.IsValid())
		return;

	auto platforms = fNode.FirstChildElement("platforms");

	if (platforms.IsValid())
	{
		platforms.for_each_child("platform", [&](const XML::gcXMLElement &platform)
		{
			if (isStopped())
				return;

			if (getUserCore()->platformFilter(platform, PlatformType::Item))
				return;

			parseItemsQuick(platform);
		});
	}
	else
	{
		fNode.FirstChildElement("games").for_each_child("game", [&](const XML::gcXMLElement &game)
		{
			if (isStopped())
				return;

			const std::string id = game.GetAtt("siteareaid");
			DesuraId gameId(id.c_str(), "games");

			if (gameId.isOk())
				parseGameQuick(game);
		});
	}
}
void InstalledWizardThread::parseGameQuick(const XML::gcXMLElement &game)
{
	if (!game.IsValid())
		return;

	m_uiTotal++;

	game.FirstChildElement("mods").for_each_child("mod", [&](const XML::gcXMLElement &)
	{
		m_uiTotal++;
	});
}
Ejemplo n.º 8
0
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;
}
Ejemplo n.º 9
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;
}
Ejemplo n.º 10
0
void InstalledWizardThread::parseItems2(const XML::gcXMLElement &fNode, gcRefPtr<WildcardManager> &pWildCard)
{
	gcAssert(pWildCard);

	if (!fNode.IsValid())
		return;

	std::map<uint64, XML::gcXMLElement> vMap;

	fNode.FirstChildElement("games").for_each_child("game", [&](const XML::gcXMLElement &game)
	{
		if (isStopped())
			return;

		const std::string szId = game.GetAtt("siteareaid");
		DesuraId gameId(szId.c_str(), "games");

		if (gameId.isOk())
			vMap[gameId.toInt64()] = game;
	});

	fNode.FirstChildElement("platforms").for_each_child("platform", [&](const XML::gcXMLElement &platform)
	{
		if (isStopped())
			return;

		if (getUserCore()->platformFilter(platform, PlatformType::Item))
			return;

		auto wm = gcRefPtr<WildcardManager>::create(pWildCard);
		auto wildCardNode = platform.FirstChildElement("wcards");

		if (wildCardNode.IsValid())
		{
			wm->parseXML(wildCardNode);
			wm->compactWildCards();
		}

		parseItems1(platform, wm, &vMap);
	});
}
Ejemplo n.º 11
0
void ToolManager::parseXml(const XML::gcXMLElement &toolinfoNode)
{
	if (!toolinfoNode.IsValid())
		return;	

	auto toolsNode = toolinfoNode.FirstChildElement("tools");

	if (!toolsNode.IsValid())
		return;

	WildcardManager wcm;

	wcm.onNeedInstallSpecialEvent += delegate(this, &ToolManager::onSpecialCheck);
	wcm.onNeedSpecialEvent += delegate(m_pUser->getNeedWildCardEvent());

	auto wildcardNode = toolinfoNode.FirstChildElement("wcards");

	if (wildcardNode.IsValid())
		wcm.parseXML(wildcardNode);

	//clear the java path value
	WildcardInfo* temp = wcm.findItem("JAVA_EXE");

	if (temp)
	{
		temp->m_szPath = "";
		temp->m_bResolved = true;
	}

	bool is64OS = UTIL::OS::is64OS();

	toolsNode.for_each_child("tool", [this, is64OS, &wcm](const XML::gcXMLElement &toolEl)
	{
		bool isTool64 = false;
		toolEl.GetChild("bit64", isTool64);

		if (isTool64 && !is64OS)
			return;

		const std::string id = toolEl.GetAtt("siteareaid");

		if (id.empty())
			return;

		DesuraId tid(id.c_str(), "tools");
		ToolInfo* tool = this->findItem(tid.toInt64());

		bool bAdd = false;

		if (!tool)
		{
			tool = new ToolInfo(tid);
			bAdd = true;
		}

		tool->parseXml(toolEl, &wcm, m_pUser->getAppDataPath());

		if (bAdd)
			this->addItem(tool);
	});
	
	postParseXml();
}
Ejemplo n.º 12
0
void InstalledWizardThread::parseGame(DesuraId id, const XML::gcXMLElement &game, gcRefPtr<WildcardManager> &pWildCard, const XML::gcXMLElement &info)
{
	pWildCard->updateInstallWildcard("INSTALL_PATH", "INSTALL_PATH");
	pWildCard->updateInstallWildcard("PARENT_INSTALL_PATH", "%INSTALL_PATH%");


	gcString name = game.GetChild("name");

	if (name == "" && info.IsValid())
		name = info.GetChild("name");

	if (name == "")
		return;

	if (m_bTriggerNewEvent)
		onNewItemEvent(name);

	triggerProgress();
	m_uiDone++;

	UserCore::Misc::InstallInfo temp(id);

	try
	{
		if (info.IsValid())
			temp.loadXmlData(info, pWildCard);

		temp.loadXmlData(game, pWildCard);
	}
	catch (gcException &except)
	{
		Warning("ItemWizard: Error in xml parsing (installed wizard, games): {0}\n", except);
		return;
	}

	if (m_bTriggerNewEvent)
		onGameFound(temp);
	else
		m_vGameList.push_back(temp);

	pWildCard->updateInstallWildcard("INSTALL_PATH", "INSTALL_PATH");
	pWildCard->updateInstallWildcard("PARENT_INSTALL_PATH", temp.getPath());

	std::map<uint64, XML::gcXMLElement> mModMap;

	info.FirstChildElement("mods").for_each_child("mods", [&mModMap, this](const XML::gcXMLElement &mod)
	{
		if (isStopped())
			return;

		const std::string szId = mod.GetAtt("siteareaid");
		DesuraId internId(szId.c_str(), "mods");

		if (internId.isOk())
			mModMap[internId.toInt64()] = mod;
	});

	game.FirstChildElement("mods").for_each_child("mods", [&](const XML::gcXMLElement &mod)
	{
		if (isStopped())
			return;

		const std::string szId = mod.GetAtt("siteareaid");
		DesuraId internId(szId.c_str(), "mods");

		if (internId.isOk())
			parseMod(id, internId, mod, pWildCard, mModMap[internId.toInt64()]);
	});
}