Example #1
0
bool CvXMLLoadUtilityModTools::isExcludedFile(const char* szLocationName)
{
	CvString szLocationNameStripDot = szLocationName;
	CvString szLocationNameStripTemp = szLocationName;	

	string::size_type posDot = szLocationNameStripDot.find_last_of('.');

	if(posDot != string::npos) 
	{		
		//force lowercase for comparison
		int length = szLocationNameStripDot.size();
		for (int i = 0; i < length; ++i)
		{
			szLocationNameStripTemp[length - (i + 1)] = tolower(szLocationNameStripDot[i]);
		}
		string::size_type posDot = szLocationNameStripTemp.find_last_of('.');
		//delete everything after first dir
		szLocationNameStripTemp.erase(posDot);
		//compare
		if ( szLocationNameStripTemp == "mht" )  //if its a thema file, force static linking
		{
#ifdef _DEBUG
		CvXMLLoadUtility* p_szLogWrite = new CvXMLLoadUtility;
		p_szLogWrite->XmlArtTagVerification("You are now loading an alternative theme: %s", szLocationName);
		SAFE_DELETE(p_szLogWrite);
#endif
			return true;
		}
	}
	return false;
}
Example #2
0
void CvXMLLoadUtilityModTools::writeThm(const char* szTextVal)
{	
	CvString tszTextVal = szTextVal;
	int posCut;
	string::size_type posBackSlash = tszTextVal.find_last_of('\\');
	string::size_type posSlashForw = tszTextVal.find_last_of('/');

	if (posBackSlash > posSlashForw)
	{
		posCut = posBackSlash;
	}
	else
	{
		posCut = posSlashForw;
	}

	if(posCut != string::npos) 
	{
		tszTextVal.erase(posCut);
	}
	else
	{
		FAssertMsg(false, "Something went wrong with the Theme file");
	}
	
	FILE *pFile = fopen(szTextVal, "w");

	if (pFile == NULL) 
	{
/*
#ifdef _DEBUG
		CvString szPrint = GetProgramDir();
		szPrint.append(szTextVal);
		CvXMLLoadUtility* p_szLogWrite = new CvXMLLoadUtility;
		p_szLogWrite->XmlArtTagVerification("Your Theme file: %s seems to be corrupted", szPrint.GetCString());
		SAFE_DELETE(p_szLogWrite);
#endif
*/
	}
	
	//set the proper string to write to the Theme file	
	CvString szOutput = "resource_path\t";	
	szOutput.append("\"");
	szOutput.append(tszTextVal);
	szOutput.append("\";\n");
	szOutput.append("\n");
	szOutput.append("include\t");
	szOutput.append("\"");
	szOutput.append(tszTextVal);
	szOutput.append("\\Themes\\Civ4\\Civ4Theme.thm");	
	szOutput.append("\";\n");

	//write the file
	fputs(szOutput, pFile);
	fclose(pFile);
}
Example #3
0
CvString CvXMLLoadUtilityModTools::deleteFileName(const char* szDirName, const char szLocateChar)
{	
	CvString szDirNameStrip = szDirName;
	string::size_type pos = szDirNameStrip.find_last_of(szLocateChar);
	if(pos != string::npos) 
	{
		szDirNameStrip.erase(pos + 1);
	}
	else
	{
		FAssertMsg(false, "Couldn't find the directory slash")
	}

	return szDirNameStrip;
}
Example #4
0
// Fully based on CString
CvString CvXMLLoadUtilityModTools::GetProgramDir()
{
	CvString szExeLocation = _pgmptr;
	if ( szExeLocation == NULL)
	{
		FAssertMsg(false, "Not running Stdlib Compatible Operating System?");
	}
	
	string::size_type posDot = szExeLocation.find_last_of('\\');

	if(posDot != string::npos) 
	{
		szExeLocation.erase(posDot + 1);
	}

	return szExeLocation;
}