From 6149ce350ab27ba70ddb46a2976473fa7f371531 Mon Sep 17 00:00:00 2001 From: elektrahesse Date: Wed, 15 Sep 2010 20:43:38 +0200 Subject: Added TAB as name completion hotkey, to be used after at least 3 chars otherwise it reverts to the default widgets-switching behaviour --- linden/indra/newview/llchatbar.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'linden/indra') diff --git a/linden/indra/newview/llchatbar.cpp b/linden/indra/newview/llchatbar.cpp index 92340ec..2009905 100644 --- a/linden/indra/newview/llchatbar.cpp +++ b/linden/indra/newview/llchatbar.cpp @@ -206,7 +206,8 @@ BOOL LLChatBar::handleKeyHere( KEY key, MASK mask ) stopChat(); handled = TRUE; } - else if (key == KEY_ESCAPE && mask == MASK_CONTROL && gChatBar == this) + // else if (key == KEY_ESCAPE && mask == MASK_CONTROL && gChatBar == this) + else if (key == KEY_TAB && gChatBar == this) { if (mInputEditor) { -- cgit v1.1 From 74363f85fa96f76c0ba83586a0d97af35bed4b4a Mon Sep 17 00:00:00 2001 From: elektrahesse Date: Wed, 15 Sep 2010 21:14:55 +0200 Subject: Added more punctuation support to both names autocomplete and names highlight in chat --- linden/indra/newview/llchatbar.cpp | 2 +- linden/indra/newview/llfloaterchat.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'linden/indra') diff --git a/linden/indra/newview/llchatbar.cpp b/linden/indra/newview/llchatbar.cpp index 2009905..c7391d9 100644 --- a/linden/indra/newview/llchatbar.cpp +++ b/linden/indra/newview/llchatbar.cpp @@ -236,7 +236,7 @@ BOOL LLChatBar::handleKeyHere( KEY key, MASK mask ) left_part = txt; } - std::string pattern_s = "(^|.*[\\.\\?!:;,\\*\\(\\s]+)([a-z0-9]+)$"; + std::string pattern_s = "(^|.*[_=&\\|\\<\\>#@\\[\\]\\-\\+\"',\\.\\?!:;\\*\\(\\)\\s]+)([a-z0-9]+)$"; boost::match_results what; boost::regex expression(pattern_s, boost::regex::icase); if (boost::regex_search(to_match, what, expression, boost::match_extra)) diff --git a/linden/indra/newview/llfloaterchat.cpp b/linden/indra/newview/llfloaterchat.cpp index b1c1356..f352926 100644 --- a/linden/indra/newview/llfloaterchat.cpp +++ b/linden/indra/newview/llfloaterchat.cpp @@ -456,7 +456,7 @@ void LLFloaterChat::updateSettings() BOOL LLFloaterChat::isOwnNameInText(const std::string &text_line) { std::string my_name = gSavedSettings.getString("FirstName"); - std::string pattern_s = "(^|.*[',\\.\\?!:;\\*\\(\\s]+)(" + my_name + ")([',\\.\\?!:;\\*\\)\\s]+.*|$)"; + std::string pattern_s = "(^|.*[_=&\\|\\<\\>#@\\[\\]\\-\\+\"',\\.\\?!:;\\*\\(\\)\\s]+)(" + my_name + ")([_=&\\|\\<\\>#@\\[\\]\\-\\+\"',\\.\\?!:;\\*\\(\\)\\s]+.*|$)"; boost::smatch what; boost::regex e1(pattern_s, boost::regex::icase); -- cgit v1.1 From fcc21b7f78a63f07630c69207e6da9455ee2f87b Mon Sep 17 00:00:00 2001 From: elektrahesse Date: Wed, 15 Sep 2010 23:46:09 +0200 Subject: Added support for autocompletion of names also in the 'local chat' window --- linden/indra/newview/llchatbar.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'linden/indra') diff --git a/linden/indra/newview/llchatbar.cpp b/linden/indra/newview/llchatbar.cpp index c7391d9..8015e10 100644 --- a/linden/indra/newview/llchatbar.cpp +++ b/linden/indra/newview/llchatbar.cpp @@ -206,8 +206,7 @@ BOOL LLChatBar::handleKeyHere( KEY key, MASK mask ) stopChat(); handled = TRUE; } - // else if (key == KEY_ESCAPE && mask == MASK_CONTROL && gChatBar == this) - else if (key == KEY_TAB && gChatBar == this) + else if (key == KEY_TAB) { if (mInputEditor) { -- cgit v1.1 From 79f7c4c58e355fe78114a940d8c6efcd1e3ff15d Mon Sep 17 00:00:00 2001 From: elektrahesse Date: Thu, 16 Sep 2010 12:39:58 +0200 Subject: Added CHAT_NORMAL_RADIUS check for autocompletion and deleted selection of last part upon new autocomplete attempt --- linden/indra/newview/llchatbar.cpp | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'linden/indra') diff --git a/linden/indra/newview/llchatbar.cpp b/linden/indra/newview/llchatbar.cpp index 8015e10..875153a 100644 --- a/linden/indra/newview/llchatbar.cpp +++ b/linden/indra/newview/llchatbar.cpp @@ -68,6 +68,7 @@ #include "llmultigesture.h" #include "llui.h" #include "lluictrlfactory.h" +#include "llvoavatar.h" #include "chatbar_as_cmdline.h" @@ -216,6 +217,8 @@ BOOL LLChatBar::handleKeyHere( KEY key, MASK mask ) if (!avatar_ids.empty()) { + mInputEditor->deleteSelection(); // Clean up prev completion before attempting a new one + std::string txt(mInputEditor->getText()); std::string to_match(txt); @@ -251,12 +254,23 @@ BOOL LLChatBar::handleKeyHere( KEY key, MASK mask ) { if (avatar_ids[i] == gAgent.getID() || avatar_ids[i].isNull()) continue; -/* - // Commented out for now... doesn't work above 1024 meters as usual + + // Grab the pos again from the objects-in-view cache... LLWorld doesn't work above 1024 meters as usual :( + LLVector3d real_pos = positions[i]; + if (real_pos[2] == 0.0f) + { + LLViewerObject *av_obj = gObjectList.findObject(avatar_ids[i]); + if (av_obj != NULL && av_obj->isAvatar()) + { + LLVOAvatar* avatarp = (LLVOAvatar*)av_obj; + if (avatarp != NULL) + real_pos = avatarp->getPositionGlobal(); + } + } + F32 dist = F32(dist_vec(positions[i], gAgent.getPositionGlobal())); if (dist > CHAT_NORMAL_RADIUS) continue; -*/ std::string agent_name = " "; std::string agent_surname = " "; -- cgit v1.1 From 93b9816a3e9b2318024661d57ba44abca6ce23c2 Mon Sep 17 00:00:00 2001 From: elektrahesse Date: Thu, 16 Sep 2010 16:32:20 +0200 Subject: Added names cycling using TAB. Only 1 char now necessary to trigger completion. Otherwise TAB reverts to cycle through widgets. --- linden/indra/newview/llchatbar.cpp | 79 +++++++++++++++++++++++--------------- linden/indra/newview/llchatbar.h | 4 ++ 2 files changed, 53 insertions(+), 30 deletions(-) (limited to 'linden/indra') diff --git a/linden/indra/newview/llchatbar.cpp b/linden/indra/newview/llchatbar.cpp index 875153a..52397b4 100644 --- a/linden/indra/newview/llchatbar.cpp +++ b/linden/indra/newview/llchatbar.cpp @@ -115,7 +115,10 @@ LLChatBar::LLChatBar() mObserver(NULL) { setIsChrome(TRUE); - + + current_index = 0; + last_initials = ""; + #if !LL_RELEASE_FOR_DOWNLOAD childDisplayNotFound(); #endif @@ -220,7 +223,6 @@ BOOL LLChatBar::handleKeyHere( KEY key, MASK mask ) mInputEditor->deleteSelection(); // Clean up prev completion before attempting a new one std::string txt(mInputEditor->getText()); - std::string to_match(txt); std::string left_part = ""; std::string right_part = ""; @@ -244,51 +246,68 @@ BOOL LLChatBar::handleKeyHere( KEY key, MASK mask ) if (boost::regex_search(to_match, what, expression, boost::match_extra)) { to_match = what[2]; - if (to_match.length() < 3) + if (to_match.length() < 1) return handled; } else return handled; - for (U32 i=0; iisAvatar()) + if (avatar_ids[i] == gAgent.getID() || avatar_ids[i].isNull()) + continue; + + // Grab the pos again from the objects-in-view cache... LLWorld doesn't work above 1024 meters as usual :( + LLVector3d real_pos = positions[i]; + if (real_pos[2] == 0.0f) { - LLVOAvatar* avatarp = (LLVOAvatar*)av_obj; - if (avatarp != NULL) - real_pos = avatarp->getPositionGlobal(); + LLViewerObject *av_obj = gObjectList.findObject(avatar_ids[i]); + if (av_obj != NULL && av_obj->isAvatar()) + { + LLVOAvatar* avatarp = (LLVOAvatar*)av_obj; + if (avatarp != NULL) + real_pos = avatarp->getPositionGlobal(); + } } - } - F32 dist = F32(dist_vec(positions[i], gAgent.getPositionGlobal())); - if (dist > CHAT_NORMAL_RADIUS) - continue; + F32 dist = F32(dist_vec(positions[i], gAgent.getPositionGlobal())); + if (dist > CHAT_SHOUT_RADIUS) + continue; - std::string agent_name = " "; - std::string agent_surname = " "; + std::string agent_name = " "; + std::string agent_surname = " "; - if(!gCacheName->getName(avatar_ids[i], agent_name, agent_surname) && (agent_name == " " || agent_surname == " ")) - continue; + if(!gCacheName->getName(avatar_ids[i], agent_name, agent_surname) && (agent_name == " " || agent_surname == " ")) + continue; - std::string test_name(agent_name); - std::transform(test_name.begin(), test_name.end(), test_name.begin(), tolower); - std::transform(to_match.begin(), to_match.end(), to_match.begin(), tolower); + std::string test_name(agent_name); + std::transform(test_name.begin(), test_name.end(), test_name.begin(), tolower); + std::transform(to_match.begin(), to_match.end(), to_match.begin(), tolower); - if (test_name.find(to_match) == 0) - { - mInputEditor->setText(left_part.substr(0, left_part.length() - to_match.length()) + agent_name + right_part); - mInputEditor->setSelection(cursorPos, cursorPos + (agent_name.length() - to_match.length())); - return TRUE; + if (test_name.find(to_match) == 0) + names.push_back(agent_name); } } + + std::string current_name = names[current_index]; + mInputEditor->setText(left_part.substr(0, left_part.length() - to_match.length()) + current_name + right_part); + mInputEditor->setSelection(cursorPos, cursorPos + (current_name.length() - to_match.length())); + + current_index++; + + if (current_index == names.size()) + current_index = 0; + + return TRUE; } } } diff --git a/linden/indra/newview/llchatbar.h b/linden/indra/newview/llchatbar.h index 13332c7..202b006 100644 --- a/linden/indra/newview/llchatbar.h +++ b/linden/indra/newview/llchatbar.h @@ -117,6 +117,10 @@ protected: private: BOOL mChanCtrlEnabled; LLSpinCtrl* mChannelControl; + + std::vector names; + std::string last_initials; + int current_index; }; extern LLChatBar *gChatBar; -- cgit v1.1 From e54613da226abdf1e31a404761aac7085e65cb7c Mon Sep 17 00:00:00 2001 From: elektrahesse Date: Thu, 16 Sep 2010 17:23:48 +0200 Subject: Fixed a bug related to the names cache clearing :P --- linden/indra/newview/llchatbar.cpp | 79 +++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 40 deletions(-) (limited to 'linden/indra') diff --git a/linden/indra/newview/llchatbar.cpp b/linden/indra/newview/llchatbar.cpp index 52397b4..9d56638 100644 --- a/linden/indra/newview/llchatbar.cpp +++ b/linden/indra/newview/llchatbar.cpp @@ -252,62 +252,61 @@ BOOL LLChatBar::handleKeyHere( KEY key, MASK mask ) else return handled; - std::string to_match_test(to_match); - std::transform(to_match_test.begin(), to_match_test.end(), to_match_test.begin(), tolower); + names.clear(); - if (last_initials != to_match_test) + for (U32 i=0; iisAvatar()) { - LLViewerObject *av_obj = gObjectList.findObject(avatar_ids[i]); - if (av_obj != NULL && av_obj->isAvatar()) - { - LLVOAvatar* avatarp = (LLVOAvatar*)av_obj; - if (avatarp != NULL) - real_pos = avatarp->getPositionGlobal(); - } + LLVOAvatar* avatarp = (LLVOAvatar*)av_obj; + if (avatarp != NULL) + real_pos = avatarp->getPositionGlobal(); } + } - F32 dist = F32(dist_vec(positions[i], gAgent.getPositionGlobal())); - if (dist > CHAT_SHOUT_RADIUS) - continue; + F32 dist = F32(dist_vec(positions[i], gAgent.getPositionGlobal())); + if (dist > CHAT_SHOUT_RADIUS) + continue; - std::string agent_name = " "; - std::string agent_surname = " "; + std::string agent_name = " "; + std::string agent_surname = " "; - if(!gCacheName->getName(avatar_ids[i], agent_name, agent_surname) && (agent_name == " " || agent_surname == " ")) - continue; + if(!gCacheName->getName(avatar_ids[i], agent_name, agent_surname) && (agent_name == " " || agent_surname == " ")) + continue; - std::string test_name(agent_name); - std::transform(test_name.begin(), test_name.end(), test_name.begin(), tolower); - std::transform(to_match.begin(), to_match.end(), to_match.begin(), tolower); + std::string test_name(agent_name); + std::transform(test_name.begin(), test_name.end(), test_name.begin(), tolower); + std::transform(to_match.begin(), to_match.end(), to_match.begin(), tolower); + + if (test_name.find(to_match) == 0) + names.push_back(agent_name); + } - if (test_name.find(to_match) == 0) - names.push_back(agent_name); - } + if (current_index >= names.size() || to_match != last_initials) + { + current_index = 0; + last_initials = to_match; } - std::string current_name = names[current_index]; - mInputEditor->setText(left_part.substr(0, left_part.length() - to_match.length()) + current_name + right_part); - mInputEditor->setSelection(cursorPos, cursorPos + (current_name.length() - to_match.length())); + if (names.size() > 0) + { + std::string current_name = names[current_index]; - current_index++; + mInputEditor->setText(left_part.substr(0, left_part.length() - to_match.length()) + current_name + right_part); + mInputEditor->setSelection(cursorPos, cursorPos + (current_name.length() - to_match.length())); - if (current_index == names.size()) - current_index = 0; + current_index++; - return TRUE; + return TRUE; + } } } } -- cgit v1.1 From e3734349d2aa0dc4f6b9c7e00616cb95861bb73d Mon Sep 17 00:00:00 2001 From: elektrahesse Date: Thu, 16 Sep 2010 18:09:52 +0200 Subject: Moved all the variables to a struct to keep code more clean and added a check to run the regex match only if the text in chat changes, so it's a bit lighter --- linden/indra/newview/llchatbar.cpp | 80 ++++++++++++++++++++------------------ linden/indra/newview/llchatbar.h | 14 +++++-- 2 files changed, 53 insertions(+), 41 deletions(-) (limited to 'linden/indra') diff --git a/linden/indra/newview/llchatbar.cpp b/linden/indra/newview/llchatbar.cpp index 9d56638..ffd5afa 100644 --- a/linden/indra/newview/llchatbar.cpp +++ b/linden/indra/newview/llchatbar.cpp @@ -116,8 +116,9 @@ LLChatBar::LLChatBar() { setIsChrome(TRUE); - current_index = 0; - last_initials = ""; + mCompletionHolder.current_index = 0; + mCompletionHolder.last_match = ""; + mCompletionHolder.last_txt = ""; #if !LL_RELEASE_FOR_DOWNLOAD childDisplayNotFound(); @@ -222,37 +223,40 @@ BOOL LLChatBar::handleKeyHere( KEY key, MASK mask ) { mInputEditor->deleteSelection(); // Clean up prev completion before attempting a new one - std::string txt(mInputEditor->getText()); - std::string to_match(txt); - std::string left_part = ""; - std::string right_part = ""; S32 cursorPos = mInputEditor->getCursor(); + std::string txt(mInputEditor->getText()); - if (cursorPos < (S32)txt.length()) - { - right_part = txt.substr(cursorPos); - left_part = txt.substr(0, cursorPos); - to_match = std::string(left_part); - } - else + if (mCompletionHolder.last_txt != mInputEditor->getText()) { - to_match = std::string(txt); - left_part = txt; - } + mCompletionHolder.last_txt = std::string(mInputEditor->getText()); - std::string pattern_s = "(^|.*[_=&\\|\\<\\>#@\\[\\]\\-\\+\"',\\.\\?!:;\\*\\(\\)\\s]+)([a-z0-9]+)$"; - boost::match_results what; - boost::regex expression(pattern_s, boost::regex::icase); - if (boost::regex_search(to_match, what, expression, boost::match_extra)) - { - to_match = what[2]; - if (to_match.length() < 1) + if (cursorPos < (S32)txt.length()) + { + mCompletionHolder.right = txt.substr(cursorPos); + mCompletionHolder.left = txt.substr(0, cursorPos); + mCompletionHolder.match = std::string(mCompletionHolder.left); + } + else + { + mCompletionHolder.right = ""; + mCompletionHolder.match = std::string(txt); + mCompletionHolder.left = txt; + } + + std::string pattern_s = "(^|.*[_=&\\|\\<\\>#@\\[\\]\\-\\+\"',\\.\\?!:;\\*\\(\\)\\s]+)([a-z0-9]+)$"; + boost::match_results what; + boost::regex expression(pattern_s, boost::regex::icase); + if (boost::regex_search(mCompletionHolder.match, what, expression, boost::match_extra)) + { + mCompletionHolder.match = what[2]; + if (mCompletionHolder.match.length() < 1) + return handled; + } + else return handled; } - else - return handled; - names.clear(); + mCompletionHolder.names.clear(); for (U32 i=0; i= names.size() || to_match != last_initials) + if (mCompletionHolder.current_index >= mCompletionHolder.names.size() || mCompletionHolder.match != mCompletionHolder.last_match) { - current_index = 0; - last_initials = to_match; + mCompletionHolder.current_index = 0; + mCompletionHolder.last_match = mCompletionHolder.match; } - if (names.size() > 0) + if (mCompletionHolder.names.size() > 0) { - std::string current_name = names[current_index]; + std::string current_name = mCompletionHolder.names[mCompletionHolder.current_index]; - mInputEditor->setText(left_part.substr(0, left_part.length() - to_match.length()) + current_name + right_part); - mInputEditor->setSelection(cursorPos, cursorPos + (current_name.length() - to_match.length())); + mInputEditor->setText(mCompletionHolder.left.substr(0, mCompletionHolder.left.length() - mCompletionHolder.match.length()) + current_name + mCompletionHolder.right); + mInputEditor->setSelection(cursorPos, cursorPos + (current_name.length() - mCompletionHolder.match.length())); - current_index++; + mCompletionHolder.current_index++; return TRUE; } diff --git a/linden/indra/newview/llchatbar.h b/linden/indra/newview/llchatbar.h index 202b006..135881f 100644 --- a/linden/indra/newview/llchatbar.h +++ b/linden/indra/newview/llchatbar.h @@ -46,6 +46,16 @@ class LLChatBarGestureObserver; class LLComboBox; class LLSpinCtrl; +typedef struct { + std::string left; + std::string right; + std::string match; + std::vector names; + std::string last_txt; + std::string last_match; + int current_index; +} CompletionHolder; + class LLChatBar : public LLPanel { @@ -118,9 +128,7 @@ private: BOOL mChanCtrlEnabled; LLSpinCtrl* mChannelControl; - std::vector names; - std::string last_initials; - int current_index; + CompletionHolder mCompletionHolder; }; extern LLChatBar *gChatBar; -- cgit v1.1 From 6485376d3ddc34e3a974dc2405b82bf5dab88a47 Mon Sep 17 00:00:00 2001 From: elektrahesse Date: Thu, 16 Sep 2010 18:24:53 +0200 Subject: Switched struct declaration to a more C++esque way... Aleric hit me with a stick :P --- linden/indra/newview/llchatbar.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'linden/indra') diff --git a/linden/indra/newview/llchatbar.h b/linden/indra/newview/llchatbar.h index 135881f..5542d8a 100644 --- a/linden/indra/newview/llchatbar.h +++ b/linden/indra/newview/llchatbar.h @@ -46,7 +46,7 @@ class LLChatBarGestureObserver; class LLComboBox; class LLSpinCtrl; -typedef struct { +struct CompletionHolder { std::string left; std::string right; std::string match; @@ -54,7 +54,7 @@ typedef struct { std::string last_txt; std::string last_match; int current_index; -} CompletionHolder; +}; class LLChatBar : public LLPanel -- cgit v1.1 From 05ed2862aa0f2c288e5b298c634fb8fe0ffc8eb5 Mon Sep 17 00:00:00 2001 From: elektrahesse Date: Thu, 16 Sep 2010 20:34:09 +0200 Subject: Commented out the checks for distance, above 1024mts seems like i can't make them work fine :( --- linden/indra/newview/llchatbar.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'linden/indra') diff --git a/linden/indra/newview/llchatbar.cpp b/linden/indra/newview/llchatbar.cpp index ffd5afa..2981958 100644 --- a/linden/indra/newview/llchatbar.cpp +++ b/linden/indra/newview/llchatbar.cpp @@ -262,7 +262,7 @@ BOOL LLChatBar::handleKeyHere( KEY key, MASK mask ) { if (avatar_ids[i] == gAgent.getID() || avatar_ids[i].isNull()) continue; - +/* // Grab the pos again from the objects-in-view cache... LLWorld doesn't work above 1024 meters as usual :( LLVector3d real_pos = positions[i]; if (real_pos[2] == 0.0f) @@ -279,7 +279,7 @@ BOOL LLChatBar::handleKeyHere( KEY key, MASK mask ) F32 dist = F32(dist_vec(positions[i], gAgent.getPositionGlobal())); if (dist > CHAT_SHOUT_RADIUS) continue; - +*/ std::string agent_name = " "; std::string agent_surname = " "; -- cgit v1.1 From 9cae845499cd22a73c9521fcc6a2a9500770bee0 Mon Sep 17 00:00:00 2001 From: elektrahesse Date: Thu, 16 Sep 2010 20:44:00 +0200 Subject: Added nicknames support for chat highlighting (up to 3) in prefs->adv->extra --- linden/indra/newview/app_settings/settings.xml | 33 ++++++++++++++++++++++ linden/indra/newview/llfloaterchat.cpp | 28 ++++++++++++++---- linden/indra/newview/llprefsadvanced.cpp | 19 ++++++++++++- .../xui/en-us/panel_preferences_advanced.xml | 24 ++++++++++++++++ 4 files changed, 98 insertions(+), 6 deletions(-) (limited to 'linden/indra') diff --git a/linden/indra/newview/app_settings/settings.xml b/linden/indra/newview/app_settings/settings.xml index 2b61a19..7a22e7e 100644 --- a/linden/indra/newview/app_settings/settings.xml +++ b/linden/indra/newview/app_settings/settings.xml @@ -4,6 +4,39 @@ + nick01 + + Comment + First Nickname for Chat Highlight + Persist + 1 + Type + String + Value + + + nick02 + + Comment + Second Nickname for Chat Highlight + Persist + 1 + Type + String + Value + + + nick03 + + Comment + Third Nickname for Chat Highlight + Persist + 1 + Type + String + Value + + HighlightOwnNameInIM Comment diff --git a/linden/indra/newview/llfloaterchat.cpp b/linden/indra/newview/llfloaterchat.cpp index f352926..59f4d70 100644 --- a/linden/indra/newview/llfloaterchat.cpp +++ b/linden/indra/newview/llfloaterchat.cpp @@ -453,14 +453,32 @@ void LLFloaterChat::updateSettings() LLFloaterChat::getInstance(LLSD())->getChild("translate chat")->set(translate_chat); } -BOOL LLFloaterChat::isOwnNameInText(const std::string &text_line) +BOOL checkStringInText(const std::string &text_line, std::string textToMatch) { - std::string my_name = gSavedSettings.getString("FirstName"); - std::string pattern_s = "(^|.*[_=&\\|\\<\\>#@\\[\\]\\-\\+\"',\\.\\?!:;\\*\\(\\)\\s]+)(" + my_name + ")([_=&\\|\\<\\>#@\\[\\]\\-\\+\"',\\.\\?!:;\\*\\(\\)\\s]+.*|$)"; boost::smatch what; - boost::regex e1(pattern_s, boost::regex::icase); + std::string pattern_s = "(^|.*[_=&\\|\\<\\>#@\\[\\]\\-\\+\"',\\.\\?!:;\\*\\(\\)\\s]+)(" + textToMatch + ")([_=&\\|\\<\\>#@\\[\\]\\-\\+\"',\\.\\?!:;\\*\\(\\)\\s]+.*|$)"; + boost::regex expression(pattern_s, boost::regex::icase); + return boost::regex_search(text_line, what, expression); +} + +BOOL LLFloaterChat::isOwnNameInText(const std::string &text_line) +{ + if (checkStringInText(text_line, gSavedSettings.getString("FirstName"))) + return TRUE; + + for (int i=1; i<=3; i++) + { + std::stringstream key; + key << "nick0" << i; + std::string nick = gSavedSettings.getString(key.str()); + if (! nick.empty()) + { + if (checkStringInText(text_line, nick)) + return TRUE; + } + } - return boost::regex_search(text_line, what, e1); + return FALSE; } LLColor4 get_extended_text_color(const LLChat& chat, LLColor4 defaultColor) diff --git a/linden/indra/newview/llprefsadvanced.cpp b/linden/indra/newview/llprefsadvanced.cpp index 898ba2c..ed0b432 100644 --- a/linden/indra/newview/llprefsadvanced.cpp +++ b/linden/indra/newview/llprefsadvanced.cpp @@ -45,6 +45,8 @@ #include "lluictrlfactory.h" +#include "boost/algorithm/string.hpp" + LLPrefsAdvanced* LLPrefsAdvanced::sInstance; LLPrefsAdvanced::LLPrefsAdvanced() @@ -117,11 +119,14 @@ BOOL LLPrefsAdvanced::postBuild() getChild("FriendsChatColor")->set(gSavedSettings.getColor4("FriendsChatColor")); childSetValue("HighlightOwnNameInChat", gSavedSettings.getBOOL("HighlightOwnNameInChat")); getChild("OwnNameChatColor")->set(gSavedSettings.getColor4("OwnNameChatColor")); + childSetValue("nick01", gSavedSettings.getString("nick01")); + childSetValue("nick02", gSavedSettings.getString("nick02")); + childSetValue("nick03", gSavedSettings.getString("nick03")); refresh(); return TRUE; -} +} void LLPrefsAdvanced::apply() { @@ -146,6 +151,18 @@ void LLPrefsAdvanced::apply() gSavedSettings.setBOOL("HighlightOwnNameInChat", childGetValue("HighlightOwnNameInChat")); gSavedSettings.setColor4("OwnNameChatColor", getChild("OwnNameChatColor")->get()); + std::string nick01 = childGetValue("nick01"); + boost::trim(nick01); + gSavedSettings.setString("nick01", nick01); + + std::string nick02 = childGetValue("nick02"); + boost::trim(nick02); + gSavedSettings.setString("nick02", nick02); + + std::string nick03 = childGetValue("nick03"); + boost::trim(nick03); + gSavedSettings.setString("nick03", nick03); + // Need to force a rebake when ClothingLayerProtection toggled for it take effect -- MC if (gSavedSettings.getBOOL("ShowMyClientTagToOthers") != (BOOL)childGetValue("client_name_tag_broadcast_check")) { diff --git a/linden/indra/newview/skins/default/xui/en-us/panel_preferences_advanced.xml b/linden/indra/newview/skins/default/xui/en-us/panel_preferences_advanced.xml index 073ed42..cac3ef1 100644 --- a/linden/indra/newview/skins/default/xui/en-us/panel_preferences_advanced.xml +++ b/linden/indra/newview/skins/default/xui/en-us/panel_preferences_advanced.xml @@ -199,6 +199,30 @@ enabled="true" follows="left|top" height="67" label="Own Name" left_delta="68" mouse_opaque="true" name="OwnNameChatColor" width="65" /> + + + Nick 1 + + + + Nick 2 + + + + Nick 3 + -- cgit v1.1