Exemple #1
0
//--------------------------------------------------------------------------
//	功能:初始化
//--------------------------------------------------------------------------
int KUiBase::Init()
{
	if (g_pIme)
	{
		g_pIme->DisableLanguageChange();
		g_pIme->CloseIME();
		g_pIme->TurnOn();
	}

	KIniFile* pSetting = GetCommSettingFile();
	char	SchemeName[32] = "";
	int		nInterval = 20;
	if (pSetting)
	{
		pSetting->GetString("Main", "LastUsedScheme", "", SchemeName, 32);
		pSetting->GetInteger("Main", "WndMoveInterval", 20, &nInterval);
		#ifdef _DEBUG
			int	nValue;
			pSetting->GetInteger("Main", "ShowDebugFrameText", 0, &nValue);
			WND_SHOW_DEBUG_FRAME_TEXT = nValue;
			pSetting->GetInteger("Main", "ShowMouseOverWnd", 0, &nValue);
			WND_SHOW_MOUSE_OVER_WND = nValue;
		#endif
			CloseCommSettingFile(false);
	}
	g_CreatePath(UI_USER_DATA_FOLDER);
	g_CreatePath(UI_USER_DATA_TEMP_FOLDER);
	KWndShowAnimate::SetInterval(nInterval);
	LoadScheme(SchemeName);
	return true;
}
Exemple #2
0
//---------------------------------------------------------------------------
// 功能:	创建一个文件,准备写入。
// 参数:	FileName	文件名
// 返回:	成功返回TRUE,失败返回FALSE。
//---------------------------------------------------------------------------
QAloneFile*	QAloneFile::Create(const char*  FileName)
{
	FILE* pFile = NULL;

	char FullPathName[MAX_PATH] = "";
	g_GetFullPath(FullPathName, FileName);
#ifdef unix
	{
		char *ptr = FullPathName;
		while(*ptr)
		{
			if (*ptr == '\\')
				*ptr = '/';
			ptr++;
		}
	}
#endif	// #ifdef unix
	char PathName[MAX_PATH] = "";
	g_ExtractFilePath(PathName, FullPathName);
	g_CreatePath(PathName);
	pFile = fopen(FullPathName, "wb+");
#ifdef unix
	{
		if (pFile == NULL)
		{
			QStrLower(FullPathName);
			pFile = fopen(FullPathName, "wb+");
		}
	}
#endif	// #ifdef unix

	return pFile ? new QAloneFile(pFile) : NULL;
}
Exemple #3
0
//--------------------------------------------------------------------------
//	功能:获得当前玩家账号在界面系统中的id
//--------------------------------------------------------------------------
int KUiBase::GetUserPrivateDataFolder(char* pBuffer, int nSize)
{
	char	szBuffer[128];
	sprintf(szBuffer, "%s\\%s\\", UI_USER_DATA_FOLDER, m_UserAccountId);
	g_CreatePath(szBuffer);
	if (pBuffer && nSize > (int)(strlen(szBuffer)))
	{
		strcpy(pBuffer, szBuffer);
		return true;
	}
	return false;
}
Exemple #4
0
//--------------------------------------------------------------------------
//	功能:关闭打开当前账号的设置文件
//--------------------------------------------------------------------------
void KUiBase::ClosePrivateSettingFile(bool bSave)
{
	if (m_pUiPrivateSettingFile)
	{
		if (bSave && m_UserAccountId[0])
		{
			char	FileName[128];
			sprintf(FileName, "%s\\%s", UI_USER_DATA_FOLDER, m_UserAccountId);
			g_CreatePath(FileName);
			strcat(FileName, "\\");
			strcat(FileName, UI_PRIVATE_SETTING_FILE);
			m_pUiPrivateSettingFile->Save(FileName);
		}
		delete(m_pUiPrivateSettingFile);
		m_pUiPrivateSettingFile = NULL;
	}
}
Exemple #5
0
/**
 * @brief 获取账号设置文件
 */
