Exemplo n.º 1
0
SyncBool TLFileSys::TFileTextDatabase::ImportText_ImportLanguageText(TPtr<TLAsset::TText>& pText, TPtr<TXmlTag>& pImportTag, TRefRef TextRef)
{
/*
	<Text TextRef="VolMus">
		<eng>Music Volume</eng>		
		<usa>Music Volume</usa>		
		<fre>Music Volume</fre>		
	</Text>
*/

	//	temporary string to put a cleaner data stirng into
	TString TempString;	

	// Now get the children of the text tag and process them
	for ( u32 index=0;	index< pImportTag->GetChildren().GetSize();	index++ )
	{
		TPtr<TXmlTag>& pTextTag = pImportTag->GetChildren().ElementAt(index);
		
		// The child tag name is the language ref
		TRef LanguageRef(pTextTag->GetTagName());

		if(!LanguageRef.IsValid())
		{
			TLDebug_Print("Failed to get valid language ref from TTD file");
			return SyncFalse;
		}

		// Now get the text string
		const TString& DataString = pTextTag->GetDataString();

		//	if the data string is dirty (needs line feed conversion etc) then convert it into a new string
		Bool IsDataStringDirty = TLString::IsStringDirty( DataString );
		if ( IsDataStringDirty )
		{
			TempString = DataString;
			TLString::CleanString( TempString );
		}

		//	final [clean] string
		const TString& TextString = IsDataStringDirty ? TempString : DataString;

		// And add to the text object
		if(!pText->AddText(LanguageRef, TextRef, TextString))
		{
			TLDebug_Break("Failed to add text string to text object");
		}
	}


	return SyncTrue;
}
Exemplo n.º 2
0
SyncBool TLFileSys::TFileTextDatabase::GenerateTextAllLanguages(TPtr<TLAsset::TText>&pText, TRefRef TextRef)
{
	// Add the text ref as text for each language
	TArray<TRef>& SupportedLanguages = TLText::g_pTextManager->GetSupportedLanguages();

	// Get the ref as a string
	TString TextString;
	TextRef.GetString(TextString);

	for(u32 uIndex = 0; uIndex < SupportedLanguages.GetSize(); uIndex++)
	{
		// Get the language
		
		TRef LanguageRef = SupportedLanguages.ElementAt(uIndex);
		
		// Add to the text object
		if(!pText->AddText(LanguageRef, TextRef, TextString))
		{
			TLDebug_Print("Failed to add text string to text object");
		}
	}

	return SyncTrue;
}