Esempio n. 1
0
bool EngineApp::LoadStrings( std::string language )
   {
	std::string languageFile = "Strings\\";
	languageFile += language;
	languageFile += ".xml";
   Resource languageRes( languageFile, g_pApp->m_EngineOptions.GetIsUsingDevDirectory() );
   TiXmlElement* pRoot = XmlResourceLoader::LoadAndReturnRootXmlElement( languageRes );
	// load failed
   if ( !pRoot )
	   {
		ENG_ERROR("Strings are missing.");
		return false;
	   }

    // Loop through each child element and load the component
    for ( TiXmlElement* pElem = pRoot->FirstChildElement(); pElem; pElem = pElem->NextSiblingElement() )
      {
		const char *pKey = pElem->Attribute( "id" );
		const char *pText = pElem->Attribute( "value" );
		if( pKey && pText ) 
		   {
			wchar_t wideKey[64];
			wchar_t wideText[1024];
			AnsiToWideCch(wideKey, pKey, 64);
			AnsiToWideCch(wideText, pText, 1024);
			m_textResource[ std::wstring(wideKey) ] = std::wstring(wideText);
		   }
	   }
	return true;
   }
Esempio n. 2
0
//-----------------------------------------------------------------------------
// Name: AnsiToGeneric()
// Desc: This is a UNICODE conversion utility to convert a CHAR string into a
//       TCHAR string. 
//       cchDestChar is the size in TCHARs of tstrDestination.  Be careful not to 
//       pass in sizeof(strDest) on UNICODE builds
//-----------------------------------------------------------------------------
bool StringHelper::AnsiToGenericCch(TCHAR* tstrDestination, const char* strSource,
	int cchDestChar)
{
	if (tstrDestination == NULL || strSource == NULL || cchDestChar < 1)
		return false;

#ifdef _UNICODE
	return AnsiToWideCch(tstrDestination, strSource, cchDestChar);
#else
	strncpy(tstrDestination, strSource, cchDestChar);
	tstrDestination[cchDestChar - 1] = '\0';
	return true;
#endif    
}
Esempio n. 3
0
//-----------------------------------------------------------------------------
// Name: GenericToWide()
// Desc: This is a UNICODE conversion utility to convert a TCHAR string into a
//       WCHAR string. 
//       cchDestChar is the size in TCHARs of wstrDestination.  Be careful not to 
//       pass in sizeof(strDest) 
//-----------------------------------------------------------------------------
bool StringHelper::GenericToWideCch(wchar_t* wstrDestination, const TCHAR* tstrSource,
	int cchDestChar)
{
	if (wstrDestination == NULL || tstrSource == NULL || cchDestChar < 1)
		return false;

#ifdef _UNICODE
	wcsncpy(wstrDestination, tstrSource, cchDestChar);
	wstrDestination[cchDestChar - 1] = L'\0';
	return true;
#else
	return AnsiToWideCch(wstrDestination, tstrSource, cchDestChar);
#endif    
}