Пример #1
0
BOOL CMyBCGPProp::TextToVar(const CString& strText)
{
	BOOL bRet = CBCGPProp::TextToVar(strText);
	if (bRet)
	{
		if ((m_dwFlags & PROP_HAS_SPIN) && m_varValue.vt == VT_INT)
		{
			if (m_varValue.intVal < m_nMinValue)
			{
				m_varValue.intVal = m_nMinValue;
			}
			if (m_varValue.intVal > m_nMaxValue)
			{
				m_varValue.intVal = m_nMaxValue;
			}
		}
		else if (IsText())
		{
			if (strText.Find('-') != -1)
			{
				CString strNewText(strText);
				strNewText.Replace('-', '_');

				m_varValue = (LPCTSTR)strNewText;
			}
		}
	}
	return bRet;
}
Пример #2
0
static void EnterRef(LPCSTR psReference, LPCSTR psText, LPCSTR psMenuFile)
{
	// special hack, StripEd text at this point will have had any "\n" LITERALS replaced by the 0x0D 0x0A pair,
	//	so we need to put them back to "\n" text ready for saving out into StripEd files again...
	//
	string	strNewText( psText );
	//
	// not sure whether just 0x0A or 0x0D/0x0A pairs (sigh), so first, eliminate 0x0Ds...
	//
	int iLoc;
	while ( (iLoc = strNewText.find(0x0D,0)) != -1)
	{
		strNewText.replace(iLoc, 1, "");
	}
	// now replace any 0x0As with literal "\n" strings...
	//
	while ( (iLoc = strNewText.find(0x0A,0)) != -1)
	{
		strNewText.replace(iLoc, 1, "\\n");
	}
	psText = strNewText.c_str();

	// curiousity...
	//
	static int iLongestText = 0;
	if (iLongestText < strlen(psText))
	{
		iLongestText = strlen(psText);
		OutputDebugString(va("Longest StripEd text: %d\n",iLongestText));
	}



	typedef map <sstringBIG_t, sstring_t> TextConsolidationTable_t;	// string and ref
	static TextConsolidationTable_t TextConsolidationTable, RefrConsolidationTable;
	static int iIndex = 0;	// INC'd every time a new StripEd entry is synthesised

	TextConsolidationTable_t::iterator it = TextConsolidationTable.find(psText);
	if (it == TextConsolidationTable.end())
	{
		// new entry...
		//
		LPCSTR psNewReference = CreateUniqueReference( (strlen(psReference) > strlen(psText))?psReference:psText  );

		CorrectionDataItem_t	CorrectionDataItem;
								CorrectionDataItem.sMenuFile			= psMenuFile;
								CorrectionDataItem.sTextToFind			= strlen(psReference) ? ( /* !stricmp(psReference,psNewReference) ? "" :*/ va("@%s",psReference) )
																			: va("\"%s\"",psText);
								CorrectionDataItem.sTextToReplaceWith	= /* !stricmp(psReference,psNewReference) ? "" : */va("@%s",psNewReference);
								//
								CorrectionDataItem.sStripEdReference	= psNewReference;
								CorrectionDataItem.sStripEdText			= psText;

//		qboolean bIsMulti = !!strstr(psMenuFile,"jk2mp");
//								CorrectionDataItem.sStripEdFileRef		= va("%sMENUS%d",bIsMulti?"MP":"SP",iIndex/256);
								CorrectionDataItem.sStripEdFileRef		= va(  "MENUS%d",iIndex/256);
		iIndex++;

		CorrectionData.push_back( CorrectionDataItem );

		TextConsolidationTable[ psText ] = psNewReference;
		RefrConsolidationTable[ psText ] = CorrectionDataItem.sStripEdFileRef.c_str();
	}
	else
	{
		// text already entered, so do a little duplicate-resolving...
		//
		// need to find the reference for the existing version...
		//
		LPCSTR psNewReference = (*it).second.c_str();
		LPCSTR psPackageRef	  = (*RefrConsolidationTable.find(psText)).second.c_str();	// yeuch, hack-city

		// only enter correction data if references are different...
		//
//		if (stricmp(psReference,psNewReference))
		{
			CorrectionDataItem_t	CorrectionDataItem;
									CorrectionDataItem.sMenuFile			= psMenuFile;
									CorrectionDataItem.sTextToFind			= strlen(psReference) ? va("@%s",psReference) : va("\"%s\"",psText);
									CorrectionDataItem.sTextToReplaceWith	= va("@%s",psNewReference);
									//
									CorrectionDataItem.sStripEdReference	= "";
									CorrectionDataItem.sStripEdText			= "";
									CorrectionDataItem.sStripEdFileRef		= psPackageRef;


			CorrectionData.push_back( CorrectionDataItem );
		}
	}
}