aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden
diff options
context:
space:
mode:
authorMcCabe Maxsted2010-09-17 03:20:34 -0700
committerMcCabe Maxsted2010-09-17 03:20:34 -0700
commitb86ea25ef4f809e473e39d887b60ee681f5e68b6 (patch)
tree0cb5237b1ceaf1ed7f9356719b073a1c8bf202fa /linden
parent"fix" null sound channel crash (diff)
parentAdded nicknames support for chat highlighting (up to 3) in prefs->adv->extra (diff)
downloadmeta-impy-b86ea25ef4f809e473e39d887b60ee681f5e68b6.zip
meta-impy-b86ea25ef4f809e473e39d887b60ee681f5e68b6.tar.gz
meta-impy-b86ea25ef4f809e473e39d887b60ee681f5e68b6.tar.bz2
meta-impy-b86ea25ef4f809e473e39d887b60ee681f5e68b6.tar.xz
Merge remote branch 'elektra/weekly' into weekly
Diffstat (limited to 'linden')
-rw-r--r--linden/indra/newview/app_settings/settings.xml33
-rw-r--r--linden/indra/newview/llchatbar.cpp106
-rw-r--r--linden/indra/newview/llchatbar.h12
-rw-r--r--linden/indra/newview/llfloaterchat.cpp28
-rw-r--r--linden/indra/newview/llprefsadvanced.cpp19
-rw-r--r--linden/indra/newview/skins/default/xui/en-us/panel_preferences_advanced.xml24
6 files changed, 181 insertions, 41 deletions
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 @@
4 4
5 <!-- Imprudence-specific settings --> 5 <!-- Imprudence-specific settings -->
6 6
7 <key>nick01</key>
8 <map>
9 <key>Comment</key>
10 <string>First Nickname for Chat Highlight</string>
11 <key>Persist</key>
12 <integer>1</integer>
13 <key>Type</key>
14 <string>String</string>
15 <key>Value</key>
16 <string></string>
17 </map>
18 <key>nick02</key>
19 <map>
20 <key>Comment</key>
21 <string>Second Nickname for Chat Highlight</string>
22 <key>Persist</key>
23 <integer>1</integer>
24 <key>Type</key>
25 <string>String</string>
26 <key>Value</key>
27 <string></string>
28 </map>
29 <key>nick03</key>
30 <map>
31 <key>Comment</key>
32 <string>Third Nickname for Chat Highlight</string>
33 <key>Persist</key>
34 <integer>1</integer>
35 <key>Type</key>
36 <string>String</string>
37 <key>Value</key>
38 <string></string>
39 </map>
7 <key>HighlightOwnNameInIM</key> 40 <key>HighlightOwnNameInIM</key>
8 <map> 41 <map>
9 <key>Comment</key> 42 <key>Comment</key>
diff --git a/linden/indra/newview/llchatbar.cpp b/linden/indra/newview/llchatbar.cpp
index 92340ec..2981958 100644
--- a/linden/indra/newview/llchatbar.cpp
+++ b/linden/indra/newview/llchatbar.cpp
@@ -68,6 +68,7 @@
68#include "llmultigesture.h" 68#include "llmultigesture.h"
69#include "llui.h" 69#include "llui.h"
70#include "lluictrlfactory.h" 70#include "lluictrlfactory.h"
71#include "llvoavatar.h"
71 72
72#include "chatbar_as_cmdline.h" 73#include "chatbar_as_cmdline.h"
73 74
@@ -114,7 +115,11 @@ LLChatBar::LLChatBar()
114 mObserver(NULL) 115 mObserver(NULL)
115{ 116{
116 setIsChrome(TRUE); 117 setIsChrome(TRUE);
117 118
119 mCompletionHolder.current_index = 0;
120 mCompletionHolder.last_match = "";
121 mCompletionHolder.last_txt = "";
122
118 #if !LL_RELEASE_FOR_DOWNLOAD 123 #if !LL_RELEASE_FOR_DOWNLOAD
119 childDisplayNotFound(); 124 childDisplayNotFound();
120#endif 125#endif
@@ -206,7 +211,7 @@ BOOL LLChatBar::handleKeyHere( KEY key, MASK mask )
206 stopChat(); 211 stopChat();
207 handled = TRUE; 212 handled = TRUE;
208 } 213 }
209 else if (key == KEY_ESCAPE && mask == MASK_CONTROL && gChatBar == this) 214 else if (key == KEY_TAB)
210 { 215 {
211 if (mInputEditor) 216 if (mInputEditor)
212 { 217 {
@@ -216,48 +221,65 @@ BOOL LLChatBar::handleKeyHere( KEY key, MASK mask )
216 221
217 if (!avatar_ids.empty()) 222 if (!avatar_ids.empty())
218 { 223 {
219 std::string txt(mInputEditor->getText()); 224 mInputEditor->deleteSelection(); // Clean up prev completion before attempting a new one
220 225
221 std::string to_match(txt);
222 std::string left_part = "";
223 std::string right_part = "";
224 S32 cursorPos = mInputEditor->getCursor(); 226 S32 cursorPos = mInputEditor->getCursor();
227 std::string txt(mInputEditor->getText());
225 228
226 if (cursorPos < (S32)txt.length()) 229 if (mCompletionHolder.last_txt != mInputEditor->getText())
227 { 230 {
228 right_part = txt.substr(cursorPos); 231 mCompletionHolder.last_txt = std::string(mInputEditor->getText());
229 left_part = txt.substr(0, cursorPos);
230 to_match = std::string(left_part);
231 }
232 else
233 {
234 to_match = std::string(txt);
235 left_part = txt;
236 }
237 232
238 std::string pattern_s = "(^|.*[\\.\\?!:;,\\*\\(\\s]+)([a-z0-9]+)$"; 233 if (cursorPos < (S32)txt.length())
239 boost::match_results<std::string::const_iterator> what; 234 {
240 boost::regex expression(pattern_s, boost::regex::icase); 235 mCompletionHolder.right = txt.substr(cursorPos);
241 if (boost::regex_search(to_match, what, expression, boost::match_extra)) 236 mCompletionHolder.left = txt.substr(0, cursorPos);
242 { 237 mCompletionHolder.match = std::string(mCompletionHolder.left);
243 to_match = what[2]; 238 }
244 if (to_match.length() < 3) 239 else
240 {
241 mCompletionHolder.right = "";
242 mCompletionHolder.match = std::string(txt);
243 mCompletionHolder.left = txt;
244 }
245
246 std::string pattern_s = "(^|.*[_=&\\|\\<\\>#@\\[\\]\\-\\+\"',\\.\\?!:;\\*\\(\\)\\s]+)([a-z0-9]+)$";
247 boost::match_results<std::string::const_iterator> what;
248 boost::regex expression(pattern_s, boost::regex::icase);
249 if (boost::regex_search(mCompletionHolder.match, what, expression, boost::match_extra))
250 {
251 mCompletionHolder.match = what[2];
252 if (mCompletionHolder.match.length() < 1)
253 return handled;
254 }
255 else
245 return handled; 256 return handled;
246 } 257 }
247 else 258
248 return handled; 259 mCompletionHolder.names.clear();
249 260
250 for (U32 i=0; i<avatar_ids.size(); i++) 261 for (U32 i=0; i<avatar_ids.size(); i++)
251 { 262 {
252 if (avatar_ids[i] == gAgent.getID() || avatar_ids[i].isNull()) 263 if (avatar_ids[i] == gAgent.getID() || avatar_ids[i].isNull())
253 continue; 264 continue;
254/* 265/*
255 // Commented out for now... doesn't work above 1024 meters as usual 266 // Grab the pos again from the objects-in-view cache... LLWorld doesn't work above 1024 meters as usual :(
267 LLVector3d real_pos = positions[i];
268 if (real_pos[2] == 0.0f)
269 {
270 LLViewerObject *av_obj = gObjectList.findObject(avatar_ids[i]);
271 if (av_obj != NULL && av_obj->isAvatar())
272 {
273 LLVOAvatar* avatarp = (LLVOAvatar*)av_obj;
274 if (avatarp != NULL)
275 real_pos = avatarp->getPositionGlobal();
276 }
277 }
278
256 F32 dist = F32(dist_vec(positions[i], gAgent.getPositionGlobal())); 279 F32 dist = F32(dist_vec(positions[i], gAgent.getPositionGlobal()));
257 if (dist > CHAT_NORMAL_RADIUS) 280 if (dist > CHAT_SHOUT_RADIUS)
258 continue; 281 continue;
259*/ 282*/
260
261 std::string agent_name = " "; 283 std::string agent_name = " ";
262 std::string agent_surname = " "; 284 std::string agent_surname = " ";
263 285
@@ -266,14 +288,28 @@ BOOL LLChatBar::handleKeyHere( KEY key, MASK mask )
266 288
267 std::string test_name(agent_name); 289 std::string test_name(agent_name);
268 std::transform(test_name.begin(), test_name.end(), test_name.begin(), tolower); 290 std::transform(test_name.begin(), test_name.end(), test_name.begin(), tolower);
269 std::transform(to_match.begin(), to_match.end(), to_match.begin(), tolower); 291 std::transform(mCompletionHolder.match.begin(), mCompletionHolder.match.end(), mCompletionHolder.match.begin(), tolower);
270 292
271 if (test_name.find(to_match) == 0) 293 if (test_name.find(mCompletionHolder.match) == 0)
272 { 294 mCompletionHolder.names.push_back(agent_name);
273 mInputEditor->setText(left_part.substr(0, left_part.length() - to_match.length()) + agent_name + right_part); 295 }
274 mInputEditor->setSelection(cursorPos, cursorPos + (agent_name.length() - to_match.length())); 296
275 return TRUE; 297 if (mCompletionHolder.current_index >= mCompletionHolder.names.size() || mCompletionHolder.match != mCompletionHolder.last_match)
276 } 298 {
299 mCompletionHolder.current_index = 0;
300 mCompletionHolder.last_match = mCompletionHolder.match;
301 }
302
303 if (mCompletionHolder.names.size() > 0)
304 {
305 std::string current_name = mCompletionHolder.names[mCompletionHolder.current_index];
306
307 mInputEditor->setText(mCompletionHolder.left.substr(0, mCompletionHolder.left.length() - mCompletionHolder.match.length()) + current_name + mCompletionHolder.right);
308 mInputEditor->setSelection(cursorPos, cursorPos + (current_name.length() - mCompletionHolder.match.length()));
309
310 mCompletionHolder.current_index++;
311
312 return TRUE;
277 } 313 }
278 } 314 }
279 } 315 }
diff --git a/linden/indra/newview/llchatbar.h b/linden/indra/newview/llchatbar.h
index 13332c7..5542d8a 100644
--- a/linden/indra/newview/llchatbar.h
+++ b/linden/indra/newview/llchatbar.h
@@ -46,6 +46,16 @@ class LLChatBarGestureObserver;
46class LLComboBox; 46class LLComboBox;
47class LLSpinCtrl; 47class LLSpinCtrl;
48 48
49struct CompletionHolder {
50 std::string left;
51 std::string right;
52 std::string match;
53 std::vector<std::string> names;
54 std::string last_txt;
55 std::string last_match;
56 int current_index;
57};
58
49class LLChatBar 59class LLChatBar
50: public LLPanel 60: public LLPanel
51{ 61{
@@ -117,6 +127,8 @@ protected:
117private: 127private:
118 BOOL mChanCtrlEnabled; 128 BOOL mChanCtrlEnabled;
119 LLSpinCtrl* mChannelControl; 129 LLSpinCtrl* mChannelControl;
130
131 CompletionHolder mCompletionHolder;
120}; 132};
121 133
122extern LLChatBar *gChatBar; 134extern LLChatBar *gChatBar;
diff --git a/linden/indra/newview/llfloaterchat.cpp b/linden/indra/newview/llfloaterchat.cpp
index b1c1356..59f4d70 100644
--- a/linden/indra/newview/llfloaterchat.cpp
+++ b/linden/indra/newview/llfloaterchat.cpp
@@ -453,14 +453,32 @@ void LLFloaterChat::updateSettings()
453 LLFloaterChat::getInstance(LLSD())->getChild<LLCheckBoxCtrl>("translate chat")->set(translate_chat); 453 LLFloaterChat::getInstance(LLSD())->getChild<LLCheckBoxCtrl>("translate chat")->set(translate_chat);
454} 454}
455 455
456BOOL LLFloaterChat::isOwnNameInText(const std::string &text_line) 456BOOL checkStringInText(const std::string &text_line, std::string textToMatch)
457{ 457{
458 std::string my_name = gSavedSettings.getString("FirstName");
459 std::string pattern_s = "(^|.*[',\\.\\?!:;\\*\\(\\s]+)(" + my_name + ")([',\\.\\?!:;\\*\\)\\s]+.*|$)";
460 boost::smatch what; 458 boost::smatch what;
461 boost::regex e1(pattern_s, boost::regex::icase); 459 std::string pattern_s = "(^|.*[_=&\\|\\<\\>#@\\[\\]\\-\\+\"',\\.\\?!:;\\*\\(\\)\\s]+)(" + textToMatch + ")([_=&\\|\\<\\>#@\\[\\]\\-\\+\"',\\.\\?!:;\\*\\(\\)\\s]+.*|$)";
460 boost::regex expression(pattern_s, boost::regex::icase);
461 return boost::regex_search(text_line, what, expression);
462}
463
464BOOL LLFloaterChat::isOwnNameInText(const std::string &text_line)
465{
466 if (checkStringInText(text_line, gSavedSettings.getString("FirstName")))
467 return TRUE;
468
469 for (int i=1; i<=3; i++)
470 {
471 std::stringstream key;
472 key << "nick0" << i;
473 std::string nick = gSavedSettings.getString(key.str());
474 if (! nick.empty())
475 {
476 if (checkStringInText(text_line, nick))
477 return TRUE;
478 }
479 }
462 480
463 return boost::regex_search(text_line, what, e1); 481 return FALSE;
464} 482}
465 483
466LLColor4 get_extended_text_color(const LLChat& chat, LLColor4 defaultColor) 484LLColor4 get_extended_text_color(const LLChat& chat, LLColor4 defaultColor)
diff --git a/linden/indra/newview/llprefsadvanced.cpp b/linden/indra/newview/llprefsadvanced.cpp
index 73a5827..cb0416e 100644
--- a/linden/indra/newview/llprefsadvanced.cpp
+++ b/linden/indra/newview/llprefsadvanced.cpp
@@ -45,6 +45,8 @@
45 45
46#include "lluictrlfactory.h" 46#include "lluictrlfactory.h"
47 47
48#include "boost/algorithm/string.hpp"
49
48LLPrefsAdvanced* LLPrefsAdvanced::sInstance; 50LLPrefsAdvanced* LLPrefsAdvanced::sInstance;
49 51
50LLPrefsAdvanced::LLPrefsAdvanced() 52LLPrefsAdvanced::LLPrefsAdvanced()
@@ -117,11 +119,14 @@ BOOL LLPrefsAdvanced::postBuild()
117 getChild<LLColorSwatchCtrl>("FriendsChatColor")->set(gSavedSettings.getColor4("FriendsChatColor")); 119 getChild<LLColorSwatchCtrl>("FriendsChatColor")->set(gSavedSettings.getColor4("FriendsChatColor"));
118 childSetValue("HighlightOwnNameInChat", gSavedSettings.getBOOL("HighlightOwnNameInChat")); 120 childSetValue("HighlightOwnNameInChat", gSavedSettings.getBOOL("HighlightOwnNameInChat"));
119 getChild<LLColorSwatchCtrl>("OwnNameChatColor")->set(gSavedSettings.getColor4("OwnNameChatColor")); 121 getChild<LLColorSwatchCtrl>("OwnNameChatColor")->set(gSavedSettings.getColor4("OwnNameChatColor"));
122 childSetValue("nick01", gSavedSettings.getString("nick01"));
123 childSetValue("nick02", gSavedSettings.getString("nick02"));
124 childSetValue("nick03", gSavedSettings.getString("nick03"));
120 125
121 refresh(); 126 refresh();
122 127
123 return TRUE; 128 return TRUE;
124} 129}
125 130
126void LLPrefsAdvanced::apply() 131void LLPrefsAdvanced::apply()
127{ 132{
@@ -146,6 +151,18 @@ void LLPrefsAdvanced::apply()
146 gSavedSettings.setBOOL("HighlightOwnNameInChat", childGetValue("HighlightOwnNameInChat")); 151 gSavedSettings.setBOOL("HighlightOwnNameInChat", childGetValue("HighlightOwnNameInChat"));
147 gSavedSettings.setColor4("OwnNameChatColor", getChild<LLColorSwatchCtrl>("OwnNameChatColor")->get()); 152 gSavedSettings.setColor4("OwnNameChatColor", getChild<LLColorSwatchCtrl>("OwnNameChatColor")->get());
148 153
154 std::string nick01 = childGetValue("nick01");
155 boost::trim(nick01);
156 gSavedSettings.setString("nick01", nick01);
157
158 std::string nick02 = childGetValue("nick02");
159 boost::trim(nick02);
160 gSavedSettings.setString("nick02", nick02);
161
162 std::string nick03 = childGetValue("nick03");
163 boost::trim(nick03);
164 gSavedSettings.setString("nick03", nick03);
165
149 // Need to force a rebake when ClothingLayerProtection toggled for it take effect -- MC 166 // Need to force a rebake when ClothingLayerProtection toggled for it take effect -- MC
150 if (gSavedSettings.getBOOL("ShowMyClientTagToOthers") != (BOOL)childGetValue("client_name_tag_broadcast_check")) 167 if (gSavedSettings.getBOOL("ShowMyClientTagToOthers") != (BOOL)childGetValue("client_name_tag_broadcast_check"))
151 { 168 {
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 d877c2d..a0c9e28 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
@@ -206,6 +206,30 @@ To use spellcheck, right-click a misspelled word
206 enabled="true" follows="left|top" height="67" label="Own Name" left_delta="68" 206 enabled="true" follows="left|top" height="67" label="Own Name" left_delta="68"
207 mouse_opaque="true" name="OwnNameChatColor" width="65" /> 207 mouse_opaque="true" name="OwnNameChatColor" width="65" />
208 208
209 <line_editor bevel_style="in" border_style="line" border_thickness="1" bottom_delta="-50"
210 enabled="true" follows="left|top" font="SansSerif"
211 handle_edit_keys_directly="true" height="20" left_delta="0"
212 max_length="50" mouse_opaque="true" name="nick01"
213 select_all_on_focus_received="true" width="400" word_wrap="false" />
214
215 <text bottom_delta="-3" follows="left|top" font="SansSerifSmall" height="20" left="20" name="nick01_text" width="70">Nick 1</text>
216
217 <line_editor bevel_style="in" border_style="line" border_thickness="1" bottom_delta="-30"
218 enabled="true" follows="left|top" font="SansSerif"
219 handle_edit_keys_directly="true" height="20" left_delta="60"
220 max_length="50" mouse_opaque="true" name="nick02"
221 select_all_on_focus_received="true" width="400" word_wrap="false" />
222
223 <text bottom_delta="-3" follows="left|top" font="SansSerifSmall" height="20" left="20" name="nick02_text" width="70">Nick 2</text>
224
225 <line_editor bevel_style="in" border_style="line" border_thickness="1" bottom_delta="-30"
226 enabled="true" follows="left|top" font="SansSerif"
227 handle_edit_keys_directly="true" height="20" left_delta="60"
228 max_length="50" mouse_opaque="true" name="nick03"
229 select_all_on_focus_received="true" width="400" word_wrap="false" />
230
231 <text bottom_delta="-3" follows="left|top" font="SansSerifSmall" height="20" left="20" name="nick03_text" width="70">Nick 3</text>
232
209 </panel> 233 </panel>
210 </tab_container> 234 </tab_container>
211</panel> 235</panel>