aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra
diff options
context:
space:
mode:
authorelektrahesse2010-09-16 16:32:20 +0200
committerelektrahesse2010-09-16 16:32:20 +0200
commit93b9816a3e9b2318024661d57ba44abca6ce23c2 (patch)
tree1854068b7d8ab76dd1f387c66f3318275d15b2c7 /linden/indra
parentAdded CHAT_NORMAL_RADIUS check for autocompletion and deleted selection of la... (diff)
downloadmeta-impy-93b9816a3e9b2318024661d57ba44abca6ce23c2.zip
meta-impy-93b9816a3e9b2318024661d57ba44abca6ce23c2.tar.gz
meta-impy-93b9816a3e9b2318024661d57ba44abca6ce23c2.tar.bz2
meta-impy-93b9816a3e9b2318024661d57ba44abca6ce23c2.tar.xz
Added names cycling using TAB. Only 1 char now necessary to trigger completion. Otherwise TAB reverts to cycle through widgets.
Diffstat (limited to 'linden/indra')
-rw-r--r--linden/indra/newview/llchatbar.cpp79
-rw-r--r--linden/indra/newview/llchatbar.h4
2 files changed, 53 insertions, 30 deletions
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()
115 mObserver(NULL) 115 mObserver(NULL)
116{ 116{
117 setIsChrome(TRUE); 117 setIsChrome(TRUE);
118 118
119 current_index = 0;
120 last_initials = "";
121
119 #if !LL_RELEASE_FOR_DOWNLOAD 122 #if !LL_RELEASE_FOR_DOWNLOAD
120 childDisplayNotFound(); 123 childDisplayNotFound();
121#endif 124#endif
@@ -220,7 +223,6 @@ BOOL LLChatBar::handleKeyHere( KEY key, MASK mask )
220 mInputEditor->deleteSelection(); // Clean up prev completion before attempting a new one 223 mInputEditor->deleteSelection(); // Clean up prev completion before attempting a new one
221 224
222 std::string txt(mInputEditor->getText()); 225 std::string txt(mInputEditor->getText());
223
224 std::string to_match(txt); 226 std::string to_match(txt);
225 std::string left_part = ""; 227 std::string left_part = "";
226 std::string right_part = ""; 228 std::string right_part = "";
@@ -244,51 +246,68 @@ BOOL LLChatBar::handleKeyHere( KEY key, MASK mask )
244 if (boost::regex_search(to_match, what, expression, boost::match_extra)) 246 if (boost::regex_search(to_match, what, expression, boost::match_extra))
245 { 247 {
246 to_match = what[2]; 248 to_match = what[2];
247 if (to_match.length() < 3) 249 if (to_match.length() < 1)
248 return handled; 250 return handled;
249 } 251 }
250 else 252 else
251 return handled; 253 return handled;
252 254
253 for (U32 i=0; i<avatar_ids.size(); i++) 255 std::string to_match_test(to_match);
256 std::transform(to_match_test.begin(), to_match_test.end(), to_match_test.begin(), tolower);
257
258 if (last_initials != to_match_test)
254 { 259 {
255 if (avatar_ids[i] == gAgent.getID() || avatar_ids[i].isNull()) 260 last_initials = to_match_test;
256 continue; 261 names.clear();
262 current_index = 0;
257 263
258 // Grab the pos again from the objects-in-view cache... LLWorld doesn't work above 1024 meters as usual :( 264 for (U32 i=0; i<avatar_ids.size(); i++)
259 LLVector3d real_pos = positions[i];
260 if (real_pos[2] == 0.0f)
261 { 265 {
262 LLViewerObject *av_obj = gObjectList.findObject(avatar_ids[i]); 266 if (avatar_ids[i] == gAgent.getID() || avatar_ids[i].isNull())
263 if (av_obj != NULL && av_obj->isAvatar()) 267 continue;
268
269 // Grab the pos again from the objects-in-view cache... LLWorld doesn't work above 1024 meters as usual :(
270 LLVector3d real_pos = positions[i];
271 if (real_pos[2] == 0.0f)
264 { 272 {
265 LLVOAvatar* avatarp = (LLVOAvatar*)av_obj; 273 LLViewerObject *av_obj = gObjectList.findObject(avatar_ids[i]);
266 if (avatarp != NULL) 274 if (av_obj != NULL && av_obj->isAvatar())
267 real_pos = avatarp->getPositionGlobal(); 275 {
276 LLVOAvatar* avatarp = (LLVOAvatar*)av_obj;
277 if (avatarp != NULL)
278 real_pos = avatarp->getPositionGlobal();
279 }
268 } 280 }
269 }
270 281
271 F32 dist = F32(dist_vec(positions[i], gAgent.getPositionGlobal())); 282 F32 dist = F32(dist_vec(positions[i], gAgent.getPositionGlobal()));
272 if (dist > CHAT_NORMAL_RADIUS) 283 if (dist > CHAT_SHOUT_RADIUS)
273 continue; 284 continue;
274 285
275 std::string agent_name = " "; 286 std::string agent_name = " ";
276 std::string agent_surname = " "; 287 std::string agent_surname = " ";
277 288
278 if(!gCacheName->getName(avatar_ids[i], agent_name, agent_surname) && (agent_name == " " || agent_surname == " ")) 289 if(!gCacheName->getName(avatar_ids[i], agent_name, agent_surname) && (agent_name == " " || agent_surname == " "))
279 continue; 290 continue;
280 291
281 std::string test_name(agent_name); 292 std::string test_name(agent_name);
282 std::transform(test_name.begin(), test_name.end(), test_name.begin(), tolower); 293 std::transform(test_name.begin(), test_name.end(), test_name.begin(), tolower);
283 std::transform(to_match.begin(), to_match.end(), to_match.begin(), tolower); 294 std::transform(to_match.begin(), to_match.end(), to_match.begin(), tolower);
284 295
285 if (test_name.find(to_match) == 0) 296 if (test_name.find(to_match) == 0)
286 { 297 names.push_back(agent_name);
287 mInputEditor->setText(left_part.substr(0, left_part.length() - to_match.length()) + agent_name + right_part);
288 mInputEditor->setSelection(cursorPos, cursorPos + (agent_name.length() - to_match.length()));
289 return TRUE;
290 } 298 }
291 } 299 }
300
301 std::string current_name = names[current_index];
302 mInputEditor->setText(left_part.substr(0, left_part.length() - to_match.length()) + current_name + right_part);
303 mInputEditor->setSelection(cursorPos, cursorPos + (current_name.length() - to_match.length()));
304
305 current_index++;
306
307 if (current_index == names.size())
308 current_index = 0;
309
310 return TRUE;
292 } 311 }
293 } 312 }
294 } 313 }
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:
117private: 117private:
118 BOOL mChanCtrlEnabled; 118 BOOL mChanCtrlEnabled;
119 LLSpinCtrl* mChannelControl; 119 LLSpinCtrl* mChannelControl;
120
121 std::vector<std::string> names;
122 std::string last_initials;
123 int current_index;
120}; 124};
121 125
122extern LLChatBar *gChatBar; 126extern LLChatBar *gChatBar;