From bccc86bd996b4ceedada6e49dc45b9c860609969 Mon Sep 17 00:00:00 2001 From: Sit Melai Date: Sat, 15 Aug 2020 18:51:20 +0200 Subject: [PATCH] Added option to show the translation as a tooltip and original by default --- .../src/interface_v3/chat_text_manager.cpp | 17 +++++++++++++-- .../interface_v3/group_in_scene_bubble.cpp | 21 ++++++++++++++++--- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/chat_text_manager.cpp b/code/ryzom/client/src/interface_v3/chat_text_manager.cpp index b3a673ffe..ec0aee822 100644 --- a/code/ryzom/client/src/interface_v3/chat_text_manager.cpp +++ b/code/ryzom/client/src/interface_v3/chat_text_manager.cpp @@ -425,6 +425,9 @@ CViewBase *CChatTextManager::createMsgTextComplex(const ucstring &msg, NLMISC::C ucstring::size_type pos = 0; // 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 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"; ucstring original = msg.substr(startTr+5, endOfOriginal-startTr-5); - pos = endOfOriginal+3; + ucstring translation = msg.substr(endOfOriginal+3); CCtrlButton *ctrlButton = new CCtrlButton(CViewBase::TCtorParam()); ctrlButton->setTexture(texture); ctrlButton->setTextureOver(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"); para->addChild(ctrlButton); } diff --git a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp index 460a095fc..2276eb506 100644 --- a/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp +++ b/code/ryzom/client/src/interface_v3/group_in_scene_bubble.cpp @@ -846,11 +846,26 @@ void CGroupInSceneBubbleManager::chatOpen (uint32 nUID, const ucstring &ucsText, // 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 textSize = ucsText.size(); + string::size_type startTr = ucsText.find(ucstring("{:")); string::size_type endOfOriginal = ucsText.find(ucstring("}@{")); if (endOfOriginal != string::npos) - pos = endOfOriginal+4; - + { + if (!originalFirst) + { + pos = endOfOriginal+4; + } + else + { + pos = startTr+5; + textSize = endOfOriginal; + } + } + // Output the message in a bubble bool show = false; @@ -870,7 +885,7 @@ void CGroupInSceneBubbleManager::chatOpen (uint32 nUID, const ucstring &ucsText, return; // Get a bubble - CGroupInSceneBubble *bubble = newBubble (ucsText.substr(pos)); + CGroupInSceneBubble *bubble = newBubble (ucsText.substr(pos, textSize-pos)); if (bubble) { // Link the bubble