Merge branch 'ryzom/deepl' into atys

ryzom/patch-changes
Ulukyn 4 years ago
commit 6597f32fc1

@ -422,6 +422,29 @@ CViewBase *CChatTextManager::createMsgTextComplex(const ucstring &msg, NLMISC::C
return para; return para;
} }
ucstring::size_type pos = 0;
// Manage Translations
string::size_type startTr = msg.find(ucstring("{:"));
string::size_type endOfOriginal = msg.find(ucstring("}@{"));
// Original/Translated case, example: {:enHello the world!}@{ Bonjour le monde !
if (startTr != string::npos && endOfOriginal != string::npos)
{
CViewBase *vt = createMsgTextSimple(msg.substr(0, startTr), col, justified, NULL);
para->addChild(vt);
string texture = "flag-"+toLower(msg.substr(startTr+2, 2)).toString()+".tga";
ucstring original = msg.substr(startTr+5, endOfOriginal-startTr-5);
pos = endOfOriginal+3;
CCtrlButton *ctrlButton = new CCtrlButton(CViewBase::TCtorParam());
ctrlButton->setTexture(texture);
ctrlButton->setTextureOver(texture);
ctrlButton->setTexturePushed(texture);
ctrlButton->setDefaultContextHelp(original);
ctrlButton->setId("tr");
para->addChild(ctrlButton);
}
// quickly check if text has links or not // quickly check if text has links or not
bool hasUrl; bool hasUrl;
@ -430,8 +453,7 @@ CViewBase *CChatTextManager::createMsgTextComplex(const ucstring &msg, NLMISC::C
hasUrl = (s.find(ucstring("http://")) || s.find(ucstring("https://"))); hasUrl = (s.find(ucstring("http://")) || s.find(ucstring("https://")));
} }
ucstring::size_type pos = 0; for (ucstring::size_type i = pos; i< textSize;)
for (ucstring::size_type i = 0; i< textSize;)
{ {
if (hasUrl && isUrlTag(msg, i, textSize)) if (hasUrl && isUrlTag(msg, i, textSize))
{ {

@ -843,6 +843,14 @@ void CGroupInSceneBubbleManager::chatOpen (uint32 nUID, const ucstring &ucsText,
if (pChar == NULL || nUID==CLFECOMMON::INVALID_CLIENT_DATASET_INDEX) return; if (pChar == NULL || nUID==CLFECOMMON::INVALID_CLIENT_DATASET_INDEX) return;
if (bubbleTimer == 0) bubbleTimer = CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionTimeoutBubbles).getValSInt32(); if (bubbleTimer == 0) bubbleTimer = CWidgetManager::getInstance()->getSystemOption(CWidgetManager::OptionTimeoutBubbles).getValSInt32();
// Clean bubble from translation system
ucstring::size_type pos = 0;
string::size_type endOfOriginal = ucsText.find(ucstring("}@{"));
if (endOfOriginal != string::npos)
pos = endOfOriginal+4;
// Output the message in a bubble // Output the message in a bubble
bool show = false; bool show = false;
@ -862,7 +870,7 @@ void CGroupInSceneBubbleManager::chatOpen (uint32 nUID, const ucstring &ucsText,
return; return;
// Get a bubble // Get a bubble
CGroupInSceneBubble *bubble = newBubble (ucsText); CGroupInSceneBubble *bubble = newBubble (ucsText.substr(pos));
if (bubble) if (bubble)
{ {
// Link the bubble // Link the bubble

Loading…
Cancel
Save