Esempio 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;
}
Esempio 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;
}