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