Exemplo n.º 1
0
// 加载杂项配置
BOOL LoadMiscConfig(LPCTSTR lpszFileName)
{
	CXmlDocument xmlDoc;
	CXmlNode xmlNode;

	BOOL bRet = xmlDoc.Load(lpszFileName);
	if (!bRet)
		return FALSE;

	bRet = xmlDoc.SelectSingleNode(_T("/Misc/FontInfo"), xmlNode);
	if (bRet)
	{
		g_fontInfo.m_strName = xmlNode.GetAttribute(_T("Name"));
		g_fontInfo.m_nSize = xmlNode.GetAttributeInt(_T("Size"));
		tstring strColor = xmlNode.GetAttribute(_T("Color"));
		g_fontInfo.m_clrText = HexStrToRGB(strColor.c_str());
		g_fontInfo.m_bBold = xmlNode.GetAttributeInt(_T("Bold"));
		g_fontInfo.m_bItalic = xmlNode.GetAttributeInt(_T("Italic"));
		g_fontInfo.m_bUnderLine = xmlNode.GetAttributeInt(_T("UnderLine"));
	}

	bRet = xmlDoc.SelectSingleNode(_T("/Misc/HotKey"), xmlNode);
	if (bRet)
	{
		tstring strHotKey = xmlNode.GetText();
		g_cHotKey = toupper(strHotKey.at(0));
	}

	xmlNode.Release();
	xmlDoc.Release();

	return TRUE;
}
Exemplo n.º 2
0
//从Xml中读取表情配置
BOOL CFaceList::LoadConfigFile(LPCTSTR lpszFileName)
{
	CXmlDocument xmlDoc;
	CXmlNode xmlNode, xmlSubNode;

	Reset();

	BOOL bRet = xmlDoc.Load(lpszFileName);
	if (!bRet)
		return FALSE;

	bRet = xmlDoc.SelectSingleNode(_T("/faceconfig"), xmlNode);
	if (bRet)
	{
		m_nItemWidth = xmlNode.GetAttributeInt(_T("item_width"));
		m_nItemHeight = xmlNode.GetAttributeInt(_T("item_height"));
		m_nZoomWidth = xmlNode.GetAttributeInt(_T("zoom_width"));
		m_nZoomHeight = xmlNode.GetAttributeInt(_T("zoom_height"));
		m_nRow = xmlNode.GetAttributeInt(_T("row"));
		m_nCol = xmlNode.GetAttributeInt(_T("col"));

		bRet = xmlNode.GetFirstChildNode(_T("face"), xmlSubNode);
		while (bRet)
		{
			CFaceInfo * lpFaceInfo = new CFaceInfo;
			if (lpFaceInfo != NULL)
			{
				lpFaceInfo->m_nId = xmlSubNode.GetAttributeInt(_T("id"));
				lpFaceInfo->m_strTip = xmlSubNode.GetAttribute(_T("tip"));
				lpFaceInfo->m_strFileName = ZYM::CPath::GetCurDir() + xmlSubNode.GetAttribute(_T("file"));
				tString strIndex = ZYM::CPath::GetFileNameWithoutExtension(lpFaceInfo->m_strFileName.c_str());
				if (IsDigit(strIndex.c_str()))
					lpFaceInfo->m_nIndex = _tcstol(strIndex.c_str(), NULL, 10);
				m_arrFaceInfo.push_back(lpFaceInfo);
			}

			bRet = xmlSubNode.GetNextSiblingNode(_T("face"), xmlSubNode);
		}
	}

	xmlSubNode.Release();
	xmlNode.Release();
	xmlDoc.Release();

	return TRUE;
}
Exemplo n.º 3
0
////////////////////////////////////////////////////////////////////////////
// Load settings from the [screensavername].xml configuration file
// the name of the screensaver (filename) is used as the name of
// the xml file - this is sent to us by XBMC when the Init func is called.
//
void	CConfig::LoadSettings()
{
	XmlNode node, childNode; //, grandChild;
	CXmlDocument doc;
	
	char szXMLFile[1024];
#ifdef _TEST
	strcpy(szXMLFile, "MatrixTrails.xml");
#else
	strcpy(szXMLFile, "Q:\\screensavers\\");
	strcat(szXMLFile, gScrName);
	strcat(szXMLFile, ".xml");
#endif

	// Load the config file
	if (doc.Load(szXMLFile) >= 0)
	{
		node = doc.GetNextNode(XML_ROOT_NODE);
		while(node > 0)
		{
			if (strcmpi(doc.GetNodeTag(node),"screensaver"))
			{
				node = doc.GetNextNode(node);
				continue;
			}

			if (childNode = doc.GetChildNode(node,"CharDelayMin"))	m_CharDelayMin	= (f32)atof(doc.GetNodeText(childNode));
			if (childNode = doc.GetChildNode(node,"CharDelayMax"))	m_CharDelayMax	= (f32)atof(doc.GetNodeText(childNode));
			if (childNode = doc.GetChildNode(node,"FadeSpeedMin"))	m_FadeSpeedMin	= (f32)atof(doc.GetNodeText(childNode));
			if (childNode = doc.GetChildNode(node,"FadeSpeedMax"))	m_FadeSpeedMax	= (f32)atof(doc.GetNodeText(childNode));

			if (childNode = doc.GetChildNode(node,"NumColumns"))	m_NumColumns	= atoi(doc.GetNodeText(childNode));
			if (childNode = doc.GetChildNode(node,"NumRows"))		m_NumRows		= atoi(doc.GetNodeText(childNode));

			if (childNode = doc.GetChildNode(node,"CharCol"))		sscanf(doc.GetNodeText(childNode), "%f %f %f", &m_CharCol.r, &m_CharCol.g, &m_CharCol.b);

			if (childNode = doc.GetChildNode(node,"NumChars"))		m_NumChars	= atoi(doc.GetNodeText(childNode));

			if (childNode = doc.GetChildNode(node,"CharSizeTexX"))	m_CharSizeTex.x	= (f32)atof(doc.GetNodeText(childNode))/TEXTURESIZE;
			if (childNode = doc.GetChildNode(node,"CharSizeTexY"))	m_CharSizeTex.y	= (f32)atof(doc.GetNodeText(childNode))/TEXTURESIZE;

			node = doc.GetNextNode(node);
		}
		doc.Close();
	}
}
Exemplo n.º 4
0
//-- LoadSettings -------------------------------------------------------------
//
//-----------------------------------------------------------------------------
void ShadeWorm_c::LoadSettings(const char* name)
{
	XmlNode node;
	CXmlDocument doc;
	int colId;
	int index;
	int col;

	// Set up the defaults
	m_numWorms = 16;
	m_drawTime = 8;
	m_numColMaps = 0;
	m_randomColMap = false;

	char szXMLFile[1024];
	strcpy(szXMLFile, "Q:\\screensavers\\");
	strcat(szXMLFile, name);
	strcat(szXMLFile, ".xml");

	// Load the config file
	if (doc.Load(szXMLFile) >= 0)
	{
		node = doc.GetNextNode(XML_ROOT_NODE);
		while(node > 0)
		{
			if (!strcmpi(doc.GetNodeTag(node),"NumWorms"))
			{
				m_numWorms = atoi(doc.GetNodeText(node));
				Clamp(1, 32, m_numWorms);
			}
			else if (!strcmpi(doc.GetNodeTag(node),"DrawTime"))
			{
				m_drawTime = atoi(doc.GetNodeText(node));
				Clamp(1, 10, m_drawTime);
			}
			else if (!strcmpi(doc.GetNodeTag(node),"RandomColMap"))
			{
				m_randomColMap = !strcmpi(doc.GetNodeText(node),"true");
			}
			else if (!strcmpi(doc.GetNodeTag(node),"Map"))
			{
				node = doc.GetNextNode(node);

				if (m_numColMaps < MAX_COLMAPS)
				{

					colId = 0;
					m_colMaps[m_numColMaps].m_numCols = 0;
					m_colMaps[m_numColMaps].m_colMap = new ColMapEntry_t[256];

					while (node>0)
					{
						if (!strcmpi(doc.GetNodeTag(node),"Col"))
						{
							if (colId < 256)
							{
								char* txt = doc.GetNodeText(node);

								sscanf(txt, "%d %x\n", &index, &col);
								if (index > 255) index = 255;
								if (index < 0) index = 0;

								m_colMaps[m_numColMaps].m_colMap[colId].m_index = index;
								m_colMaps[m_numColMaps].m_colMap[colId].m_col = col;
								colId++;
							}
						}
						else if (!strcmpi(doc.GetNodeTag(node),"/Map"))
						{
							m_colMaps[m_numColMaps].m_numCols = colId;
							m_numColMaps++;
							break;
						}

						node = doc.GetNextNode(node);
					}
				}
			}

			node = doc.GetNextNode(node);
		}
		doc.Close();
	}

} // LoadSettings
Exemplo n.º 5
0
//-- LoadSettings -------------------------------------------------------------
//
//-----------------------------------------------------------------------------
void ShadeWorm_c::LoadSettings(const char* name)
{
	int colId;
	int index;
	int col;

	// Set up the defaults
	m_numWorms = 16;
	m_drawTime = 8;
	m_numColMaps = 0;
	m_randomColMap = false;

	XmlNode node;
	CXmlDocument doc;

	char contentPath[MAX_PATH];
	getDreamContentPath((char*)&contentPath);

	char szXMLFile[MAX_PATH];
	sprintf((char*)&szXMLFile, "%s\\%s", contentPath, "Resources\\Config.xml");

	// Load the config file
	if (doc.Load(szXMLFile) >= 0)
	{
		node = doc.GetNextNode(XML_ROOT_NODE);
		while(node > 0)
		{
			if (!_strcmpi(doc.GetNodeTag(node),"NumWorms"))
			{
				m_numWorms = atoi(doc.GetNodeText(node));
				Clamp(1, 32, m_numWorms);
			}
			else if (!_strcmpi(doc.GetNodeTag(node),"DrawTime"))
			{
				m_drawTime = atoi(doc.GetNodeText(node));
				Clamp(1, 10, m_drawTime);
			}
			else if (!_strcmpi(doc.GetNodeTag(node),"RandomColMap"))
			{
				m_randomColMap = !_strcmpi(doc.GetNodeText(node),"true");
			}
			else if (!_strcmpi(doc.GetNodeTag(node),"Map"))
			{
				node = doc.GetNextNode(node);

				if (m_numColMaps < MAX_COLMAPS)
				{

					colId = 0;
					m_colMaps[m_numColMaps].m_numCols = 0;
					m_colMaps[m_numColMaps].m_colMap = new ColMapEntry_t[256];

					while (node>0)
					{
						if (!_strcmpi(doc.GetNodeTag(node),"Col"))
						{
							if (colId < 256)
							{
								char* txt = doc.GetNodeText(node);

								sscanf(txt, "%d %x\n", &index, &col);
								if (index > 255) index = 255;
								if (index < 0) index = 0;

								m_colMaps[m_numColMaps].m_colMap[colId].m_index = index;
								m_colMaps[m_numColMaps].m_colMap[colId].m_col = col;
								colId++;
							}
						}
						else if (!_strcmpi(doc.GetNodeTag(node),"/Map"))
						{
							m_colMaps[m_numColMaps].m_numCols = colId;
							m_numColMaps++;
							break;
						}

						node = doc.GetNextNode(node);
					}
				}
			}

			node = doc.GetNextNode(node);
		}
		doc.Close();
	}

} // LoadSettings
Exemplo n.º 6
0
// Load settings from the [screensavername].xml configuration file
// the name of the screensaver (filename) is used as the name of
// the xml file - this is sent to us by XBMC when the Init func
// is called.
void LoadSettings()
{
    XmlNode node, childNode;
    CXmlDocument doc;

    char szXMLFile[1024];
    strcpy(szXMLFile, "Q:\\screensavers\\");
    strcat(szXMLFile, m_szScrName);
    strcat(szXMLFile, ".xml");

    OutputDebugString("Loading XML: ");
    OutputDebugString(szXMLFile);
    float xmin = -10.0f,
          xmax = 10.0f,
          ymin = -10.0f,
          ymax = 10.0f,
          height = 0.0f,
          elasticity = 0.5f,
          viscosity = 0.05f,
          tension = 1.0f,
          blendability = 0.04f;

    int xdivs = 50;
    int ydivs = 50;
    int divs = 50;

    SetDefaults();

    g_lightDir = D3DXVECTOR3(0.0f,0.6f,-0.8f);
    // Load the config file
    if (doc.Load(szXMLFile) >= 0)
    {
        node = doc.GetNextNode(XML_ROOT_NODE);
        while(node > 0)
        {
            if (strcmpi(doc.GetNodeTag(node),"screensaver"))
            {
                node = doc.GetNextNode(node);
                continue;
            }
            if (childNode = doc.GetChildNode(node,"wireframe")) {
                world.isWireframe = strcmp(doc.GetNodeText(childNode),"true") == 0;
            }
            if (childNode = doc.GetChildNode(node,"elasticity")) {
                elasticity = (float)atof(doc.GetNodeText(childNode));
            }
            if (childNode = doc.GetChildNode(node,"viscosity")) {
                viscosity = (float)atof(doc.GetNodeText(childNode));
            }
            if (childNode = doc.GetChildNode(node,"tension")) {
                tension = (float)atof(doc.GetNodeText(childNode));
            }
            if (childNode = doc.GetChildNode(node,"blendability")) {
                tension = (float)atof(doc.GetNodeText(childNode));
            }
            if (childNode = doc.GetChildNode(node,"xmin")) {
                xmin = (float)atof(doc.GetNodeText(childNode));
            }
            if (childNode = doc.GetChildNode(node,"xmax")) {
                xmax = (float)atof(doc.GetNodeText(childNode));
            }
            if (childNode = doc.GetChildNode(node,"ymin")) {
                ymin = (float)atof(doc.GetNodeText(childNode));
            }
            if (childNode = doc.GetChildNode(node,"ymax")) {
                ymax = (float)atof(doc.GetNodeText(childNode));
            }
            if (childNode = doc.GetChildNode(node,"lightx")) {
                g_lightDir.x = (float)atof(doc.GetNodeText(childNode));
            }
            if (childNode = doc.GetChildNode(node,"lighty")) {
                g_lightDir.y = (float)atof(doc.GetNodeText(childNode));
            }
            if (childNode = doc.GetChildNode(node,"lightz")) {
                g_lightDir.z = (float)atof(doc.GetNodeText(childNode));
            }
            if (childNode = doc.GetChildNode(node,"shininess")) {
                g_shininess = (float)atof(doc.GetNodeText(childNode));
            }
            if (childNode = doc.GetChildNode(node,"texturefolder")) {
                strcpy(world.szTextureSearchPath, doc.GetNodeText(childNode));
            }
            if (childNode = doc.GetChildNode(node,"texturemode")) {
                world.isTextureMode = strcmp(doc.GetNodeText(childNode),"true") == 0;
            }
            if (childNode = doc.GetChildNode(node,"nexttexture")) {
                world.nextTextureTime = (int)(30*(float)atof(doc.GetNodeText(childNode)));
            }
            if (childNode = doc.GetChildNode(node,"quality")) {
                divs = atoi(doc.GetNodeText(childNode));
            }
            node = doc.GetNextNode(node);
        }
        doc.Close();
    }
    float scaleRatio = (xmax-xmin)/(ymax-ymin);
    int totalPoints = (int)(divs * divs * scaleRatio);
    //world.scaleX = 0.5f;
    xdivs = (int)sqrt(totalPoints * scaleRatio / world.scaleX);
    ydivs = totalPoints / xdivs;
    //xdivs = 144; ydivs= 90;
    world.waterField = new WaterField(xmin, xmax, ymin, ymax, xdivs, ydivs, height, elasticity, viscosity, tension, blendability, world.isTextureMode);
}