aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/llfloatermap.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/llfloatermap.cpp')
-rw-r--r--linden/indra/newview/llfloatermap.cpp276
1 files changed, 230 insertions, 46 deletions
diff --git a/linden/indra/newview/llfloatermap.cpp b/linden/indra/newview/llfloatermap.cpp
index c60f07f..0ee0f2b 100644
--- a/linden/indra/newview/llfloatermap.cpp
+++ b/linden/indra/newview/llfloatermap.cpp
@@ -43,8 +43,10 @@
43#include "lluictrlfactory.h" 43#include "lluictrlfactory.h"
44 44
45// radar 45// radar
46#include "llchat.h"
46#include "llfirstuse.h" 47#include "llfirstuse.h"
47#include "llfloateravatarinfo.h" 48#include "llfloateravatarinfo.h"
49#include "llfloaterchat.h"
48#include "llfloaterfriends.h" 50#include "llfloaterfriends.h"
49#include "llfloatergroupinvite.h" 51#include "llfloatergroupinvite.h"
50#include "llfloatergroups.h" 52#include "llfloatergroups.h"
@@ -69,13 +71,16 @@ LLFloaterMap::LLFloaterMap(const LLSD& key)
69 : 71 :
70 LLFloater(std::string("minimap")), 72 LLFloater(std::string("minimap")),
71 mPanelMap(NULL), 73 mPanelMap(NULL),
72 mUpdate(TRUE) 74 mUpdate(TRUE),
75 mSelectedAvatar(LLUUID::null)
76
73{ 77{
74 LLCallbackMap::map_t factory_map; 78 LLCallbackMap::map_t factory_map;
75 factory_map["mini_mapview"] = LLCallbackMap(createPanelMiniMap, this); 79 factory_map["mini_mapview"] = LLCallbackMap(createPanelMiniMap, this);
76 LLUICtrlFactory::getInstance()->buildFloater(this, "floater_mini_map.xml", &factory_map, FALSE); 80 LLUICtrlFactory::getInstance()->buildFloater(this, "floater_mini_map.xml", &factory_map, FALSE);
77 81
78 mSelectedAvatar.setNull(); 82 mChatAvatars.clear();
83 mTypingAvatars.clear();
79} 84}
80 85
81 86
@@ -232,78 +237,257 @@ void LLFloaterMap::populateRadar()
232 237
233 S32 scroll_pos = mRadarList->getScrollPos(); 238 S32 scroll_pos = mRadarList->getScrollPos();
234 239
235 LLVector3d current_pos = gAgent.getPositionGlobal(); 240 // clear count
241 std::stringstream avatar_count;
242 avatar_count.str("");
236 243
237 // find what avatars you can see 244 // find what avatars you can see
245 F32 range = gSavedSettings.getF32("NearMeRange");
246 LLVector3d current_pos = gAgent.getPositionGlobal();
238 std::vector<LLUUID> avatar_ids; 247 std::vector<LLUUID> avatar_ids;
239 std::vector<LLVector3d> positions; 248 std::vector<LLVector3d> positions;
240 LLWorld::getInstance()->getAvatars(&avatar_ids, &positions, current_pos, gSavedSettings.getF32("NearMeRange")); 249 LLWorld::getInstance()->getAvatars(&avatar_ids, &positions);
241 250
242 LLSD element; 251 LLSD element;
243 252
244 mRadarList->deleteAllItems(); 253 mRadarList->deleteAllItems();
245 254
246 for (U32 i=0; i<avatar_ids.size(); i++) 255 if (!avatar_ids.empty())
247 { 256 {
248 if (avatar_ids[i] == gAgent.getID() || 257 for (U32 i=0; i<avatar_ids.size(); i++)
249 avatar_ids[i].isNull())
250 { 258 {
251 continue; 259 if (avatar_ids[i] == gAgent.getID() ||
252 } 260 avatar_ids[i].isNull())
261 {
262 continue;
263 }
253 264
254 // Add to list only if we get their name 265 // Add to list only if we get their name
255 std::string fullname = getSelectedName(avatar_ids[i]); 266 std::string fullname = getSelectedName(avatar_ids[i]);
256 if (!fullname.empty()) 267 if (!fullname.empty())
257 {
258// [RLVa:KB] - Alternate: Imprudence-1.2.0
259 if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES))
260 { 268 {
261 fullname = gRlvHandler.getAnonym(fullname); 269 bool notify_chat = gSavedSettings.getBOOL("MiniMapNotifyChatRange");
270 bool notify_sim = gSavedSettings.getBOOL("MiniMapNotifySimRange");
271 // [RLVa:KB] - Alternate: Imprudence-1.2.0
272 if (gRlvHandler.hasBehaviour(RLV_BHVR_SHOWNAMES))
273 {
274 fullname = gRlvHandler.getAnonym(fullname);
275 notify_chat = false;
276 notify_sim = false;
277 }
278 // [/RLVa:KB]
279
280 // check if they're in certain ranges and notify user if we've enabled that
281 LLVector3d temp = positions[i] - current_pos;
282 F32 distance = llround((F32)temp.magVec(), 0.1f);
283 /*char dist[32];
284 sprintf(dist, "%.1f", distance);
285 std::string dist_string = dist;*/
286 std::string dist_string = llformat("%.1f", distance);
287
288 if (notify_chat)
289 {
290 if (distance < 20.0f)
291 {
292 if (!getInChatList(avatar_ids[i]))
293 {
294 addToChatList(avatar_ids[i], dist_string);
295 }
296 }
297 else
298 {
299 if (getInChatList(avatar_ids[i]))
300 {
301 removeFromChatList(avatar_ids[i]);
302 }
303 }
304 updateChatList(avatar_ids);
305 }
306 else if (!mChatAvatars.empty())
307 {
308 mChatAvatars.clear();
309 }
310
311 if (notify_sim)
312 {
313 if (!getInChatList(avatar_ids[i]) && !getInSimAvList(avatar_ids[i]))
314 {
315 LLViewerObject *av_obj = gObjectList.findObject(avatar_ids[i]);
316 if (av_obj != NULL && av_obj->isAvatar())
317 {
318 LLVOAvatar* avatarp = (LLVOAvatar*)av_obj;
319 if (avatarp != NULL)
320 {
321 if (avatarp->getRegion() == gAgent.getRegion())
322 {
323 addToSimAvList(avatar_ids[i], dist_string);
324 }
325 }
326 }
327 }
328 updateSimAvList(avatar_ids);
329 }
330 else if (!mSimAvatars.empty())
331 {
332 mSimAvatars.clear();
333 }
334
335 // only display avatars in range
336 if (distance <= range)
337 {
338 // append typing string
339 std::string typing = "";
340 if (getIsTyping(avatar_ids[i]))
341 {
342 typing = getString("is_typing")+ " ";
343 }
344
345 std::string mute_text = LLMuteList::getInstance()->isMuted(avatar_ids[i]) ? getString("is_muted") : "";
346 element["id"] = avatar_ids[i];
347 element["columns"][0]["column"] = "avatar_name";
348 element["columns"][0]["type"] = "text";
349 element["columns"][0]["value"] = typing + fullname + " " + mute_text;
350 element["columns"][1]["column"] = "avatar_distance";
351 element["columns"][1]["type"] = "text";
352 element["columns"][1]["value"] = dist_string+"m";
353
354 mRadarList->addElement(element, ADD_BOTTOM);
355 }
262 } 356 }
263// [/RLVa:KB] 357 }
264 358
265 std::string mute_text = LLMuteList::getInstance()->isMuted(avatar_ids[i]) ? getString("muted") : ""; 359 mRadarList->sortItems();
266 element["id"] = avatar_ids[i]; 360 mRadarList->setScrollPos(scroll_pos);
267 element["columns"][0]["column"] = "avatar_name"; 361 if (mSelectedAvatar.notNull())
268 element["columns"][0]["type"] = "text"; 362 {
269 element["columns"][0]["value"] = fullname + " " + mute_text; 363 mRadarList->selectByID(mSelectedAvatar);
270 element["columns"][1]["column"] = "avatar_distance";
271 element["columns"][1]["type"] = "text";
272
273 LLVector3d temp = positions[i] - current_pos;
274 F32 distance = (F32)temp.magVec();
275 char dist[32];
276 snprintf(dist, sizeof(dist), "%.1f", distance);
277 element["columns"][1]["value"] = strcat(dist,"m");
278
279 mRadarList->addElement(element, ADD_BOTTOM);
280 } 364 }
365 avatar_count << (int)avatar_ids.size();
281 } 366 }
367 else
368 {
369 mTypingAvatars.clear();
370 mRadarList->addCommentText(getString("no_one_near"), ADD_TOP);
371 avatar_count << "0";
372 }
373
374 childSetText("lblAvatarCount", avatar_count.str());
282 375
283 mRadarList->sortItems(); 376 toggleButtons();
284 mRadarList->setScrollPos(scroll_pos); 377
285 if (mSelectedAvatar.notNull()) 378 //llinfos << "mSelectedAvatar: " << mSelectedAvatar.asString() << llendl;
379}
380
381void LLFloaterMap::updateChatList(std::vector<LLUUID> agent_ids)
382{
383 std::set<LLUUID>::iterator it;
384 std::vector<LLUUID>::iterator result;
385 for (it = mChatAvatars.begin(); it != mChatAvatars.end(); )
286 { 386 {
287 mRadarList->selectByID(mSelectedAvatar); 387 result = find(agent_ids.begin(), agent_ids.end(), *it);
388 if (result == agent_ids.end())
389 {
390 mChatAvatars.erase(it++);
391 }
392 else
393 {
394 it++;
395 }
288 } 396 }
397}
289 398
290 // set count 399bool LLFloaterMap::getInChatList(LLUUID agent_id)
291 std::stringstream avatar_count; 400{
292 avatar_count.str(""); 401 if (mChatAvatars.count(agent_id) > 0)
293 if (avatar_ids.empty())
294 { 402 {
295 mRadarList->addCommentText(getString("no_one_near"), ADD_TOP); 403 return true;
296 avatar_count << "0"; 404 }
405 return false;
406}
407
408void LLFloaterMap::addToChatList(LLUUID agent_id, std::string distance)
409{
410 mChatAvatars.insert(agent_id);
411 LLChat chat;
412
413 LLUIString notify = getString("entering_chat_range");
414 notify.setArg("[NAME]", getSelectedName(agent_id));
415 notify.setArg("[DISTANCE]", distance);
416
417 chat.mText = notify;
418 chat.mSourceType = CHAT_SOURCE_SYSTEM;
419 LLFloaterChat::addChat(chat, FALSE, FALSE);
420}
421
422void LLFloaterMap::removeFromChatList(LLUUID agent_id)
423{
424 // Do we want to add a notice?
425 mChatAvatars.erase(agent_id);
426}
427
428bool LLFloaterMap::getIsTyping(LLUUID agent_id)
429{
430 if (mTypingAvatars.count(agent_id) > 0)
431 {
432 return true;
433 }
434 return false;
435}
436
437void LLFloaterMap::updateTypingList(LLUUID agent_id, bool remove)
438{
439 if (remove)
440 {
441 if (getIsTyping(agent_id))
442 {
443 mTypingAvatars.erase(agent_id);
444 }
297 } 445 }
298 else 446 else
299 { 447 {
300 avatar_count << (int)avatar_ids.size(); 448 mTypingAvatars.insert(agent_id);
301 } 449 }
302 childSetText("lblAvatarCount", avatar_count.str()); 450}
303 451
304 toggleButtons(); 452void LLFloaterMap::updateSimAvList(std::vector<LLUUID> agent_ids)
453{
454 std::set<LLUUID>::iterator it;
455 std::vector<LLUUID>::iterator result;
456 for (it = mSimAvatars.begin(); it != mSimAvatars.end(); )
457 {
458 result = find(agent_ids.begin(), agent_ids.end(), *it);
459 if (result == agent_ids.end())
460 {
461 mSimAvatars.erase(it++);
462 }
463 else
464 {
465 it++;
466 }
467 }
468}
305 469
306 //llinfos << "mSelectedAvatar: " << mSelectedAvatar.asString() << llendl; 470void LLFloaterMap::addToSimAvList(LLUUID agent_id, std::string distance)
471{
472 mSimAvatars.insert(agent_id);
473 LLChat chat;
474
475 LLUIString notify = getString("entering_sim_range");
476 notify.setArg("[NAME]", getSelectedName(agent_id));
477 notify.setArg("[DISTANCE]", distance);
478
479 chat.mText = notify;
480 chat.mSourceType = CHAT_SOURCE_SYSTEM;
481 LLFloaterChat::addChat(chat, FALSE, FALSE);
482}
483
484bool LLFloaterMap::getInSimAvList(LLUUID agent_id)
485{
486 if (mSimAvatars.count(agent_id) > 0)
487 {
488 return true;
489 }
490 return false;
307} 491}
308 492
309void LLFloaterMap::toggleButtons() 493void LLFloaterMap::toggleButtons()