KIniFile* KUiBase::GetAccountSettingFile(char* szAccount)
{
	if(szAccount && szAccount[0])
	{
		unsigned int uID1 =  g_FileName2Id(szAccount);
		unsigned int uID2 =  g_FileName2Id(UI_USER_DATA_FOLDER);
		sprintf(m_szAccountSettingFilePath, "%s\\%u\\", UI_USER_DATA_FOLDER, uID2);
		g_CreatePath(m_szAccountSettingFilePath);
		sprintf(m_szAccountSettingFilePath, "%s\\%u.ini", m_szAccountSettingFilePath, uID1);
		if(m_pAccountSettingFile)
		{
			m_pAccountSettingFile->Clear();
		}
		else
		{
			m_pAccountSettingFile = new KIniFile;
		}
		if(m_pAccountSettingFile)
		{
			m_pAccountSettingFile->Load(m_szAccountSettingFilePath);
		}
	}
	return m_pAccountSettingFile;
}
Exemple #6
0
//从包中解出全部文件
bool KPackFileManager::UnpackAll(int nPakIndex, int& nUnpackCount, const char* pDestPath, const char* pFileNamePrefix)
{
	nUnpackCount = 0;
	if (pFileNamePrefix == NULL)
		pFileNamePrefix = "";

	if (nPakIndex < 0 || nPakIndex >= PACK_FILE_SHELL_MAX_SUPPORT_PAK_NUM || !m_PackItemList[nPakIndex].pIOFile ||
		pDestPath == NULL || pDestPath[0] == 0)
	{
		return false;
	}
	int		nFileNameStartOffset = strlen(pDestPath);
	if (nFileNameStartOffset + 128 > MAX_PATH)
		return false;

	g_CreatePath(pDestPath);
	char	szFullName[MAX_PATH] = "";
	char*	pElemName = NULL;
	strcpy(szFullName, pDestPath);
	if (szFullName[nFileNameStartOffset - 1] == '\\')		/// 文件名都是带有'\\'的,eg:\image\effect\sfx\关卡\地狱鬼手.3e
	{
		pElemName = szFullName + nFileNameStartOffset - 1;
	}
	else
	{
		pElemName = szFullName + nFileNameStartOffset;
	}

	ELEM_FILE_INFO	info;
	info.nPakIndex = nPakIndex;
	PACK_ITEM& item = m_PackItemList[nPakIndex];

	for (info.nElemIndex = 0; info.nElemIndex < (int)item.Header.uCount; info.nElemIndex++)
	{
		XPackIndexInfo& IndexInfo = item.pIndexList[info.nElemIndex];
		info.uId = IndexInfo.uId;
	
		KPackFilePartner::PACKPARTNER_ELEM_INFO	PartnerInfo;
		if (m_PackPartnerList[info.nPakIndex].GetElemInfo(info.uId, PartnerInfo))
		{
			if (pFileNamePrefix[0])
			{
				if (strstr(PartnerInfo.szFileName, pFileNamePrefix) != PartnerInfo.szFileName)
					continue;	//排除前缀不符合的文件
			}
			strcpy(info.szFileName, PartnerInfo.szFileName);
			info.uCRC = PartnerInfo.uCRC;
			info.uTime = PartnerInfo.uTime;
		}
		else
		{
			if (pFileNamePrefix[0])
				continue;
			sprintf(info.szFileName, "\\_-ID-_%08x", info.uId);		///这边没看懂(以ID作为名字)
			info.uCRC = 0;
			info.uTime = 0;
		}
//		info.uCompressFlag = (IndexInfo.uCompressSizeFlag & (~XPACK_COMPRESS_SIZE_FILTER));
//		info.uSize = IndexInfo.uSize;
//		info.uStoreSize = (IndexInfo.uCompressSizeFlag & XPACK_COMPRESS_SIZE_FILTER);

		strcpy(pElemName, info.szFileName);				/// 路径 + 文件名
		char* pLastSplit = strrchr(pElemName, '\\');	/// 查找字符在指定字符串中从后面开始的第一次出现的位置  <---> strchr
		if (pLastSplit && pLastSplit != pElemName)		/// 对文件夹的处理?:文件名可以是带有目录的形式,eg: \image\dc\B2_M7_1.Mtl
		{
			*pLastSplit = 0;
			g_CreatePath(szFullName);			
			*pLastSplit = '\\';
		}
		//----解开存盘----
		UnpackElemByIndex(nPakIndex, info.nElemIndex, szFullName);

		//----修改文件时间----
		if (info.uTime)
		{
			_utimbuf time;
			time.actime = time.modtime = info.uTime;
			_utime(szFullName, &time);
		}

		nUnpackCount++;
	}
	return true;
}