Пример #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());
		});
	});
}
Пример #2
0
void BranchInfo::processInstallScript(const XML::gcXMLElement &xmlElement)
{
	uint32 crc = 0;
	xmlElement.GetAtt("crc", crc);

	if (UTIL::FS::isValidFile(m_szInstallScript))
	{
		if (crc != 0 && m_uiInstallScriptCRC == (uint32)crc)
			return;
	}
	else
	{
		m_szInstallScript = UTIL::OS::getAppDataPath(gcWString(L"{0}\\{1}\\install_script.js", m_ItemId.getFolderPathExtension(), getBranchId()).c_str());
	}

	gcString base64 = xmlElement.GetText();

	try
	{
		UTIL::FS::recMakeFolder(UTIL::FS::Path(m_szInstallScript, "", true));
		UTIL::FS::FileHandle fh(m_szInstallScript.c_str(), UTIL::FS::FILE_WRITE);
		UTIL::STRING::base64_decode(base64, [&fh](const unsigned char* data, uint32 size) -> bool
		{
			fh.write((const char*)data, size);
			return true;
		});

		m_uiInstallScriptCRC = crc;
	}
	catch (gcException &e)
	{
		Warning("Failed to save install script for {0} branch {1}: {2}\n", m_ItemId.toInt64(), m_uiBranchId, e);
		m_szInstallScript = "";
	}
}
Пример #3
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
}