Merge branch 'translation-original-message-by-default-option' into yubo

merge-requests/7/merge
Ulukyn 4 years ago
commit 006ab4fb46

@ -425,6 +425,9 @@ CViewBase *CChatTextManager::createMsgTextComplex(const ucstring &msg, NLMISC::C
ucstring::size_type pos = 0; ucstring::size_type pos = 0;
// Manage Translations // Manage Translations
CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_TRANSLATION_ONLY_AS_TOOLTIP_CB", false);
bool originalFirst = node->getValueBool();
string::size_type startTr = msg.find(ucstring("{:")); string::size_type startTr = msg.find(ucstring("{:"));
string::size_type endOfOriginal = msg.find(ucstring("}@{")); string::size_type endOfOriginal = msg.find(ucstring("}@{"));
@ -436,12 +439,22 @@ CViewBase *CChatTextManager::createMsgTextComplex(const ucstring &msg, NLMISC::C
string texture = "flag-"+toLower(msg.substr(startTr+2, 2)).toString()+".tga"; string texture = "flag-"+toLower(msg.substr(startTr+2, 2)).toString()+".tga";
ucstring original = msg.substr(startTr+5, endOfOriginal-startTr-5); ucstring original = msg.substr(startTr+5, endOfOriginal-startTr-5);
pos = endOfOriginal+3; ucstring translation = msg.substr(endOfOriginal+3);
CCtrlButton *ctrlButton = new CCtrlButton(CViewBase::TCtorParam()); CCtrlButton *ctrlButton = new CCtrlButton(CViewBase::TCtorParam());
ctrlButton->setTexture(texture); ctrlButton->setTexture(texture);
ctrlButton->setTextureOver(texture); ctrlButton->setTextureOver(texture);
ctrlButton->setTexturePushed(texture); ctrlButton->setTexturePushed(texture);
ctrlButton->setDefaultContextHelp(original); if (!originalFirst)
{
ctrlButton->setDefaultContextHelp(original);
pos = endOfOriginal+3;
}
else
{
ctrlButton->setDefaultContextHelp(translation);
pos = startTr+5;
textSize = endOfOriginal;
}
ctrlButton->setId("tr"); ctrlButton->setId("tr");
para->addChild(ctrlButton); para->addChild(ctrlButton);
} }

@ -846,10 +846,25 @@ void CGroupInSceneBubbleManager::chatOpen (uint32 nUID, const ucstring &ucsText,
// Clean bubble from translation system // Clean bubble from translation system
CCDBNodeLeaf *node= NLGUI::CDBManager::getInstance()->getDbProp("UI:SAVE:CHAT:SHOW_TRANSLATION_ONLY_AS_TOOLTIP_CB", false);
bool originalFirst = node->getValueBool();
ucstring::size_type pos = 0; ucstring::size_type pos = 0;
ucstring::size_type textSize = ucsText.size();
string::size_type startTr = ucsText.find(ucstring("{:"));
string::size_type endOfOriginal = ucsText.find(ucstring("}@{")); string::size_type endOfOriginal = ucsText.find(ucstring("}@{"));
if (endOfOriginal != string::npos) if (endOfOriginal != string::npos)
pos = endOfOriginal+4; {
if (!originalFirst)
{
pos = endOfOriginal+4;
}
else
{
pos = startTr+5;
textSize = endOfOriginal;
}
}
// Output the message in a bubble // Output the message in a bubble
@ -870,7 +885,7 @@ void CGroupInSceneBubbleManager::chatOpen (uint32 nUID, const ucstring &ucsText,
return; return;
// Get a bubble // Get a bubble
CGroupInSceneBubble *bubble = newBubble (ucsText.substr(pos)); CGroupInSceneBubble *bubble = newBubble (ucsText.substr(pos, textSize-pos));
if (bubble) if (bubble)
{ {
// Link the bubble // Link the bubble

Loading…
Cancel
Save